home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / RCS_SRC.ZIP / RCSKEYS.C < prev    next >
C/C++ Source or Header  |  1991-01-15  |  3KB  |  98 lines

  1. /*
  2.  *                     RCS keyword table and match operation
  3.  */
  4. #ifndef lint
  5. static char rcsid[]= "$Id: rcskeys.c,v 4.3 89/05/01 15:13:02 narten Exp $ Purdue CS";
  6. #endif
  7.  
  8. /* Copyright (C) 1982, 1988, 1989 Walter Tichy
  9.    Distributed under license by the Free Software Foundation, Inc.
  10.  
  11. This file is part of RCS.
  12.  
  13. RCS is free software; you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation; either version 1, or (at your option)
  16. any later version.
  17.  
  18. RCS is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with RCS; see the file COPYING.  If not, write to
  25. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  
  27. Report problems and direct all questions to:
  28.  
  29.     rcs-bugs@cs.purdue.edu
  30.  
  31. */
  32.  
  33.  
  34.  
  35. /* $Log:    rcskeys.c,v $
  36.  * Revision 4.3  89/05/01  15:13:02  narten
  37.  * changed copyright header to reflect current distribution rules
  38.  * 
  39.  * Revision 4.2  87/10/18  10:36:33  narten
  40.  * Updating version numbers. Changes relative to 1.1 actuallyt
  41.  * relative to 4.1
  42.  * 
  43.  * Revision 1.2  87/09/24  14:00:10  narten
  44.  * Sources now pass through lint (if you ignore printf/sprintf/fprintf 
  45.  * warnings)
  46.  * 
  47.  * Revision 1.1  84/01/23  14:50:32  kcs
  48.  * Initial revision
  49.  * 
  50.  * Revision 4.1  83/05/04  10:06:53  wft
  51.  * Initial revision.
  52.  * 
  53.  */
  54.  
  55.  
  56. #include "rcsbase.h"
  57.  
  58.  
  59.  
  60. struct { char * keyword; enum markers marker;} markertable[] =
  61.         {{AUTHOR,   Author  },
  62.          {DATE,     Date    },
  63.          {HEADER,   Header  },
  64.          {IDH,      Id      },
  65.          {LOCKER,   Locker  },
  66.          {LOG,      Log     },
  67.          {RCSFILE,  RCSfile },
  68.          {REVISION, Revision},
  69.          {SOURCE,   Source  },
  70.          {STATE,    State   },
  71.          {nil,      Nomatch }};
  72.  
  73.  
  74.  
  75. enum markers trymatch(string,onlyvdelim)
  76. char * string;
  77. /* function: Checks whether string starts with a keyword followed
  78.  * by a KDELIM or a VDELIM. If onlyvdelim==true, only a VDELIM
  79.  * may follow the keyword.
  80.  * If successful, returns the appropriate marker, otherwise Nomatch.
  81.  */
  82. {
  83.         register int j;
  84.     register char * p, * s;
  85.         for (j=0; markertable[j].keyword!=nil; j++ ) {
  86.         /* try next keyword */
  87.         p = markertable[j].keyword; s = string;
  88.         while (*p!='\0' && *s!='\0' && *p == *s) {
  89.             p++; s++;
  90.         }
  91.         if (*p != '\0') continue; /* no match */
  92.         if ((*s == VDELIM) || (!onlyvdelim && (*s == KDELIM)))
  93.             return(markertable[j].marker);
  94.         }
  95.         return(Nomatch);
  96. }
  97.  
  98.