1/* RCS keyword table and match operation */ 2 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. 6 7This file is part of RCS. 8 9RCS is free software; you can redistribute it and/or modify 10it under the terms of the GNU General Public License as published by 11the Free Software Foundation; either version 2, or (at your option) 12any later version. 13 14RCS is distributed in the hope that it will be useful, 15but WITHOUT ANY WARRANTY; without even the implied warranty of 16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17GNU General Public License for more details. 18 19You should have received a copy of the GNU General Public License 20along with RCS; see the file COPYING. 21If not, write to the Free Software Foundation, 2259 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 23 24Report problems and direct all questions to: 25 26 rcs-bugs@cs.purdue.edu 27 28*/ 29 30/* 31 * Revision 5.4 1995/06/16 06:19:24 eggert 32 * Update FSF address. 33 * 34 * Revision 5.3 1993/11/03 17:42:27 eggert 35 * Add Name keyword. 36 * 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.) 40 * 41 * Revision 5.1 1991/04/21 11:58:25 eggert 42 * Don't put , just before } in initializer. 43 * 44 * Revision 5.0 1990/08/22 08:12:54 eggert 45 * Add -k. Ansify and Posixate. 46 * 47 * Revision 4.3 89/05/01 15:13:02 narten 48 * changed copyright header to reflect current distribution rules 49 * 50 * Revision 4.2 87/10/18 10:36:33 narten 51 * Updating version numbers. Changes relative to 1.1 actuallyt 52 * relative to 4.1 53 * 54 * Revision 1.2 87/09/24 14:00:10 narten 55 * Sources now pass through lint (if you ignore printf/sprintf/fprintf 56 * warnings) 57 * 58 * Revision 4.1 83/05/04 10:06:53 wft 59 * Initial revision. 60 * 61 */ 62 63 64#include "rcsbase.h" 65
| 1/* RCS keyword table and match operation */ 2 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. 6 7This file is part of RCS. 8 9RCS is free software; you can redistribute it and/or modify 10it under the terms of the GNU General Public License as published by 11the Free Software Foundation; either version 2, or (at your option) 12any later version. 13 14RCS is distributed in the hope that it will be useful, 15but WITHOUT ANY WARRANTY; without even the implied warranty of 16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17GNU General Public License for more details. 18 19You should have received a copy of the GNU General Public License 20along with RCS; see the file COPYING. 21If not, write to the Free Software Foundation, 2259 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 23 24Report problems and direct all questions to: 25 26 rcs-bugs@cs.purdue.edu 27 28*/ 29 30/* 31 * Revision 5.4 1995/06/16 06:19:24 eggert 32 * Update FSF address. 33 * 34 * Revision 5.3 1993/11/03 17:42:27 eggert 35 * Add Name keyword. 36 * 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.) 40 * 41 * Revision 5.1 1991/04/21 11:58:25 eggert 42 * Don't put , just before } in initializer. 43 * 44 * Revision 5.0 1990/08/22 08:12:54 eggert 45 * Add -k. Ansify and Posixate. 46 * 47 * Revision 4.3 89/05/01 15:13:02 narten 48 * changed copyright header to reflect current distribution rules 49 * 50 * Revision 4.2 87/10/18 10:36:33 narten 51 * Updating version numbers. Changes relative to 1.1 actuallyt 52 * relative to 4.1 53 * 54 * Revision 1.2 87/09/24 14:00:10 narten 55 * Sources now pass through lint (if you ignore printf/sprintf/fprintf 56 * warnings) 57 * 58 * Revision 4.1 83/05/04 10:06:53 wft 59 * Initial revision. 60 * 61 */ 62 63 64#include "rcsbase.h" 65
|
66libId(keysId, "$Id$")
| 66libId(keysId, "$Id: rcskeys.c,v 1.10 1997/02/22 15:47:38 peter Exp $")
|
67 68
| 67 68
|
69char const *const Keyword[] = {
| 69char const *Keyword[] = {
|
70 /* This must be in the same order as rcsbase.h's enum markers type. */ 71 0, 72 AUTHOR, DATE, HEADER, IDH,
| 70 /* This must be in the same order as rcsbase.h's enum markers type. */ 71 0, 72 AUTHOR, DATE, HEADER, IDH,
|
73 LOCKER, LOG, NAME, RCSFILE, REVISION, SOURCE, STATE, 74 FREEBSD
| 73 LOCKER, LOG, NAME, RCSFILE, REVISION, SOURCE, STATE, CVSHEADER, 74 NULL
|
75}; 76 77/* Expand all keywords by default */
| 75}; 76 77/* Expand all keywords by default */
|
78
| |
79static int ExpandKeyword[] = { 80 false, 81 true, true, true, true,
| 78static int ExpandKeyword[] = { 79 false, 80 true, true, true, true,
|
82 true, true, true, true, true, true, true, 83 false
| 81 true, true, true, true, true, true, true, true, 82 true
|
84};
| 83};
|
| 84enum markers LocalIdMode = Id;
|
85 86 enum markers 87trymatch(string) 88 char const *string; 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. 92 */ 93{ 94 register int j; 95 register char const *p, *s; 96 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) { 97 if (!ExpandKeyword[j]) 98 continue; 99 /* try next keyword */ 100 p = Keyword[j];
| 85 86 enum markers 87trymatch(string) 88 char const *string; 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. 92 */ 93{ 94 register int j; 95 register char const *p, *s; 96 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) { 97 if (!ExpandKeyword[j]) 98 continue; 99 /* try next keyword */ 100 p = Keyword[j];
|
| 101 if (p == NULL) 102 continue;
|
101 s = string; 102 while (*p++ == *s++) { 103 if (!*p) 104 switch (*s) { 105 case KDELIM: 106 case VDELIM: 107 return (enum markers)j; 108 default: 109 return Nomatch; 110 } 111 } 112 } 113 return(Nomatch); 114} 115
| 103 s = string; 104 while (*p++ == *s++) { 105 if (!*p) 106 switch (*s) { 107 case KDELIM: 108 case VDELIM: 109 return (enum markers)j; 110 default: 111 return Nomatch; 112 } 113 } 114 } 115 return(Nomatch); 116} 117
|
| 118 void
|
116setIncExc(arg)
| 119setIncExc(arg)
|
117 char *arg;
| 120 char const *arg;
|
118/* Sets up the ExpandKeyword table according to command-line flags */ 119{ 120 char *key;
| 121/* Sets up the ExpandKeyword table according to command-line flags */ 122{ 123 char *key;
|
| 124 char *copy, *next;
|
121 int include = 0, j; 122
| 125 int include = 0, j; 126
|
123 arg += 2; 124 switch (*arg++) {
| 127 copy = strdup(arg); 128 next = copy; 129 switch (*next++) {
|
125 case 'e': 126 include = false; 127 break; 128 case 'i': 129 include = true; 130 break; 131 default:
| 130 case 'e': 131 include = false; 132 break; 133 case 'i': 134 include = true; 135 break; 136 default:
|
132 return(false);
| 137 free(copy); 138 return;
|
133 } 134 if (include) 135 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) 136 ExpandKeyword[j] = false;
| 139 } 140 if (include) 141 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) 142 ExpandKeyword[j] = false;
|
137 key = strtok(arg, ",");
| 143 key = strtok(next, ",");
|
138 while (key) {
| 144 while (key) {
|
139 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); )
| 145 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) { 146 if (Keyword[j] == NULL) 147 continue;
|
140 if (!strcmp(key, Keyword[j])) 141 ExpandKeyword[j] = include;
| 148 if (!strcmp(key, Keyword[j])) 149 ExpandKeyword[j] = include;
|
| 150 }
|
142 key = strtok(NULL, ","); 143 }
| 151 key = strtok(NULL, ","); 152 }
|
144 return(true);
| 153 free(copy); 154 return;
|
145}
| 155}
|
| 156 157 void 158setRCSLocalId(string) 159 char const *string; 160/* function: sets local RCS id and RCSLOCALID envariable */ 161{ 162 static char local_id[keylength+1]; 163 char *copy, *next, *key; 164 int j; 165 166 copy = strdup(string); 167 next = copy; 168 key = strtok(next, "="); 169 if (strlen(key) > keylength) 170 error("LocalId is too long"); 171 VOID strcpy(local_id, key); 172 Keyword[LocalId] = local_id; 173 174 /* options? */ 175 while (key = strtok(NULL, ",")) { 176 if (!strcmp(key, Keyword[Id])) 177 LocalIdMode=Id; 178 else if (!strcmp(key, Keyword[Header])) 179 LocalIdMode=Header; 180 else if (!strcmp(key, Keyword[CVSHeader])) 181 LocalIdMode=CVSHeader; 182 else 183 error("Unknown LocalId mode"); 184 } 185 free(copy); 186}
|
| |