page%swap@Sun.COM (Bob Page) (11/19/89)
Submitted-by: rsbx@cbmvax.commodore.com (Raymond S. Brand) Posting-number: Volume 89, Issue 223 Archive-name: unix/rcs.08 # This is a shell archive. # Remove anything above and including the cut line. # Then run the rest of the file through 'sh'. # Unpacked files will be owned by you and have default permissions. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: SHell ARchive # Run the following text through 'sh' to create: # rcs/rcs.rcsfiles/rcsbase.h,v # rcs/rcs.rcsfiles/rcsdiff.c,v # rcs/rcs.rcsfiles/rcsclean.c,v # This is archive 8 of a 14-part kit. # This archive created: Sun Nov 19 01:12:09 1989 if `test ! -d rcs` then mkdir rcs echo "mkdir rcs" fi if `test ! -d rcs/rcs.rcsfiles` then mkdir rcs/rcs.rcsfiles echo "mkdir rcs/rcs.rcsfiles" fi echo "extracting rcs/rcs.rcsfiles/rcsbase.h,v" sed 's/^X//' << \SHAR_EOF > rcs/rcs.rcsfiles/rcsbase.h,v Xhead 4.9; Xbranch 4.9.2; Xaccess ; Xsymbols amiga_rcs:4.9.2 cbmvax_source:4.9.1 uunet_june89_dist:4.9; Xlocks ; strict; Xcomment @ * @; X X X4.9 Xdate 89.05.01.15.17.14; author narten; state Exp; Xbranches 4.9.1.1 4.9.2.1; Xnext ; X X4.9.1.1 Xdate 89.08.11.01.42.12; author rsbx; state Exp; Xbranches ; Xnext ; X X4.9.2.1 Xdate 89.10.13.19.16.35; author rsbx; state Exp; Xbranches ; Xnext 4.9.2.2; X X4.9.2.2 Xdate 89.10.15.15.43.52; author rsbx; state Exp; Xbranches ; Xnext 4.9.2.3; X X4.9.2.3 Xdate 89.10.16.19.07.02; author rsbx; state Exp; Xbranches ; Xnext 4.9.2.4; X X4.9.2.4 Xdate 89.11.01.14.43.06; author rsbx; state Exp; Xbranches ; Xnext ; X X Xdesc X@RCS common definitions and data structures. X@ X X X X4.9 Xlog X@checked in with -k by rsbx at 89.08.10.16.06.59. X@ Xtext X@ X/* X * RCS common definitions and data structures X */ X#define RCSBASE "$Id: rcsbase.h,v 4.9 89/05/01 15:17:14 narten Exp $" X X/* Copyright (C) 1982, 1988, 1989 Walter Tichy X * All rights reserved. X * X * Redistribution and use in source and binary forms are permitted X * provided that the above copyright notice and this paragraph are X * duplicated in all such forms and that any documentation, X * advertising materials, and other materials related to such X * distribution and use acknowledge that the software was developed X * by Walter Tichy. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. X * X * Report all problems and direct all questions to: X * rcs-bugs@@cs.purdue.edu X * X X X X X X X X*/ X X X X/***************************************************************************** X * INSTRUCTIONS: X * ============= X * The following should be handled in the Makefile: X * For USG Unix, define USG; for BSD Unix, don't (see ifdef USG). X * For 4.2 bsd, define V4_2BSD; this will replace the routines X * getwd() and rename() with the corresponding ones in the C-library. X * V4_2BSD also selects different definitions for the macros NCPFN and NCPPN X * (max. number of characters per filename, number of characters per path name). X * Define STRICT_LOCKING appropriately (see STRICT_LOCKING). X * The following need be changed for porting to a different machine: X * Define SMALLOG for a machine with small memory (like the PDP11). X * SMALLOG conserves space for log messages. X * Change BYTESIZ if necessary. X * If you need to change the comment leaders, update the table comtable[] X * in rcsfnms.c. (This can wait until you know what a comment leader is.) X ***************************************************************************** X */ X X X/* $Log: rcsbase.h,v $ X * Revision 4.9 89/05/01 15:17:14 narten X * botched previous USG fix X * X * Revision 4.8 89/05/01 14:53:05 narten X * changed #include <strings.h> -> string.h for USG systems. X * X * Revision 4.7 88/11/08 15:58:45 narten X * removed defs for functions loaded from libraries X * X * Revision 4.6 88/11/08 12:04:06 narten X * changes from eggert@@sm.unisys.com (Paul Eggert) X * X * Revision 4.6 88/08/09 19:12:36 eggert X * Shrink stdio code size; remove lint; permit -Dhshsize=nn. X * X * Revision 4.5 87/12/18 17:06:41 narten X * made removed BSD ifdef, now uses V4_2BSD X * X * Revision 4.4 87/10/18 10:29:49 narten X * Updating version numbers X * Changes relative to 1.1 are actually relative to 4.2 X * X * Revision 1.3 87/09/24 14:02:25 narten X * changes for lint X * X * Revision 1.2 87/03/27 14:22:02 jenkins X * Port to suns X * X * Revision 1.1 84/01/23 14:50:14 kcs X * Initial revision X * X * Revision 4.2 83/12/20 16:04:20 wft X * merged 3.6.1.1 and 4.1 (SMALLOG, logsize). X * moved setting of STRICT_LOCKING to Makefile. X * changed DOLLAR to UNKN (conflict with KDELIM). X * X * Revision 4.1 83/05/04 09:12:41 wft X * Added markers Id and RCSfile. X * Added Dbranch for default branches. X * X * Revision 3.6.1.1 83/12/02 21:56:22 wft X * Increased logsize, added macro SMALLOG. X * X * Revision 3.6 83/01/15 16:43:28 wft X * 4.2 prerelease X * X * Revision 3.6 83/01/15 16:43:28 wft X * Replaced dbm.h with BYTESIZ, fixed definition of rindex(). X * Added variants of NCPFN and NCPPN for bsd 4.2, selected by defining V4_2BSD. X * Added macro DELNUMFORM to have uniform format for printing delta text nodes. X * Added macro DELETE to mark deleted deltas. X * X * Revision 3.5 82/12/10 12:16:56 wft X * Added two forms of DATEFORM, one using %02d, the other %.2d. X * X * Revision 3.4 82/12/04 20:01:25 wft X * added LOCKER, Locker, and USG (redefinition of rindex). X * X * Revision 3.3 82/12/03 12:22:04 wft X * Added dbm.h, stdio.h, RCSBASE, RCSSEP, RCSSUF, WORKMODE, TMPFILE3, X * PRINTDATE, PRINTTIME, map, and ctab; removed Suffix. Redefined keyvallength X * using NCPPN. Changed putc() to abort on write error. X * X * Revision 3.2 82/10/18 15:03:52 wft X * added macro STRICT_LOCKING, removed RCSUMASK. X * renamed JOINFILE[1,2] to JOINFIL[1,2]. X * X * Revision 3.1 82/10/11 19:41:17 wft X * removed NBPW, NBPC, NCPW. X * added typdef int void to aid compiling X */ X X X X#include <stdio.h> X#ifdef USG X#include <string.h> X#else X#include <strings.h> X#endif X#undef putc /* will be redefined */ X X X#ifdef USG X# define rindex strrchr X# define DATEFORM "%.2d.%.2d.%.2d.%.2d.%.2d.%.2d" X#else X# define DATEFORM "%02d.%02d.%02d.%02d.%02d.%02d" X#endif X/* Make sure one of %02d or %.2d prints a number with a field width 2, with X * leading zeroes. For example, 0, 1, and 22 must be printed as 00, 01, and X * 22. Otherwise, there will be problems with the dates. X */ X X#define PRINTDATE(file,date) fprintf(file,"%.2s/%.2s/%.2s",date,date+3,date+6) X#define PRINTTIME(file,date) fprintf(file,"%.2s:%.2s:%.2s",date+9,date+12,date+15) X/* print RCS format date and time in nice format from a string */ X X/* X * Parameters X */ X#define BYTESIZ 8 /* number of bits in a byte */ X X/*#define STRICT_LOCKING 0 /* 0 sets the default locking to non-strict; */ X /* used in experimental environments. */ X /* 1 sets the default locking to strict; */ X /* used in production environments. */ X /* STRICT_LOCKING is set in the Makefile! */ X#ifndef hshsize X#define hshsize 239 /* hashtable size; MUST be prime and -1 mod 4 */ X /* other choices: 547 or 719 */ X#endif X X#define strtsize (hshsize * 50) /* string table size */ X#ifdef SMALLOG X# define logsize 1024 /* max. size of log message for pdp11 */ X#else X# define logsize 4096 /* max. size of log message for others */ X#endif X#define revlength 30 /* max. length of revision numbers */ X#define datelength 20 /* length of a date in RCS format */ X#define joinlength 20 /* number of joined revisions permitted */ X#define RCSDIR "RCS/" /* subdirectory for RCS files */ X#define RCSSUF 'v' /* suffix for RCS files */ X#define RCSSEP ',' /* separator for RCSSUF */ X#define KDELIM '$' /* delimiter for keywords */ X#define VDELIM ':' /* separates keywords from values */ X#define DEFAULTSTATE "Exp" /* default state of revisions */ X#ifdef V4_2BSD X# define NCPFN 256 /* number of characters per filename */ X# define NCPPN 1024 /* number of characters per pathname */ X#else X# define NCPFN 14 /* number of characters per filename */ X# define NCPPN 6*NCPFN /* number of characters per pathname */ X#endif X#define keylength 20 /* buffer length for expansion keywords */ X#define keyvallength NCPPN+revlength+datelength+60 X /* buffer length for keyword expansion */ X X X X#define true 1 X#define false 0 X#define nil 0 X#define elsif else if X#define elif else if X X X/* temporary file names */ X X#define NEWRCSFILE ",RCSnewXXXXXX" X#define DIFFILE ",RCSciXXXXXX" X#define TMPFILE1 ",RCSt1XXXXXX" X#define TMPFILE2 ",RCSt2XXXXXX" X#define TMPFILE3 ",RCSt3XXXXXX" X#define JOINFIL2 ",RCSj2XXXXXX" X#define JOINFIL3 ",RCSj3XXXXXX" X X X#define putc(x,p) (--(p)->_cnt>=0? ((int)(*(p)->_ptr++=(unsigned)(x))):fflsbuf((unsigned)(x),p)) X/* This version of putc prints a char, but aborts on write error */ X X#define GETC(in,out,echo) (c=getc(in), echo?putc(c,out):c) X/* GETC modifies a local variable c; a kludge, but smaller and faster. */ X/* GETC writes a del-character (octal 177) on end of file */ X X#define WORKMODE(RCSmode) (RCSmode&~0222)|((lockflag||!StrictLocks)?0600:0000) X/* computes mode of working file: same as RCSmode, but write permission */ X/* determined by lockflag and StrictLocks. */ X X X/* character classes and token codes */ Xenum tokens { X/* char classes*/ DIGIT, IDCHAR, NEWLN, LETTER, PERIOD, SBEGIN, SPACE, UNKN, X/* tokens */ COLON, DATE, EOFILE, ID, KEYW, NUM, SEMI, STRING, X}; X X#define AT SBEGIN /* class SBEGIN (string begin) is returned by lex. anal. */ X#define SDELIM '@@' /* the actual character is needed for string handling*/ X/* these must be changed consistently, for instance to: X * #define DQUOTE SBEGIN X * #define SDELIM '"' X * #define AT IDCHAR X * there should be no overlap among SDELIM, KDELIM, and VDELIM X */ X X/* other characters */ X X#define ACCENT IDCHAR X#define AMPER IDCHAR X#define BACKSL IDCHAR X#define BAR IDCHAR X#define COMMA UNKN X#define DIVIDE IDCHAR X#define DOLLAR UNKN /* overlap with KDELIM */ X#define DQUOTE IDCHAR X#define EQUAL IDCHAR X#define EXCLA IDCHAR X#define GREAT IDCHAR X#define HASH IDCHAR X#define INSERT UNKN X#define LBRACE IDCHAR X#define LBRACK IDCHAR X#define LESS IDCHAR X#define LPARN IDCHAR X#define MINUS IDCHAR X#define PERCNT IDCHAR X#define PLUS IDCHAR X#define QUEST IDCHAR X#define RBRACE IDCHAR X#define RBRACK IDCHAR X#define RPARN IDCHAR X#define SQUOTE IDCHAR X#define TILDE IDCHAR X#define TIMES IDCHAR X#define UNDER IDCHAR X#define UPARR IDCHAR X X X X X/*************************************** X * Data structures for the symbol table X ***************************************/ X X X/* Hash table entry */ Xstruct hshentry { X char * num; /* pointer to revision number (ASCIZ) */ X char * date; /* pointer to date of checking */ X char * author; /* login of person checking in */ X char * lockedby; /* who locks the revision */ X char * log; /* log message requested at checkin */ X char * state; /* state of revision (Exp by default) */ X struct branchhead * branches; /* list of first revisions on branches*/ X struct hshentry * next; /* next revision on same branch */ X int insertlns;/* lines inserted (computed by rlog) */ X int deletelns;/* lines deleted (computed by rlog) */ X char selector; /* marks entry for selection/deletion */ X}; X X/* list element for branch lists */ Xstruct branchhead { X struct hshentry * hsh; X struct branchhead * nextbranch; X}; X X/* accesslist element */ Xstruct access { X char * login; X struct access * nextaccess; X}; X X/* list element for locks */ Xstruct lock { X char * login; X struct hshentry * delta; X struct lock * nextlock; X}; X X/* list element for symbolic names */ Xstruct assoc { X char * symbol; X struct hshentry * delta; X struct assoc * nextassoc; X}; X X X/* common variables (getadmin and getdelta())*/ Xextern char * Comment; Xextern struct access * AccessList; Xextern struct assoc * Symbols; Xextern struct lock * Locks; Xextern struct hshentry * Head; Xextern struct hshentry * Dbranch; Xextern int StrictLocks; Xextern int TotalDeltas; X#ifndef lint Xstatic char copyright[]="Copyright (C) 1982 by Walter F. Tichy"; X#endif X X/* common variables (lexical analyzer)*/ Xextern enum tokens map[]; X#define ctab (&map[1]) Xextern enum tokens nexttok; Xextern int hshenter; Xextern char * NextString; Xextern char * cmdid; X X#if defined(USG) || defined(V4_2BSD) X#define VOID (void) X#else Xtypedef int void; X#define VOID X#endif X X/* common routines */ Xextern char *talloc(); Xextern int serror(); Xextern int faterror(); Xextern int fatserror(); Xextern void ignoreints(); Xextern void catchints(); Xextern void restoreints(); X X#ifdef USG Xextern int sprintf(); X#endif X X/* X * Markers for keyword expansion (used in co and ident) X */ X#define AUTHOR "Author" X#define DATE "Date" X#define HEADER "Header" X#define IDH "Id" X#define LOCKER "Locker" X#define LOG "Log" X#define RCSFILE "RCSfile" X#define REVISION "Revision" X#define SOURCE "Source" X#define STATE "State" X Xenum markers { Nomatch, Author, Date, Header, Id, X Locker, Log, RCSfile, Revision, Source, State }; X X#define DELNUMFORM "\n\n%s\n%s\n" X/* used by putdtext and scanlogtext */ X#define DELETE 'D' X/* set by rcs -o and used by puttree() in rcssyn */ X X@ X X X4.9.2.1 Xlog X@Start of Amiga RCS port branch. X@ Xtext X@d5 1 Xa5 2 X<<<<<<< rcsbase.h X#define RCSBASE "$Id: rcsbase.h,v 4.9.1.1 89/08/11 01:42:12 rsbx Exp Locker: rsbx $" Xa33 3 X======= X#define RCSBASE "$Id: rcsbase.h,v 1.3 89/09/17 09:54:06 rick Exp $" X>>>>>>> 1.3 Xa54 9 X<<<<<<< rcsbase.h X * Revision 4.9.1.1 89/08/11 01:42:12 rsbx X * Start of cbmvax RCS source branch. X======= X * Revision 1.3 89/09/17 09:54:06 rick X * Change back to original X>>>>>>> 1.3 X * X<<<<<<< rcsbase.h Xa55 3 X * checked in with -k by rsbx at 89.08.10.16.06.59. X * X * Revision 4.9 89/05/01 15:17:14 narten Xa69 5 X======= X * Revision 1.2 88/09/03 15:14:12 rick X * Port to AmigaDos. All done with conditional compiles X * X>>>>>>> 1.3 Xa129 1 X<<<<<<< rcsbase.h Xa134 3 X======= X#ifndef AMIGA X>>>>>>> 1.3 Xa135 1 X#endif Xd137 1 Xa137 4 X#ifdef AMIGA X# define rindex strrchr X# define DATEFORM "%02d.%02d.%02d.%02d.%02d.%02d" X#else Xa143 1 X#endif Xa182 4 X#ifdef AMIGA X# define NCPFN 256 /* number of characters per filename */ X# define NCPPN 1024 /* number of characters per pathname */ X#else Xa189 1 X#endif Xd213 1 Xa213 1 X#ifndef AMIGA Xa215 1 X#endif X@ X X X4.9.2.2 Xlog X@Finished the integration of Rick Schaeffer's RCS Amiga port with the RCS Xsources I have here (and are later than the ones Rick used). X@ Xtext X@d5 2 Xa6 1 X#define RCSBASE "$Id: rcsbase.h,v 4.9.2.1 89/10/13 19:16:35 rsbx Exp Locker: rsbx $" Xd35 3 Xd59 1 Xa59 3 X * Revision 4.9.2.1 89/10/13 19:16:35 rsbx X * Start of Amiga RCS port branch. X * Xd62 4 Xd67 1 Xd86 5 Xd151 2 Xa152 1 X#if defined(USG) || defined(AMIGA) Xd157 1 Xd159 1 Xd380 1 Xa380 1 X#if defined(USG) || defined(V4_2BSD) || defined (AMIGA) X@ X X X4.9.2.3 Xlog X@Changed file path handling to deal with Amiga file path sematics. X@ Xtext X@d5 1 Xa5 1 X#define RCSBASE "$Id: rcsbase.h,v 4.9.2.2 89/10/15 15:43:52 rsbx Exp $" Xa54 4 X * Revision 4.9.2.2 89/10/15 15:43:52 rsbx X * Finished the integration of Rick Schaeffer's RCS Amiga port with the RCS X * sources I have here (and are later than the ones Rick used). X * Xa149 1 X# define index strchr X@ X X X4.9.2.4 Xlog X@Changes to make the delete bit to track the write bit. Made protection Xbit manipulation less insane. X@ Xtext X@d5 1 Xa5 1 X#define RCSBASE "$Id: rcsbase.h,v 4.9.2.3 89/10/16 19:07:02 rsbx Exp $" Xa54 3 X * Revision 4.9.2.3 89/10/16 19:07:02 rsbx X * Changed file path handling to deal with Amiga file path sematics. X * Xd230 7 Xa236 7 X#define NEWRCSFILE ",RCSnewXXXXXXXX" X#define DIFFILE ",RCSciXXXXXXXX" X#define TMPFILE1 ",RCSt1XXXXXXXX" X#define TMPFILE2 ",RCSt2XXXXXXXX" X#define TMPFILE3 ",RCSt3XXXXXXXX" X#define JOINFIL2 ",RCSj2XXXXXXXX" X#define JOINFIL3 ",RCSj3XXXXXXXX" Xa246 3 X#ifdef AMIGA X#define WORKMODE(RCSmode) (RCSmode&~(S_IWRITE|S_IDELETE))|((lockflag||!StrictLocks)?S_IWRITE|S_IREAD|S_IDELETE:0) X#else Xa247 1 X#endif X@ X X X4.9.1.1 Xlog X@Start of cbmvax RCS source branch. X@ Xtext X@a55 3 X * checked in with -k by rsbx at 89.08.10.16.06.59. X * X * Revision 4.9 89/05/01 15:17:14 narten X@ SHAR_EOF echo "extracting rcs/rcs.rcsfiles/rcsdiff.c,v" sed 's/^X//' << \SHAR_EOF > rcs/rcs.rcsfiles/rcsdiff.c,v Xhead 4.6; Xbranch 4.6.2; Xaccess ; Xsymbols amiga_rcs:4.6.2 cbmvax_source:4.6.1 uunet_june89_dist:4.6; Xlocks ; strict; Xcomment @ * @; X X X4.6 Xdate 89.05.01.15.12.27; author narten; state Exp; Xbranches 4.6.1.1 4.6.2.1; Xnext ; X X4.6.1.1 Xdate 89.08.11.01.42.22; author rsbx; state Exp; Xbranches ; Xnext ; X X4.6.2.1 Xdate 89.10.13.19.18.20; author rsbx; state Exp; Xbranches ; Xnext 4.6.2.2; X X4.6.2.2 Xdate 89.10.15.15.44.03; author rsbx; state Exp; Xbranches ; Xnext 4.6.2.3; X X4.6.2.3 Xdate 89.11.12.15.07.26; author rsbx; state Exp; Xbranches ; Xnext ; X X Xdesc X@RCS rcsdiff operation. X@ X X X X4.6 Xlog X@checked in with -k by rsbx at 89.08.10.16.19.11. X@ Xtext X@/* X * RCS rcsdiff operation X */ X#ifndef lint Xstatic char rcsid[]= X"$Header: /usr/src/local/bin/rcs/src/RCS/rcsdiff.c,v 4.6 89/05/01 15:12:27 narten Exp $ Purdue CS"; X#endif X/***************************************************************************** X * generate difference between RCS revisions X ***************************************************************************** X */ X X/* Copyright (C) 1982, 1988, 1989 Walter Tichy X * All rights reserved. X * X * Redistribution and use in source and binary forms are permitted X * provided that the above copyright notice and this paragraph are X * duplicated in all such forms and that any documentation, X * advertising materials, and other materials related to such X * distribution and use acknowledge that the software was developed X * by Walter Tichy. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. X * X * Report all problems and direct all questions to: X * rcs-bugs@@cs.purdue.edu X * X X X X X X X X*/ X X X X X/* $Log: rcsdiff.c,v $ X * Revision 4.6 89/05/01 15:12:27 narten X * changed copyright header to reflect current distribution rules X * X * Revision 4.5 88/11/08 12:01:51 narten X * changes from eggert@@sm.unisys.com (Paul Eggert) X * X * Revision 4.5 88/08/09 19:12:41 eggert X * Use execv(), not system(); yield exit status like diff(1)s; allow cc -R. X * X * Revision 4.4 87/12/18 11:37:46 narten X * changes Jay Lepreau made in the 4.3 BSD version, to add support for X * "-i", "-w", and "-t" flags and to permit flags to be bundled together, X * merged in. X * X * Revision 4.3 87/10/18 10:31:42 narten X * Updating version numbers. Changes relative to 1.1 actually X * relative to 4.1 X * X * Revision 1.3 87/09/24 13:59:21 narten X * Sources now pass through lint (if you ignore printf/sprintf/fprintf X * warnings) X * X * Revision 1.2 87/03/27 14:22:15 jenkins X * Port to suns X * X * Revision 1.1 84/01/23 14:50:18 kcs X * Initial revision X * X * Revision 4.1 83/05/03 22:13:19 wft X * Added default branch, option -q, exit status like diff. X * Added fterror() to replace faterror(). X * X * Revision 3.6 83/01/15 17:52:40 wft X * Expanded mainprogram to handle multiple RCS files. X * X * Revision 3.5 83/01/06 09:33:45 wft X * Fixed passing of -c (context) option to diff. X * X * Revision 3.4 82/12/24 15:28:38 wft X * Added call to catchsig(). X * X * Revision 3.3 82/12/10 16:08:17 wft X * Corrected checking of return code from diff; improved error msgs. X * X * Revision 3.2 82/12/04 13:20:09 wft X * replaced getdelta() with gettree(). Changed diagnostics. X * X * Revision 3.1 82/11/28 19:25:04 wft X * Initial revision. X * X */ X#include <ctype.h> X#include "rcsbase.h" X#define ERRCODE 2 /*error code for exit status */ Xextern char *rindex(); X#ifndef lint Xstatic char rcsbaseid[] = RCSBASE; X#endif Xstatic char co[] = CO; X Xextern int cleanup(); /* cleanup after signals */ Xextern char * mktempfile(); /*temporary file name generator */ Xextern int fterror(); /*forward for special fatal error func. */ Xextern struct hshentry * genrevs(); /*generate delta numbers */ Xextern int nerror; /*counter for errors */ Xextern int quietflag; /*suppresses diagnostics */ Xextern FILE * finptr; /* RCS input file */ X Xchar *RCSfilename; Xchar *workfilename; Xchar * temp1file, * temp2file; X Xchar bops[10]; Xchar otherops[10]; X Xmain (argc, argv) Xint argc; char **argv; X{ X char * cmdusage; X char commarg[revlength+3]; X int revnums; /* counter for revision numbers given */ X char * rev1, * rev2; /* revision numbers from command line */ X char numericrev[revlength]; /* holds expanded revision number */ X char * xrev1, * xrev2; /* expanded revision numbers */ X struct hshentry * gendeltas[hshsize];/*stores deltas to be generated*/ X struct hshentry * target; X char * boption, * otheroption; X int exit_stats; X int diffs_found; X char *argp; X register c; X X catchints(); X otheroption = otherops + 2; X boption = bops + 2; X cmdid = "rcsdiff"; X cmdusage = "command format:\n rcsdiff [-biwt] [-q] [-cefhn] [-rrev1] [-rrev2] file"; X diffs_found=revnums=0; X while (--argc,++argv, argc>=1 && ((*argv)[0] == '-')) { X argp = &((*argv)[1]); X while (c = *argp++) switch (c) { X case 'r': X if (*argp!='\0') { X if (revnums==0) { X rev1= argp; revnums=1; X } elif (revnums==1) { X rev2= argp; revnums=2; X } else { X fterror("too many revision numbers"); X } X } /* do nothing for empty -r */ X argp += strlen(argp); X break; X case 'b': X case 'i': X case 'w': X case 't': X if (!rindex(bops + 2, c)) X *boption++ = c; X break; X case 'q': X quietflag=true; X break; X case 'c': X case 'e': X case 'f': X case 'h': X case 'n': X if (otheroption == otherops + 2) { X *otheroption++ = c; X if (c == 'c' && isdigit(*argp)) { X while (isdigit(*argp) && otheroption < otherops+sizeof(otherops)-1) X *otheroption++ = *argp++; X if (*argp) X faterror("-c: bad count"); X argp = ""; X } X } else { X fterror("Options c,e,f,h,n are mutually exclusive"); X } X break; X default: X fterror("unknown option: %s\n%s", *argv,cmdusage); X }; X } /* end of option processing */ X X if (boption != bops + 2) { X bops[0] = ' '; X bops[1] = '-'; X boption = bops; X } X if (otheroption != otherops + 2) { X otherops[0] = ' '; X otherops[1] = '-'; X otheroption = otherops; X } X if (argc<1) fterror("No input file\n%s",cmdusage); X X /* now handle all filenames */ X do { X finptr=NULL; X X if (pairfilenames(argc,argv,true,false)!=1) continue; X diagnose("==================================================================="); X diagnose("RCS file: %s",RCSfilename); X if (revnums<2 && !(access(workfilename,4)==0)) { X error("Can't open %s",workfilename); X continue; X } X if (!trysema(RCSfilename,false)) continue; /* give up */ X X X gettree(); /* reads in the delta tree */ X X if (Head==nil) { X error("no revisions present"); X continue; X } X if (revnums==0) X rev1=Dbranch!=nil?Dbranch->num:Head->num; /* default rev1 */ X X if (!expandsym(rev1,numericrev)) continue; X if (!(target=genrevs(numericrev,(char *)nil,(char *)nil,(char *)nil,gendeltas))) continue; X xrev1=target->num; X X if (revnums==2) { X if (!expandsym(rev2,numericrev)) continue; X if (!(target=genrevs(numericrev,(char *)nil,(char *)nil,(char *)nil,gendeltas))) continue; X xrev2=target->num; X } X X X temp1file=mktempfile("/tmp/",TMPFILE1); X diagnose("retrieving revision %s",xrev1); X VOID sprintf(commarg,"-p%s",xrev1); X if (run((char*)nil,temp1file, co,"-q",commarg,RCSfilename,(char*)nil)){ X error("co failed"); X continue; X } X if (revnums<=1) { X temp2file=workfilename; X diagnose("diff%s%s -r%s %s",boption,otheroption,xrev1,workfilename); X } else { X temp2file=mktempfile("/tmp/",TMPFILE2); X diagnose("retrieving revision %s",xrev2); X VOID sprintf(commarg,"-p%s",xrev2); X if (run((char*)nil,temp2file, co,"-q",commarg,RCSfilename,(char *)nil)){ X error("co failed"); X continue; X } X diagnose("diff%s%s -r%s -r%s",boption,otheroption,xrev1,xrev2); X } X X exit_stats = X *boption X ? *otheroption X ? run((char*)nil,(char*)nil, DIFF, boption+1, otheroption+1, temp1file,temp2file,(char*)nil) X : run((char*)nil,(char*)nil, DIFF, boption+1, temp1file,temp2file,(char*)nil) X : *otheroption X ? run((char*)nil,(char*)nil, DIFF, otheroption+1, temp1file,temp2file,(char*)nil) X : run((char*)nil,(char*)nil, DIFF, temp1file,temp2file,(char*)nil); X X if (exit_stats == (1 << BYTESIZ)) X diffs_found = 1; X else if (exit_stats != 0) { X error ("diff failed"); X continue; X } X } while (cleanup(), X ++argv, --argc >=1); X X X exit(nerror ? ERRCODE : diffs_found); X} X X X/*VARARGS3*/ Xfterror(e, e1, e2) Xchar * e, * e1, * e2; X/* prints error message and terminates program with ERRCODE */ X{ nerror++; X VOID fprintf(stderr,"%s error: ",cmdid); X VOID fprintf(stderr,e, e1, e2); X VOID fprintf(stderr,"\n%s aborted\n",cmdid); X VOID cleanup(); X exit(ERRCODE); X} X X@ X X X4.6.2.1 Xlog X@Start of Amiga RCS port branch. X@ Xtext X@d6 1 Xa6 5 X<<<<<<< rcsdiff.c X"$Header: /u/softeng/rsbx/rcs/amiga/RCS.cbmvax/rcsdiff.c,v 4.6.1.1 89/08/11 01:42:22 rsbx Exp Locker: rsbx $ Purdue CS"; X======= X"$Header: /u/softeng/rsbx/rcs/amiga/RCS/rcsdiff.c,v 1.2 89/09/17 13:35:25 rick Exp $ Purdue CS"; X>>>>>>> 1.2 Xa41 11 X<<<<<<< rcsdiff.c X * Revision 4.6.1.1 89/08/11 01:42:22 rsbx X * Start of cbmvax RCS source branch. X======= X * Revision 1.2 89/09/17 13:35:25 rick X * Port to AmigaDos done by Rick Schaeffer (ricks@@iscuva.iscs.com) X * All changes done with conditional compile (#ifdef AMIGA). This version X * compiles correctly with Lattice C version 5.02 or later. X>>>>>>> 1.2 X * X<<<<<<< rcsdiff.c Xa42 3 X * checked in with -k by rsbx at 89.08.10.16.19.11. X * X * Revision 4.6 89/05/01 15:12:27 narten Xa50 8 X======= X * Revision 1.3 89/09/10 09:27:39 rick X * Moved TARGETDIR to rcs: X * X * Revision 1.2 88/09/03 15:09:44 rick X * Port to AmigaDos. All done with conditional compiles X * X>>>>>>> 1.2 Xa101 6 X#ifdef AMIGA X#define DTMPFILE1 ",RDFt1XXXXXX" X#define DTMPFILE2 ",RDFt2XXXXXX" X#define DTMPFILE3 ",RDFt3XXXXXX" X#endif X Xa233 3 X#ifdef AMIGA X temp1file=mktempfile("t:",DTMPFILE1); X#else Xa234 1 X#endif Xa235 1 X<<<<<<< rcsdiff.c Xa237 5 X======= X VOID sprintf(command,"%sco -q -p%s %s >%s\n", X TARGETDIR,xrev1,RCSfilename,temp1file); X if (system(command)){ X>>>>>>> 1.2 Xa244 3 X#ifdef AMIGA X temp2file=mktempfile("t:",DTMPFILE2); X#else Xa245 1 X#endif Xa246 1 X<<<<<<< rcsdiff.c Xa248 5 X======= X VOID sprintf(command,"%sco -q -p%s %s >%s\n", X TARGETDIR,xrev2,RCSfilename,temp2file); X if (system(command)){ X>>>>>>> 1.2 X@ X X X4.6.2.2 Xlog X@Finished the integration of Rick Schaeffer's RCS Amiga port with the RCS Xsources I have here (and are later than the ones Rick used). X@ Xtext X@d6 5 Xa10 1 X"$Header: /u/softeng/rsbx/rcs/amiga/RCS/rcsdiff.c,v 4.6.2.1 89/10/13 19:18:20 rsbx Exp Locker: rsbx $ Purdue CS"; Xd46 1 Xa46 3 X * Revision 4.6.2.1 89/10/13 19:18:20 rsbx X * Start of Amiga RCS port branch. X * Xd49 6 Xd56 1 Xd69 8 Xd272 1 Xd275 5 Xd293 1 Xd296 5 X@ X X X4.6.2.3 Xlog X@WaitChild() on the Amiga returns the completion code from a child process Xwithout shifting it up 8 bits like the Unix wait() does. X@ Xtext X@d6 1 Xa6 1 X"$Header: /u/softeng/rsbx/rcs/amiga/RCS/rcsdiff.c,v 4.6.2.2 89/10/15 15:44:03 rsbx Exp $ Purdue CS"; Xa41 4 X * Revision 4.6.2.2 89/10/15 15:44:03 rsbx X * Finished the integration of Rick Schaeffer's RCS Amiga port with the RCS X * sources I have here (and are later than the ones Rick used). X * Xa286 3 X#ifdef AMIGA X if (exit_stats == 1) X#else Xa287 1 X#endif X@ X X X4.6.1.1 Xlog X@Start of cbmvax RCS source branch. X@ Xtext X@d6 1 Xa6 1 X"$Header: /u/softeng/rsbx/rcs/rcs.uunet/src/RCS/rcsdiff.c,v 4.6 89/05/01 15:12:27 narten Exp $ Purdue CS"; Xa41 3 X * Revision 4.6 89/05/01 15:12:27 narten X * checked in with -k by rsbx at 89.08.10.16.19.11. X * X@ SHAR_EOF echo "extracting rcs/rcs.rcsfiles/rcsclean.c,v" sed 's/^X//' << \SHAR_EOF > rcs/rcs.rcsfiles/rcsclean.c,v Xhead 4.4; Xbranch 4.4.2; Xaccess ; Xsymbols amiga_rcs:4.4.2 cbmvax_source:4.4.1 uunet_june89_dist:4.4; Xlocks ; strict; Xcomment @ * @; X X X4.4 Xdate 89.05.01.15.12.21; author narten; state Exp; Xbranches 4.4.1.1 4.4.2.1; Xnext ; X X4.4.1.1 Xdate 89.08.11.01.42.15; author rsbx; state Exp; Xbranches ; Xnext ; X X4.4.2.1 Xdate 89.10.13.19.18.16; author rsbx; state Exp; Xbranches ; Xnext 4.4.2.2; X X4.4.2.2 Xdate 89.10.15.15.43.57; author rsbx; state Exp; Xbranches ; Xnext ; X X Xdesc X@RCS rcsclean operation. X@ X X X X4.4 Xlog X@checked in by rsbx at 89.08.10.16.15.55. X@ Xtext X@/* X * RCS rcsclean operation X */ X Xstatic char rcsid[]= X"$Header $ Purdue CS"; X/***************************************************************************** X * remove unneded working files X ***************************************************************************** X */ X X/* Copyright (C) 1982, 1988, 1989 Walter Tichy X * All rights reserved. X * X * Redistribution and use in source and binary forms are permitted X * provided that the above copyright notice and this paragraph are X * duplicated in all such forms and that any documentation, X * advertising materials, and other materials related to such X * distribution and use acknowledge that the software was developed X * by Walter Tichy. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. X * X * Report all problems and direct all questions to: X * rcs-bugs@@cs.purdue.edu X * X X X X X X X X*/ X X X X X/* $Log: rcsclean.c,v $ X * Revision 4.4 89/05/01 15:12:21 narten X * changed copyright header to reflect current distribution rules X * X * Revision 4.3 88/11/08 15:59:54 narten X * removed reference to TARGETDIR X * X * Revision 4.2 87/10/18 10:30:43 narten X * Updating version numbers. Changes relative to 1.1 are actually X * relative to 4.1 X * X * Revision 1.2 87/09/24 13:59:13 narten X * Sources now pass through lint (if you ignore printf/sprintf/fprintf X * warnings) X * X * Revision 1.1 84/01/23 14:50:16 kcs X * Initial revision X * X * Revision 4.1 83/12/15 12:26:18 wft X * Initial revision. X * X */ X#include "rcsbase.h" X#define ERRCODE 2 /*error code for exit status */ Xstatic char rcsbaseid[] = RCSBASE; X Xextern int cleanup(); /* cleanup after signals */ Xextern char * mktempfile(); /*temporary file name generator */ Xextern int fterror(); /*forward for special fatal error func. */ Xextern struct hshentry * genrevs(); /*generate delta numbers */ Xextern int nerror; /*counter for errors */ Xextern int quietflag; /*suppresses diagnostics */ Xextern FILE * finptr; /* RCS input file */ Xextern FILE * fopen(); X Xchar *RCSfilename; Xchar *workfilename; Xchar * tempfile; XFILE * file1, * file2; /*file descriptors for comparison */ X Xmain (argc, argv) Xint argc; char **argv; X{ X char * cmdusage; X char command[NCPPN+revlength+40]; X char * rev; /* revision number from command line */ X char numericrev[revlength]; /* holds expanded revision number */ X int revnums; /* number of -r options */ X struct hshentry * gendeltas[hshsize];/*stores deltas to be generated*/ X struct hshentry * target; X int filecounter; X register int c1; /* reading input */ X int result; /* result of comparison */ X int pairresult; /* reulst of pairfilenames */ X X catchints(); X cmdid = "rcsclean"; X cmdusage = "command format:\n rcsclean [-rrev] file"; X filecounter=revnums=0; X quietflag=true; /* default no diagnostics */ X while (--argc,++argv, argc>=1 && ((*argv)[0] == '-')) { X switch ((*argv)[1]) { X case 'r': X revno: if ((*argv)[2]!='\0') { X if (revnums==0) { X rev= *argv+2; revnums=1; X } else { X fterror("too many revision numbers"); X } X } /* do nothing for empty -r */ X break; X case 'D': /* debug option */ X quietflag = false; X break; X X default: X fterror("unknown option: %s\n%s", *argv,cmdusage); X }; X } /* end of option processing */ X X if (argc<1) fterror("No input file\n%s",cmdusage); X X /* now handle all filenames */ X do { X finptr=NULL; X pairresult=pairfilenames(argc,argv,false,false); X X if (pairresult==0) continue; /* error */ X if (!(access(workfilename,4)==0)) { X diagnose("Can't open %s",workfilename); X continue; X } elsif (pairresult == -1) { X warn("Can't find RCS file for %s",workfilename); X continue; X } X diagnose("RCS file: %s",RCSfilename); X if (!trysema(RCSfilename,false)) continue; /* give up */ X X X gettree(); /* reads in the delta tree */ X X if (Head==nil) { X error("no revisions present"); X continue; X } X if (revnums==0) X rev=(Dbranch!=nil?Dbranch->num:Head->num); /* default rev1 */ X X if (!expandsym(rev,numericrev)) continue; X if (!(target=genrevs(numericrev,nil,nil,nil,gendeltas))) continue; X X tempfile=mktempfile("/tmp/",TMPFILE1); X diagnose("retrieving revision %s",target->num); X VOID sprintf(command,"%s -q -p%s %s > %s\n", X CO ,target->num,RCSfilename,tempfile); X if (system(command)){ X error("co failed"); X continue; X } X /* now do comparison */ X if ((file1=fopen(tempfile,"r"))==NULL) { X error("Can't open checked out file %s",tempfile); X continue; X } X if ((file2=fopen(workfilename,"r"))==NULL) { X error("Can't open %s",workfilename); X continue; X } X result=1; X while ((c1=getc(file1))==getc(file2)) { X if (c1==EOF) { X /* identical files; can remove working file */ X result=0; X diagnose("files identical; %s removed",workfilename); X if (unlink(workfilename)!=0) { X error("Can't unlink %s",workfilename); X } X break; X } X } X fclose(file1); fclose(file2); X X if (result==1) diagnose ("files different"); X X X } while (cleanup(), X ++argv, --argc >=1); X X X if (nerror>0) { X exit(ERRCODE); X } else { X exit(result); X } X X} X X Xfterror(e, e1, e2) Xchar * e, * e1, * e2; X/* prints error message and terminates program with ERRCODE */ X{ nerror++; X VOID fprintf(stderr,"%s error: ",cmdid); X VOID fprintf(stderr,e, e1, e2); X VOID fprintf(stderr,"\n%s aborted\n",cmdid); X VOID cleanup(); X exit(ERRCODE); X} X X@ X X X4.4.2.1 Xlog X@Start of Amiga RCS port branch. X@ Xtext X@a40 11 X<<<<<<< rcsclean.c X * Revision 4.4.1.1 89/08/11 01:42:15 rsbx X * Start of cbmvax RCS source branch. X======= X * Revision 1.2 89/09/17 13:35:21 rick X * Port to AmigaDos done by Rick Schaeffer (ricks@@iscuva.iscs.com) X * All changes done with conditional compile (#ifdef AMIGA). This version X * compiles correctly with Lattice C version 5.02 or later. X>>>>>>> 1.2 X * X<<<<<<< rcsclean.c Xa41 3 X * checked in by rsbx at 89.08.10.16.15.55. X * X * Revision 4.4 89/05/01 15:12:21 narten Xa46 8 X======= X * Revision 1.3 89/09/10 09:27:22 rick X * Moved TARGETDIR to rcs: X * X * Revision 1.2 88/09/03 15:09:35 rick X * Port to AmigaDos. All done with conditional compiles X * X>>>>>>> 1.2 Xa150 3 X#ifdef AMIGA X tempfile=mktempfile("t:",TMPFILE1); X#else Xa151 1 X#endif Xa152 1 X<<<<<<< rcsclean.c Xa154 4 X======= X sprintf(command,"%sco -q -p%s %s >%s\n", X TARGETDIR,target->num,RCSfilename,tempfile); X>>>>>>> 1.2 Xa173 1 X fclose(file2); file2 = NULL; Xd180 1 Xa180 4 X if (file1) X fclose(file1); X if (file2) X fclose(file2); X@ X X X4.4.2.2 Xlog X@Finished the integration of Rick Schaeffer's RCS Amiga port with the RCS Xsources I have here (and are later than the ones Rick used). X@ Xtext X@d41 1 Xa41 3 X * Revision 4.4.2.1 89/10/13 19:18:16 rsbx X * Start of Amiga RCS port branch. X * Xd44 6 Xd51 1 Xd61 8 Xd179 1 Xd182 4 X@ X X X4.4.1.1 Xlog X@Start of cbmvax RCS source branch. X@ Xtext X@a41 3 X * checked in by rsbx at 89.08.10.16.15.55. X * X * Revision 4.4 89/05/01 15:12:21 narten X@ SHAR_EOF echo "End of archive 8 (of 14)" # if you want to concatenate archives, remove anything after this line exit