Try out this little gizmo which I coded back about 1983 I think:
/*
*
* This program identifies both RCS and SCCS files.
*
*/
static char *RcsId = "$Id$";
#include <stdio.h>
char line[256];
main( int argc, char **argv )
{
FILE *fp, *fopen();
if ( argc < 2 )
{
fprintf( stderr, "Usage: %s file [file ...]\n", argv[0] );
exit( 0 );
}
while ( --argc > 0 )
{
if ( (fp = fopen( *++argv, "r" ) ) == NULL )
{
fprintf( stderr, "Can't open %s\n", *argv );
continue;
}
else
{
printf( "%s:\n", *argv );
scanfile( fp );
fclose( fp );
}
}
exit(0);
Quote:}
int scanfile( FILE *file )
{
register int c;
while( (c = getc( file )) != EOF )
{
if ( (char) c == '$' )
rcsmatch( file );
sccsmatch( file );
}
Quote:}
/* Group substring between two '$'s; then do pattern match. */
int rcsmatch( FILE *fp )
{
register int c;
register char *tp;
tp = line;
while( (c = getc(fp)) != '$' )
{
*tp++ = c;
if ( c == EOF || c == '\n' || tp >= line + sizeof(line) - 2 )
return 0;
}
*tp++ = c; /* append trailing '$' */
*tp = '\0';
if ( strncmp( line, "Header", 6 ) == 0 ||
strncmp( line, "Id", 2 ) == 0 )
{
printf( "\t$%s\n", line );
return 1;
}
else
{
/* no match; put trailing '$' back into input */
ungetc( c, fp );
return 0;
}
Quote:}
int sccsmatch( FILE *fp )
{
register int c;
register char *tp;
tp = line;
while( (c = getc(fp)) != '\n' && c != '\0' )
{
*tp++ = c;
if ( c == EOF || c == '\n' || tp >= line + sizeof(line) - 2 )
return 0;
}
/* *tp++ = c; /* append trailing '$' */
*tp = '\0';
if ( strncmp( line, "(#)", 3 ) == 0 )
{
printf( "\t%s\n", line + 3 );
return 1;
}
else
{
/* no match; put trailing character back into input */
ungetc( c, fp );
return 0;
}
Quote:}
--
David Wayne Summers "Linux: Because reboots are for upgrades!"
PGP Key fingerprint = C0 E0 4F 50 DD A9 B6 2B 60 A1 31 7E D2 28 6D A8