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
30 * $FreeBSD: src/gnu/usr.bin/rcs/lib/rcskeys.c,v 1.12.2.1 2002/02/08 11:58:35 ru Exp $
31 * $DragonFly: src/gnu/usr.bin/rcs/lib/rcskeys.c,v 1.2 2003/06/17 04:25:47 dillon Exp $
33 * Revision 5.4 1995/06/16 06:19:24 eggert
36 * Revision 5.3 1993/11/03 17:42:27 eggert
39 * Revision 5.2 1991/08/19 03:13:55 eggert
40 * Say `T const' instead of `const T'; it's less confusing for pointer types.
41 * (This change was made in other source files too.)
43 * Revision 5.1 1991/04/21 11:58:25 eggert
44 * Don't put , just before } in initializer.
46 * Revision 5.0 1990/08/22 08:12:54 eggert
47 * Add -k. Ansify and Posixate.
49 * Revision 4.3 89/05/01 15:13:02 narten
50 * changed copyright header to reflect current distribution rules
52 * Revision 4.2 87/10/18 10:36:33 narten
53 * Updating version numbers. Changes relative to 1.1 actuallyt
56 * Revision 1.2 87/09/24 14:00:10 narten
57 * Sources now pass through lint (if you ignore printf/sprintf/fprintf
60 * Revision 4.1 83/05/04 10:06:53 wft
68 libId(keysId
, "$DragonFly: src/gnu/usr.bin/rcs/lib/rcskeys.c,v 1.2 2003/06/17 04:25:47 dillon Exp $")
71 char const *Keyword
[] = {
72 /* This must be in the same order as rcsbase.h's enum markers type. */
74 AUTHOR
, DATE
, HEADER
, IDH
,
75 LOCKER
, LOG
, NAME
, RCSFILE
, REVISION
, SOURCE
, STATE
, CVSHEADER
,
79 /* Expand all keywords by default */
80 static int ExpandKeyword
[] = {
82 true, true, true, true,
83 true, true, true, true, true, true, true, true,
86 enum markers LocalIdMode
= Id
;
91 /* function: Checks whether string starts with a keyword followed
92 * by a KDELIM or a VDELIM.
93 * If successful, returns the appropriate marker, otherwise Nomatch.
97 register char const *p
, *s
;
98 for (j
= sizeof(Keyword
)/sizeof(*Keyword
); (--j
); ) {
99 if (!ExpandKeyword
[j
])
101 /* try next keyword */
106 while (*p
++ == *s
++) {
111 return (enum markers
)j
;
123 /* Sets up the ExpandKeyword table according to command-line flags */
143 for (j
= sizeof(Keyword
)/sizeof(*Keyword
); (--j
); )
144 ExpandKeyword
[j
] = false;
145 key
= strtok(next
, ",");
147 for (j
= sizeof(Keyword
)/sizeof(*Keyword
); (--j
); ) {
148 if (Keyword
[j
] == NULL
)
150 if (!strcmp(key
, Keyword
[j
]))
151 ExpandKeyword
[j
] = include
;
153 key
= strtok(NULL
, ",");
160 setRCSLocalId(string
)
162 /* function: sets local RCS id and RCSLOCALID envariable */
164 static char local_id
[keylength
+1];
165 char *copy
, *next
, *key
;
167 copy
= strdup(string
);
169 key
= strtok(next
, "=");
170 if (strlen(key
) > keylength
)
171 faterror("LocalId is too long");
172 VOID
strcpy(local_id
, key
);
173 Keyword
[LocalId
] = local_id
;
176 while ((key
= strtok(NULL
, ","))) {
177 if (!strcmp(key
, Keyword
[Id
]))
179 else if (!strcmp(key
, Keyword
[Header
]))
181 else if (!strcmp(key
, Keyword
[CVSHeader
]))
182 LocalIdMode
=CVSHeader
;
184 error("Unknown LocalId mode");