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