1 /* RCS keyword table and match operation */
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.
7 This file is part of RCS.
9 RCS is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
14 RCS is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with RCS; see the file COPYING.
21 If not, write to the Free Software Foundation,
22 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 Report problems and direct all questions to:
26 rcs-bugs@cs.purdue.edu
31 * Revision 5.4 1995/06/16 06:19:24 eggert
34 * Revision 5.3 1993/11/03 17:42:27 eggert
37 * Revision 5.2 1991/08/19 03:13:55 eggert
38 * Say `T const' instead of `const T'; it's less confusing for pointer types.
39 * (This change was made in other source files too.)
41 * Revision 5.1 1991/04/21 11:58:25 eggert
42 * Don't put , just before } in initializer.
44 * Revision 5.0 1990/08/22 08:12:54 eggert
45 * Add -k. Ansify and Posixate.
47 * Revision 4.3 89/05/01 15:13:02 narten
48 * changed copyright header to reflect current distribution rules
50 * Revision 4.2 87/10/18 10:36:33 narten
51 * Updating version numbers. Changes relative to 1.1 actuallyt
54 * Revision 1.2 87/09/24 14:00:10 narten
55 * Sources now pass through lint (if you ignore printf/sprintf/fprintf
58 * Revision 4.1 83/05/04 10:06:53 wft
66 libId(keysId, "$FreeBSD$")
69 char const *Keyword[] = {
70 /* This must be in the same order as rcsbase.h's enum markers type. */
72 AUTHOR, DATE, HEADER, IDH,
73 LOCKER, LOG, NAME, RCSFILE, REVISION, SOURCE, STATE, CVSHEADER,
77 /* Expand all keywords by default */
78 static int ExpandKeyword[] = {
80 true, true, true, true,
81 true, true, true, true, true, true, true, true,
84 enum markers LocalIdMode = Id;
89 /* function: Checks whether string starts with a keyword followed
90 * by a KDELIM or a VDELIM.
91 * If successful, returns the appropriate marker, otherwise Nomatch.
95 register char const *p, *s;
96 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) {
97 if (!ExpandKeyword[j])
99 /* try next keyword */
104 while (*p++ == *s++) {
109 return (enum markers)j;
121 /* Sets up the ExpandKeyword table according to command-line flags */
141 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); )
142 ExpandKeyword[j] = false;
143 key = strtok(next, ",");
145 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) {
146 if (Keyword[j] == NULL)
148 if (!strcmp(key, Keyword[j]))
149 ExpandKeyword[j] = include;
151 key = strtok(NULL, ",");
158 setRCSLocalId(string)
160 /* function: sets local RCS id and RCSLOCALID envariable */
162 static char local_id[keylength+1];
163 char *copy, *next, *key;
166 copy = strdup(string);
168 key = strtok(next, "=");
169 if (strlen(key) > keylength)
170 faterror("LocalId is too long");
171 VOID strcpy(local_id, key);
172 Keyword[LocalId] = local_id;
175 while (key = strtok(NULL, ",")) {
176 if (!strcmp(key, Keyword[Id]))
178 else if (!strcmp(key, Keyword[Header]))
180 else if (!strcmp(key, Keyword[CVSHeader]))
181 LocalIdMode=CVSHeader;
183 error("Unknown LocalId mode");