1: /*
   2:  *                     RCS identification operation
   3:  */
   4:  static char rcsid[] =
   5:  "$Header: /usr/wft/RCS/SRC/RCS/ident.c,v 3.4 83/02/18 17:37:49 wft Exp $Purdue CS";
   6: /*****************************************************************************
   7:  *****************************************************************************
   8:  *
   9:  * Copyright (C) 1982 by Walter F. Tichy
  10:  *                       Purdue University
  11:  *                       Computer Science Department
  12:  *                       West Lafayette, IN 47907
  13:  *
  14:  * All rights reserved. No part of this software may be sold or distributed
  15:  * in any form or by any means without the prior written permission of the
  16:  * author.
  17:  * Report problems and direct all inquiries to Tichy@purdue (ARPA net).
  18:  */
  19: 
  20: /* $Log:	ident.c,v $
  21:  * Revision 3.4  83/02/18  17:37:49  wft
  22:  * removed printing of new line after last file.
  23:  *
  24:  * Revision 3.3  82/12/04  12:48:55  wft
  25:  * Added LOCKER.
  26:  *
  27:  * Revision 3.2  82/11/28  18:24:17  wft
  28:  * removed Suffix; added ungetc to avoid skipping over trailing KDELIM.
  29:  *
  30:  * Revision 3.1  82/10/13  15:58:51  wft
  31:  * fixed type of variables receiving from getc() (char-->int).
  32: */
  33: 
  34: #include  "rcsbase.h"
  35: #define fflsbuf _flsbuf
  36: /* redefinition of _flsbuf in putc not needed */
  37: static char rcsbaseid[] = RCSBASE;
  38: 
  39: main(argc, argv)
  40: int  argc; char  *argv[];
  41: /*  Ident searches the named files for all occurrences
  42:  *  of the pattern $keyword:...$, where the keywords are
  43:  *  Author, Date, Header, Log, Revision, Source, and State.
  44:  */
  45: 
  46: {
  47:    FILE *fp, *fopen();
  48:    register int c;
  49:    register int matchcount;
  50: 
  51:    if (argc<2) {
  52:         fprintf(stderr,  "ident error: no input file\n");
  53:         exit(1);
  54:    }
  55:    while ( --argc > 0 ) {
  56:       if ( (fp = fopen(*++argv, "r") ) == NULL ) {
  57:          fprintf(stderr,  "ident error: can't open %s\n", *argv);
  58:          continue;
  59:       } else {
  60:          matchcount = 0;
  61:          printf( "%s:\n", *argv);   /*  print file name  */
  62:          while( (c=getc(fp)) != EOF) {
  63:             if ( (char)c==KDELIM)
  64:                matchcount += match(fp);
  65:          }
  66:          if (matchcount == 0)
  67:             fprintf(stderr, "ident warning: no id keywords in %s\n", *argv);
  68:          if (argc>1) putchar('\n');
  69:       }
  70:       fclose(fp);
  71:    }
  72: }
  73: 
  74: match(fp)   /* group substring between two KDELIM's; then do pattern match */
  75: FILE *fp;
  76: 
  77: {
  78:    char line[keyvallength];
  79:    register int c;
  80:    register char * tp;
  81: 
  82:    tp = line;
  83:    while( (c = getc(fp)) != KDELIM ) {
  84:       *tp++ = c;
  85:       if ( c==EOF || c=='\n' || tp>= line+keyvallength-2)
  86:          return(0);
  87:       }
  88:    *tp++=c;     /*append trailing KDELIM*/
  89:    *tp='\0';
  90:    if (isprefix(line, AUTHOR))
  91:        ;
  92:    else if ( isprefix(line,DATE) )
  93:        ;
  94:    else if ( isprefix(line, HEADER) )
  95:        ;
  96:    else if ( isprefix(line, LOCKER) )
  97:        ;
  98:    else if ( isprefix(line, LOG) )
  99:        ;
 100:    else if (isprefix(line, REVISION) )
 101:        ;
 102:    else if (isprefix(line, SOURCE) )
 103:        ;
 104:    else if ( isprefix(line, STATE) )
 105:        ;
 106:    else {
 107:       /* no match; put trailing KDELIM back into input */
 108:       ungetc(c,fp );
 109:       return(0);
 110:    }
 111:    fprintf(stdout,"     $%s\n",line);
 112:    return(1);
 113: }
 114: 
 115: 
 116: isprefix(s,t) /*  return true if t is prefix of s; false otherwise  */
 117: char s[], t[];
 118: {
 119:    int  j, k;
 120: 
 121:    for (j=0, k=0; t[k] != '\0' && s[j] != '\0' && s[j] == t[k]; ++j,++k)
 122:       ;
 123:    if ( t[k] != '\0' )
 124:       return(false);
 125:    if (s[j] == VDELIM)
 126:       return(true);
 127:    return(false);
 128: }

Defined functions

isprefix defined in line 116; used 8 times
main defined in line 39; never used
match defined in line 74; used 1 times
  • in line 64

Defined variables

rcsbaseid defined in line 37; never used
rcsid defined in line 4; never used

Defined macros

fflsbuf defined in line 35; never used
Last modified: 1983-05-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 709
Valid CSS Valid XHTML 1.0 Strict