home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OS9000 / APPS / rcs.lzh / rcs1 / rcskeys.c < prev    next >
Text File  |  1996-04-20  |  3KB  |  104 lines

  1. /*
  2.  *                     RCS keyword table and match operation
  3.  */
  4. #ifndef lint
  5. static char rcsid[]= "$Id: rcskeys.c_v 1.1 93/04/02 01:35:01 hiro 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 1.1  93/04/02  01:35:01  hiro
  37.  * Initial revision
  38.  * 
  39.  * Revision 1.1  90/07/19  15:21:57  momo
  40.  * Initial revision
  41.  * 
  42.  * Revision 4.3  89/05/01  15:13:02  narten
  43.  * changed copyright header to reflect current distribution rules
  44.  * 
  45.  * Revision 4.2  87/10/18  10:36:33  narten
  46.  * Updating version numbers. Changes relative to 1.1 actuallyt
  47.  * relative to 4.1
  48.  * 
  49.  * Revision 1.2  87/09/24  14:00:10  narten
  50.  * Sources now pass through lint (if you ignore printf/sprintf/fprintf 
  51.  * warnings)
  52.  * 
  53.  * Revision 1.1  84/01/23  14:50:32  kcs
  54.  * Initial revision
  55.  * 
  56.  * Revision 4.1  83/05/04  10:06:53  wft
  57.  * Initial revision.
  58.  * 
  59.  */
  60.  
  61.  
  62. #include "rcsbase.h"
  63.  
  64.  
  65.  
  66. struct { char * keyword; enum markers marker;} markertable[] =
  67.         {{AUTHOR,   Author  },
  68.          {DATE,     Date    },
  69.          {HEADER,   Header  },
  70.          {IDH,      Id      },
  71.          {LOCKER,   Locker  },
  72.          {LOG,      Log     },
  73.          {RCSFILE,  RCSfile },
  74.          {REVISION, Revision},
  75.          {SOURCE,   Source  },
  76.          {STATE,    State   },
  77.          {nil,      Nomatch }};
  78.  
  79.  
  80.  
  81. enum markers trymatch(string,onlyvdelim)
  82. char * string;
  83. /* function: Checks whether string starts with a keyword followed
  84.  * by a KDELIM or a VDELIM. If onlyvdelim==true, only a VDELIM
  85.  * may follow the keyword.
  86.  * If successful, returns the appropriate marker, otherwise Nomatch.
  87.  */
  88. {
  89.         register int j;
  90.     register char * p, * s;
  91.         for (j=0; markertable[j].keyword!=nil; j++ ) {
  92.         /* try next keyword */
  93.         p = markertable[j].keyword; s = string;
  94.         while (*p!='\0' && *s!='\0' && *p == *s) {
  95.             p++; s++;
  96.         }
  97.         if (*p != '\0') continue; /* no match */
  98.         if ((*s == VDELIM) || (!onlyvdelim && (*s == KDELIM)))
  99.             return(markertable[j].marker);
  100.         }
  101.         return(Nomatch);
  102. }
  103.  
  104.