1 /* Copyright (C) 1982, 1988, 1989 Walter Tichy
4 * Redistribution and use in source and binary forms are permitted
5 * provided that the above copyright notice and this paragraph are
6 * duplicated in all such forms and that any documentation,
7 * advertising materials, and other materials related to such
8 * distribution and use acknowledge that the software was developed
10 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
11 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14 * Report all problems and direct all questions to:
15 * rcs-bugs@cs.purdue.edu
27 * RCS identification operation
31 "$Header: /pub/NetBSD/misc/repositories/cvsroot/src/usr.bin/rcs/src/Attic/ident.c,v 1.1 1993/03/21 09:58:06 cgd Exp $Purdue CS";
35 * Revision 4.5 89/05/01 15:11:54 narten
36 * changed copyright header to reflect current distribution rules
38 * Revision 4.4 87/10/23 17:09:57 narten
39 * added exit(0) so exit return code would be non random
41 * Revision 4.3 87/10/18 10:23:55 narten
42 * Updating version numbers. Changes relative to 1.1 are actually relative
45 * Revision 1.3 87/07/09 09:20:52 trinkle
46 * Added check to make sure there is at least one arg before comparing argv[1]
47 * with "-q". This necessary on machines that don't allow dereferncing null
48 * pointers (i.e. Suns).
50 * Revision 1.2 87/03/27 14:21:47 jenkins
53 * Revision 1.1 84/01/23 14:50:03 kcs
56 * Revision 4.1 83/05/10 16:31:02 wft
57 * Added option -q and input from reading stdin.
58 * Marker matching is now done with trymatch() (independent of keywords).
60 * Revision 3.4 83/02/18 17:37:49 wft
61 * removed printing of new line after last file.
63 * Revision 3.3 82/12/04 12:48:55 wft
66 * Revision 3.2 82/11/28 18:24:17 wft
67 * removed Suffix; added ungetc to avoid skipping over trailing KDELIM.
69 * Revision 3.1 82/10/13 15:58:51 wft
70 * fixed type of variables receiving from getc() (char-->int).
78 #define fflsbuf _flsbuf
80 /* redefinition of putc not needed */
82 static char rcsbaseid
[] = RCSBASE
;
85 extern enum markers
trymatch();
90 int argc
; char *argv
[];
91 /* Ident searches the named files for all occurrences
92 * of the pattern $keyword:...$, where the keywords are
93 * Author, Date, Header, Id, Log, RCSfile, Revision, Source, and State.
100 if (argc
> 1 && strcmp("-q",argv
[1])==0) {
106 if ((scanfile(stdin
) == 0) && !quietflag
)
107 VOID
fprintf(stderr
, "ident warning: no id keywords in input\n");
111 while ( --argc
> 0 ) {
112 if ( (fp
= fopen(*++argv
, "r") ) == NULL
) {
113 VOID
fprintf(stderr
, "ident error: can't open %s\n", *argv
);
116 VOID
printf( "%s:\n", *argv
); /* print file name */
117 if ((scanfile(fp
) == 0) && !quietflag
)
118 VOID
fprintf(stderr
, "ident warning: no id keywords in %s\n", *argv
);
119 if (argc
>1) putchar('\n');
129 /* Function: scan an open file with descriptor file for keywords.
130 * Returns the number of matches.
133 register int matchcount
;
138 while( (c
=getc(file
)) != EOF
) {
139 if ( (char)c
==KDELIM
)
140 matchcount
+= match(file
);
147 match(fp
) /* group substring between two KDELIM's; then do pattern match */
150 char line
[keyvallength
];
155 while( (c
= getc(fp
)) != KDELIM
) {
157 if ( c
==EOF
|| c
=='\n' || tp
>= line
+keyvallength
-2)
160 *tp
++ = c
; /*append trailing KDELIM*/
162 if (trymatch(line
,true)!=Nomatch
) {
163 VOID
fprintf(stdout
," $%s\n",line
);
166 /* no match; put trailing KDELIM back into input */