1995-10-28 21:50:58 +00:00
|
|
|
/* RCS keyword table and match operation */
|
1993-06-18 04:22:21 +00:00
|
|
|
|
1995-10-28 21:50:58 +00:00
|
|
|
/* Copyright 1982, 1988, 1989 Walter Tichy
|
|
|
|
Copyright 1990, 1991, 1992, 1993, 1995 Paul Eggert
|
1993-06-18 04:22:21 +00:00
|
|
|
Distributed under license by the Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
This file is part of RCS.
|
|
|
|
|
|
|
|
RCS is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
RCS is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
1995-10-28 21:50:58 +00:00
|
|
|
along with RCS; see the file COPYING.
|
|
|
|
If not, write to the Free Software Foundation,
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1993-06-18 04:22:21 +00:00
|
|
|
|
|
|
|
Report problems and direct all questions to:
|
|
|
|
|
|
|
|
rcs-bugs@cs.purdue.edu
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
1995-10-28 21:50:58 +00:00
|
|
|
/*
|
|
|
|
* Revision 5.4 1995/06/16 06:19:24 eggert
|
|
|
|
* Update FSF address.
|
1994-05-15 22:15:14 +00:00
|
|
|
*
|
1995-10-28 21:50:58 +00:00
|
|
|
* Revision 5.3 1993/11/03 17:42:27 eggert
|
|
|
|
* Add Name keyword.
|
1994-05-14 07:00:23 +00:00
|
|
|
*
|
1993-06-18 04:22:21 +00:00
|
|
|
* Revision 5.2 1991/08/19 03:13:55 eggert
|
|
|
|
* Say `T const' instead of `const T'; it's less confusing for pointer types.
|
|
|
|
* (This change was made in other source files too.)
|
|
|
|
*
|
|
|
|
* Revision 5.1 1991/04/21 11:58:25 eggert
|
|
|
|
* Don't put , just before } in initializer.
|
|
|
|
*
|
|
|
|
* Revision 5.0 1990/08/22 08:12:54 eggert
|
|
|
|
* Add -k. Ansify and Posixate.
|
|
|
|
*
|
|
|
|
* Revision 4.3 89/05/01 15:13:02 narten
|
|
|
|
* changed copyright header to reflect current distribution rules
|
1995-05-30 05:05:38 +00:00
|
|
|
*
|
1993-06-18 04:22:21 +00:00
|
|
|
* Revision 4.2 87/10/18 10:36:33 narten
|
|
|
|
* Updating version numbers. Changes relative to 1.1 actuallyt
|
|
|
|
* relative to 4.1
|
1995-05-30 05:05:38 +00:00
|
|
|
*
|
1993-06-18 04:22:21 +00:00
|
|
|
* Revision 1.2 87/09/24 14:00:10 narten
|
1995-05-30 05:05:38 +00:00
|
|
|
* Sources now pass through lint (if you ignore printf/sprintf/fprintf
|
1993-06-18 04:22:21 +00:00
|
|
|
* warnings)
|
1995-05-30 05:05:38 +00:00
|
|
|
*
|
1993-06-18 04:22:21 +00:00
|
|
|
* Revision 4.1 83/05/04 10:06:53 wft
|
|
|
|
* Initial revision.
|
1995-05-30 05:05:38 +00:00
|
|
|
*
|
1993-06-18 04:22:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "rcsbase.h"
|
|
|
|
|
1997-05-11 05:33:08 +00:00
|
|
|
libId(keysId, "$Id: rcskeys.c,v 1.10 1997/02/22 15:47:38 peter Exp $")
|
1993-06-18 04:22:21 +00:00
|
|
|
|
|
|
|
|
1997-05-11 05:33:08 +00:00
|
|
|
char const *Keyword[] = {
|
1993-06-18 04:22:21 +00:00
|
|
|
/* This must be in the same order as rcsbase.h's enum markers type. */
|
1995-10-28 21:50:58 +00:00
|
|
|
0,
|
1993-06-18 04:22:21 +00:00
|
|
|
AUTHOR, DATE, HEADER, IDH,
|
1997-05-11 05:33:08 +00:00
|
|
|
LOCKER, LOG, NAME, RCSFILE, REVISION, SOURCE, STATE, CVSHEADER,
|
|
|
|
NULL
|
1993-06-18 04:22:21 +00:00
|
|
|
};
|
|
|
|
|
1995-10-29 19:31:11 +00:00
|
|
|
/* Expand all keywords by default */
|
|
|
|
static int ExpandKeyword[] = {
|
|
|
|
false,
|
|
|
|
true, true, true, true,
|
1997-05-11 05:33:08 +00:00
|
|
|
true, true, true, true, true, true, true, true,
|
|
|
|
true
|
1995-10-29 19:31:11 +00:00
|
|
|
};
|
1997-05-11 05:33:08 +00:00
|
|
|
enum markers LocalIdMode = Id;
|
1993-06-18 04:22:21 +00:00
|
|
|
|
|
|
|
enum markers
|
|
|
|
trymatch(string)
|
|
|
|
char const *string;
|
|
|
|
/* function: Checks whether string starts with a keyword followed
|
|
|
|
* by a KDELIM or a VDELIM.
|
|
|
|
* If successful, returns the appropriate marker, otherwise Nomatch.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
register int j;
|
|
|
|
register char const *p, *s;
|
|
|
|
for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) {
|
1995-10-29 19:31:11 +00:00
|
|
|
if (!ExpandKeyword[j])
|
|
|
|
continue;
|
1993-06-18 04:22:21 +00:00
|
|
|
/* try next keyword */
|
|
|
|
p = Keyword[j];
|
1997-05-11 05:33:08 +00:00
|
|
|
if (p == NULL)
|
|
|
|
continue;
|
1993-06-18 04:22:21 +00:00
|
|
|
s = string;
|
|
|
|
while (*p++ == *s++) {
|
|
|
|
if (!*p)
|
|
|
|
switch (*s) {
|
|
|
|
case KDELIM:
|
|
|
|
case VDELIM:
|
|
|
|
return (enum markers)j;
|
|
|
|
default:
|
|
|
|
return Nomatch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(Nomatch);
|
|
|
|
}
|
|
|
|
|
1997-05-11 05:33:08 +00:00
|
|
|
void
|
1995-10-29 19:31:11 +00:00
|
|
|
setIncExc(arg)
|
1997-05-11 05:33:08 +00:00
|
|
|
char const *arg;
|
1995-10-29 19:31:11 +00:00
|
|
|
/* Sets up the ExpandKeyword table according to command-line flags */
|
|
|
|
{
|
|
|
|
char *key;
|
1997-05-11 05:33:08 +00:00
|
|
|
char *copy, *next;
|
1995-10-29 19:31:11 +00:00
|
|
|
int include = 0, j;
|
|
|
|
|
1997-05-11 05:33:08 +00:00
|
|
|
copy = strdup(arg);
|
|
|
|
next = copy;
|
|
|
|
switch (*next++) {
|
1995-10-29 19:31:11 +00:00
|
|
|
case 'e':
|
|
|
|
include = false;
|
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
include = true;
|
|
|
|
break;
|
|
|
|
default:
|
1997-05-11 05:33:08 +00:00
|
|
|
free(copy);
|
|
|
|
return;
|
1995-10-29 19:31:11 +00:00
|
|
|
}
|
|
|
|
if (include)
|
|
|
|
for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); )
|
|
|
|
ExpandKeyword[j] = false;
|
1997-05-11 05:33:08 +00:00
|
|
|
key = strtok(next, ",");
|
1995-10-29 19:31:11 +00:00
|
|
|
while (key) {
|
1997-05-11 05:33:08 +00:00
|
|
|
for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) {
|
|
|
|
if (Keyword[j] == NULL)
|
|
|
|
continue;
|
1995-10-29 19:31:11 +00:00
|
|
|
if (!strcmp(key, Keyword[j]))
|
|
|
|
ExpandKeyword[j] = include;
|
1997-05-11 05:33:08 +00:00
|
|
|
}
|
1995-10-29 19:31:11 +00:00
|
|
|
key = strtok(NULL, ",");
|
|
|
|
}
|
1997-05-11 05:33:08 +00:00
|
|
|
free(copy);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
setRCSLocalId(string)
|
|
|
|
char const *string;
|
|
|
|
/* function: sets local RCS id and RCSLOCALID envariable */
|
|
|
|
{
|
|
|
|
static char local_id[keylength+1];
|
|
|
|
char *copy, *next, *key;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
copy = strdup(string);
|
|
|
|
next = copy;
|
|
|
|
key = strtok(next, "=");
|
|
|
|
if (strlen(key) > keylength)
|
|
|
|
error("LocalId is too long");
|
|
|
|
VOID strcpy(local_id, key);
|
|
|
|
Keyword[LocalId] = local_id;
|
|
|
|
|
|
|
|
/* options? */
|
|
|
|
while (key = strtok(NULL, ",")) {
|
|
|
|
if (!strcmp(key, Keyword[Id]))
|
|
|
|
LocalIdMode=Id;
|
|
|
|
else if (!strcmp(key, Keyword[Header]))
|
|
|
|
LocalIdMode=Header;
|
|
|
|
else if (!strcmp(key, Keyword[CVSHeader]))
|
|
|
|
LocalIdMode=CVSHeader;
|
|
|
|
else
|
|
|
|
error("Unknown LocalId mode");
|
|
|
|
}
|
|
|
|
free(copy);
|
1995-10-29 19:31:11 +00:00
|
|
|
}
|