1/* RCS keyword table and match operation */ 2 3/* Copyright 1982, 1988, 1989 Walter Tichy 4 Copyright 1990, 1991, 1992, 1993, 1995 Paul Eggert 5 Distributed under license by the Free Software Foundation, Inc. 6 7This file is part of RCS. 8 9RCS is free software; you can redistribute it and/or modify 10it under the terms of the GNU General Public License as published by 11the Free Software Foundation; either version 2, or (at your option) 12any later version. 13 14RCS is distributed in the hope that it will be useful, 15but WITHOUT ANY WARRANTY; without even the implied warranty of 16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17GNU General Public License for more details. 18 19You should have received a copy of the GNU General Public License 20along with RCS; see the file COPYING. 21If not, write to the Free Software Foundation, 2259 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 23 24Report problems and direct all questions to: 25 26 rcs-bugs@cs.purdue.edu 27 28*/ 29 30/* 31 * $Log: rcskeys.c,v $ 32 * Revision 1.1 2003/06/11 15:56:10 darkwyrm 33 * Added rcs, gzip, sed, and associated utilities. 34 * 35 * Revision 5.4 1995/06/16 06:19:24 eggert 36 * Update FSF address. 37 * 38 * Revision 5.3 1993/11/03 17:42:27 eggert 39 * Add Name keyword. 40 * 41 * Revision 5.2 1991/08/19 03:13:55 eggert 42 * Say `T const' instead of `const T'; it's less confusing for pointer types. 43 * (This change was made in other source files too.) 44 * 45 * Revision 5.1 1991/04/21 11:58:25 eggert 46 * Don't put , just before } in initializer. 47 * 48 * Revision 5.0 1990/08/22 08:12:54 eggert 49 * Add -k. Ansify and Posixate. 50 * 51 * Revision 4.3 89/05/01 15:13:02 narten 52 * changed copyright header to reflect current distribution rules 53 * 54 * Revision 4.2 87/10/18 10:36:33 narten 55 * Updating version numbers. Changes relative to 1.1 actuallyt 56 * relative to 4.1 57 * 58 * Revision 1.2 87/09/24 14:00:10 narten 59 * Sources now pass through lint (if you ignore printf/sprintf/fprintf 60 * warnings) 61 * 62 * Revision 4.1 83/05/04 10:06:53 wft 63 * Initial revision. 64 * 65 */ 66 67 68#include "rcsbase.h" 69 70libId(keysId, "$Id: rcskeys.c 3476 2003-06-11 15:56:10Z darkwyrm $") 71 72 73char const *const Keyword[] = { 74 /* This must be in the same order as rcsbase.h's enum markers type. */ 75 0, 76 AUTHOR, DATE, HEADER, IDH, 77 LOCKER, LOG, NAME, RCSFILE, REVISION, SOURCE, STATE 78}; 79 80 81 82 enum markers 83trymatch(string) 84 char const *string; 85/* function: Checks whether string starts with a keyword followed 86 * by a KDELIM or a VDELIM. 87 * If successful, returns the appropriate marker, otherwise Nomatch. 88 */ 89{ 90 register int j; 91 register char const *p, *s; 92 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) { 93 /* try next keyword */ 94 p = Keyword[j]; 95 s = string; 96 while (*p++ == *s++) { 97 if (!*p) 98 switch (*s) { 99 case KDELIM: 100 case VDELIM: 101 return (enum markers)j; 102 default: 103 return Nomatch; 104 } 105 } 106 } 107 return(Nomatch); 108} 109 110