xref: /netbsd-src/external/gpl2/rcs/dist/src/rcskeys.c (revision fa28c6faa16e0b00edee7acdcaf4899797043def)
1*fa28c6faSchristos /*	$NetBSD: rcskeys.c,v 1.2 2016/01/14 04:22:39 christos Exp $	*/
27bdc2678Schristos 
37bdc2678Schristos /* RCS keyword table and match operation */
47bdc2678Schristos 
57bdc2678Schristos /* Copyright 1982, 1988, 1989 Walter Tichy
67bdc2678Schristos    Copyright 1990, 1991, 1992, 1993, 1995 Paul Eggert
77bdc2678Schristos    Distributed under license by the Free Software Foundation, Inc.
87bdc2678Schristos 
97bdc2678Schristos This file is part of RCS.
107bdc2678Schristos 
117bdc2678Schristos RCS is free software; you can redistribute it and/or modify
127bdc2678Schristos it under the terms of the GNU General Public License as published by
137bdc2678Schristos the Free Software Foundation; either version 2, or (at your option)
147bdc2678Schristos any later version.
157bdc2678Schristos 
167bdc2678Schristos RCS is distributed in the hope that it will be useful,
177bdc2678Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of
187bdc2678Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
197bdc2678Schristos GNU General Public License for more details.
207bdc2678Schristos 
217bdc2678Schristos You should have received a copy of the GNU General Public License
227bdc2678Schristos along with RCS; see the file COPYING.
237bdc2678Schristos If not, write to the Free Software Foundation,
247bdc2678Schristos 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
257bdc2678Schristos 
267bdc2678Schristos Report problems and direct all questions to:
277bdc2678Schristos 
287bdc2678Schristos     rcs-bugs@cs.purdue.edu
297bdc2678Schristos 
307bdc2678Schristos */
317bdc2678Schristos 
327bdc2678Schristos /*
337bdc2678Schristos  * Log: rcskeys.c,v
347bdc2678Schristos  * Revision 5.4  1995/06/16 06:19:24  eggert
357bdc2678Schristos  * Update FSF address.
367bdc2678Schristos  *
377bdc2678Schristos  * Revision 5.3  1993/11/03 17:42:27  eggert
387bdc2678Schristos  * Add Name keyword.
397bdc2678Schristos  *
407bdc2678Schristos  * Revision 5.2  1991/08/19  03:13:55  eggert
417bdc2678Schristos  * Say `T const' instead of `const T'; it's less confusing for pointer types.
427bdc2678Schristos  * (This change was made in other source files too.)
437bdc2678Schristos  *
447bdc2678Schristos  * Revision 5.1  1991/04/21  11:58:25  eggert
457bdc2678Schristos  * Don't put , just before } in initializer.
467bdc2678Schristos  *
477bdc2678Schristos  * Revision 5.0  1990/08/22  08:12:54  eggert
487bdc2678Schristos  * Add -k.  Ansify and Posixate.
497bdc2678Schristos  *
507bdc2678Schristos  * Revision 4.3  89/05/01  15:13:02  narten
517bdc2678Schristos  * changed copyright header to reflect current distribution rules
527bdc2678Schristos  *
537bdc2678Schristos  * Revision 4.2  87/10/18  10:36:33  narten
547bdc2678Schristos  * Updating version numbers. Changes relative to 1.1 actuallyt
557bdc2678Schristos  * relative to 4.1
567bdc2678Schristos  *
577bdc2678Schristos  * Revision 1.2  87/09/24  14:00:10  narten
587bdc2678Schristos  * Sources now pass through lint (if you ignore printf/sprintf/fprintf
597bdc2678Schristos  * warnings)
607bdc2678Schristos  *
617bdc2678Schristos  * Revision 4.1  83/05/04  10:06:53  wft
627bdc2678Schristos  * Initial revision.
637bdc2678Schristos  *
647bdc2678Schristos  */
657bdc2678Schristos 
667bdc2678Schristos 
677bdc2678Schristos #include "rcsbase.h"
687bdc2678Schristos 
697bdc2678Schristos libId(keysId, "Id: rcskeys.c,v 5.4 1995/06/16 06:19:24 eggert Exp ")
707bdc2678Schristos 
717bdc2678Schristos 
727bdc2678Schristos char const *const Keyword[] = {
737bdc2678Schristos     /* This must be in the same order as rcsbase.h's enum markers type. */
747bdc2678Schristos 	0,
757bdc2678Schristos 	AUTHOR, DATE, HEADER, IDH,
76*fa28c6faSchristos #ifdef LOCALID
77*fa28c6faSchristos 	LOCALID,
78*fa28c6faSchristos #endif
797bdc2678Schristos 	LOCKER, LOG, NAME, RCSFILE, REVISION, SOURCE, STATE
807bdc2678Schristos };
817bdc2678Schristos 
827bdc2678Schristos 
837bdc2678Schristos 
847bdc2678Schristos 	enum markers
trymatch(string)857bdc2678Schristos trymatch(string)
867bdc2678Schristos 	char const *string;
877bdc2678Schristos /* function: Checks whether string starts with a keyword followed
887bdc2678Schristos  * by a KDELIM or a VDELIM.
897bdc2678Schristos  * If successful, returns the appropriate marker, otherwise Nomatch.
907bdc2678Schristos  */
917bdc2678Schristos {
927bdc2678Schristos         register int j;
937bdc2678Schristos 	register char const *p, *s;
947bdc2678Schristos 	for (j = sizeof(Keyword)/sizeof(*Keyword);  (--j);  ) {
957bdc2678Schristos 		/* try next keyword */
967bdc2678Schristos 		p = Keyword[j];
977bdc2678Schristos 		s = string;
987bdc2678Schristos 		while (*p++ == *s++) {
997bdc2678Schristos 			if (!*p)
1007bdc2678Schristos 			    switch (*s) {
1017bdc2678Schristos 				case KDELIM:
1027bdc2678Schristos 				case VDELIM:
1037bdc2678Schristos 				    return (enum markers)j;
1047bdc2678Schristos 				default:
1057bdc2678Schristos 				    return Nomatch;
1067bdc2678Schristos 			    }
1077bdc2678Schristos 		}
1087bdc2678Schristos         }
1097bdc2678Schristos         return(Nomatch);
1107bdc2678Schristos }
1117bdc2678Schristos 
112