1130561Sobrien/* $NetBSD: rcskeys.c,v 1.2 2016/01/14 04:22:39 christos Exp $ */ 2218822Sdim 3130561Sobrien/* RCS keyword table and match operation */ 4130561Sobrien 5130561Sobrien/* Copyright 1982, 1988, 1989 Walter Tichy 6130561Sobrien Copyright 1990, 1991, 1992, 1993, 1995 Paul Eggert 7130561Sobrien Distributed under license by the Free Software Foundation, Inc. 8130561Sobrien 9130561SobrienThis file is part of RCS. 10130561Sobrien 11130561SobrienRCS is free software; you can redistribute it and/or modify 12130561Sobrienit under the terms of the GNU General Public License as published by 13130561Sobrienthe Free Software Foundation; either version 2, or (at your option) 14130561Sobrienany later version. 15130561Sobrien 16130561SobrienRCS is distributed in the hope that it will be useful, 17130561Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of 18130561SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19218822SdimGNU General Public License for more details. 20130561Sobrien 21130561SobrienYou should have received a copy of the GNU General Public License 22130561Sobrienalong with RCS; see the file COPYING. 23130561SobrienIf not, write to the Free Software Foundation, 24130561Sobrien59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 25130561Sobrien 26130561SobrienReport problems and direct all questions to: 27130561Sobrien 28130561Sobrien rcs-bugs@cs.purdue.edu 29130561Sobrien 30130561Sobrien*/ 31130561Sobrien 32130561Sobrien/* 33130561Sobrien * Log: rcskeys.c,v 34130561Sobrien * Revision 5.4 1995/06/16 06:19:24 eggert 35130561Sobrien * Update FSF address. 36130561Sobrien * 37130561Sobrien * Revision 5.3 1993/11/03 17:42:27 eggert 38130561Sobrien * Add Name keyword. 39130561Sobrien * 40130561Sobrien * Revision 5.2 1991/08/19 03:13:55 eggert 41130561Sobrien * Say `T const' instead of `const T'; it's less confusing for pointer types. 42130561Sobrien * (This change was made in other source files too.) 43130561Sobrien * 44130561Sobrien * Revision 5.1 1991/04/21 11:58:25 eggert 45218822Sdim * Don't put , just before } in initializer. 46218822Sdim * 47218822Sdim * Revision 5.0 1990/08/22 08:12:54 eggert 48218822Sdim * Add -k. Ansify and Posixate. 49218822Sdim * 50218822Sdim * Revision 4.3 89/05/01 15:13:02 narten 51218822Sdim * changed copyright header to reflect current distribution rules 52218822Sdim * 53218822Sdim * Revision 4.2 87/10/18 10:36:33 narten 54218822Sdim * Updating version numbers. Changes relative to 1.1 actuallyt 55218822Sdim * relative to 4.1 56218822Sdim * 57218822Sdim * Revision 1.2 87/09/24 14:00:10 narten 58218822Sdim * Sources now pass through lint (if you ignore printf/sprintf/fprintf 59218822Sdim * warnings) 60218822Sdim * 61218822Sdim * Revision 4.1 83/05/04 10:06:53 wft 62218822Sdim * Initial revision. 63218822Sdim * 64218822Sdim */ 65218822Sdim 66218822Sdim 67218822Sdim#include "rcsbase.h" 68218822Sdim 69218822SdimlibId(keysId, "Id: rcskeys.c,v 5.4 1995/06/16 06:19:24 eggert Exp ") 70218822Sdim 71218822Sdim 72218822Sdimchar const *const Keyword[] = { 73218822Sdim /* This must be in the same order as rcsbase.h's enum markers type. */ 74218822Sdim 0, 75218822Sdim AUTHOR, DATE, HEADER, IDH, 76218822Sdim#ifdef LOCALID 77218822Sdim LOCALID, 78130561Sobrien#endif 79130561Sobrien LOCKER, LOG, NAME, RCSFILE, REVISION, SOURCE, STATE 80130561Sobrien}; 81130561Sobrien 82130561Sobrien 83130561Sobrien 84130561Sobrien enum markers 85130561Sobrientrymatch(string) 86130561Sobrien char const *string; 87130561Sobrien/* function: Checks whether string starts with a keyword followed 88130561Sobrien * by a KDELIM or a VDELIM. 89130561Sobrien * If successful, returns the appropriate marker, otherwise Nomatch. 90130561Sobrien */ 91130561Sobrien{ 92130561Sobrien register int j; 93130561Sobrien register char const *p, *s; 94130561Sobrien for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) { 95130561Sobrien /* try next keyword */ 96130561Sobrien p = Keyword[j]; 97130561Sobrien s = string; 98130561Sobrien while (*p++ == *s++) { 99130561Sobrien if (!*p) 100130561Sobrien switch (*s) { 101130561Sobrien case KDELIM: 102130561Sobrien case VDELIM: 103130561Sobrien return (enum markers)j; 104130561Sobrien default: 105130561Sobrien return Nomatch; 106130561Sobrien } 107130561Sobrien } 108130561Sobrien } 109130561Sobrien return(Nomatch); 110130561Sobrien} 111130561Sobrien 112130561Sobrien