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 * $Log: rcskeys.c,v $
| 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 * $Log: rcskeys.c,v $
|
| 32 * Revision 1.6 1995/10/28 21:49:45 peter 33 * First part of import conflict merge from rcs-5.7 import. 34 * 35 * All those $Log$ entries, combined with the whitespace changes are a real 36 * pain. 37 * 38 * I'm committing this now, before it's completely finished to get it compiling 39 * and working again ASAP. Some of the FreeBSD specific features are not working 40 * in this commit yet (mainly rlog stuff and $FreeBSD: head/gnu/usr.bin/rcs/lib/rcskeys.c 11927 1995-10-29 19:31:11Z peter $ support) 41 *
|
32 * Revision 5.4 1995/06/16 06:19:24 eggert 33 * Update FSF address. 34 * 35 * Revision 5.3 1993/11/03 17:42:27 eggert 36 * Add Name keyword. 37 * 38 * Revision 5.2 1991/08/19 03:13:55 eggert 39 * Say `T const' instead of `const T'; it's less confusing for pointer types. 40 * (This change was made in other source files too.) 41 * 42 * Revision 5.1 1991/04/21 11:58:25 eggert 43 * Don't put , just before } in initializer. 44 * 45 * Revision 5.0 1990/08/22 08:12:54 eggert 46 * Add -k. Ansify and Posixate. 47 * 48 * Revision 4.3 89/05/01 15:13:02 narten 49 * changed copyright header to reflect current distribution rules 50 * 51 * Revision 4.2 87/10/18 10:36:33 narten 52 * Updating version numbers. Changes relative to 1.1 actuallyt 53 * relative to 4.1 54 * 55 * Revision 1.2 87/09/24 14:00:10 narten 56 * Sources now pass through lint (if you ignore printf/sprintf/fprintf 57 * warnings) 58 * 59 * Revision 4.1 83/05/04 10:06:53 wft 60 * Initial revision. 61 * 62 */ 63 64 65#include "rcsbase.h" 66
| 42 * Revision 5.4 1995/06/16 06:19:24 eggert 43 * Update FSF address. 44 * 45 * Revision 5.3 1993/11/03 17:42:27 eggert 46 * Add Name keyword. 47 * 48 * Revision 5.2 1991/08/19 03:13:55 eggert 49 * Say `T const' instead of `const T'; it's less confusing for pointer types. 50 * (This change was made in other source files too.) 51 * 52 * Revision 5.1 1991/04/21 11:58:25 eggert 53 * Don't put , just before } in initializer. 54 * 55 * Revision 5.0 1990/08/22 08:12:54 eggert 56 * Add -k. Ansify and Posixate. 57 * 58 * Revision 4.3 89/05/01 15:13:02 narten 59 * changed copyright header to reflect current distribution rules 60 * 61 * Revision 4.2 87/10/18 10:36:33 narten 62 * Updating version numbers. Changes relative to 1.1 actuallyt 63 * relative to 4.1 64 * 65 * Revision 1.2 87/09/24 14:00:10 narten 66 * Sources now pass through lint (if you ignore printf/sprintf/fprintf 67 * warnings) 68 * 69 * Revision 4.1 83/05/04 10:06:53 wft 70 * Initial revision. 71 * 72 */ 73 74 75#include "rcsbase.h" 76
|
67libId(keysId, "$Id: rcskeys.c,v 5.4 1995/06/16 06:19:24 eggert Exp $")
| 77libId(keysId, "$Id: rcskeys.c,v 1.6 1995/10/28 21:49:45 peter Exp $")
|
68 69 70char const *const Keyword[] = { 71 /* This must be in the same order as rcsbase.h's enum markers type. */ 72 0, 73 AUTHOR, DATE, HEADER, IDH,
| 78 79 80char const *const Keyword[] = { 81 /* This must be in the same order as rcsbase.h's enum markers type. */ 82 0, 83 AUTHOR, DATE, HEADER, IDH,
|
74 LOCKER, LOG, NAME, RCSFILE, REVISION, SOURCE, STATE
| 84 LOCKER, LOG, NAME, RCSFILE, REVISION, SOURCE, STATE, 85 FREEBSD
|
75}; 76
| 86}; 87
|
| 88/* Expand all keywords by default */
|
77
| 89
|
| 90static int ExpandKeyword[] = { 91 false, 92 true, true, true, true, 93 true, true, true, true, true, true, true, 94 false 95};
|
78 79 enum markers 80trymatch(string) 81 char const *string; 82/* function: Checks whether string starts with a keyword followed 83 * by a KDELIM or a VDELIM. 84 * If successful, returns the appropriate marker, otherwise Nomatch. 85 */ 86{ 87 register int j; 88 register char const *p, *s; 89 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) {
| 96 97 enum markers 98trymatch(string) 99 char const *string; 100/* function: Checks whether string starts with a keyword followed 101 * by a KDELIM or a VDELIM. 102 * If successful, returns the appropriate marker, otherwise Nomatch. 103 */ 104{ 105 register int j; 106 register char const *p, *s; 107 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) {
|
| 108 if (!ExpandKeyword[j]) 109 continue;
|
90 /* try next keyword */ 91 p = Keyword[j]; 92 s = string; 93 while (*p++ == *s++) { 94 if (!*p) 95 switch (*s) { 96 case KDELIM: 97 case VDELIM: 98 return (enum markers)j; 99 default: 100 return Nomatch; 101 } 102 } 103 } 104 return(Nomatch); 105} 106
| 110 /* try next keyword */ 111 p = Keyword[j]; 112 s = string; 113 while (*p++ == *s++) { 114 if (!*p) 115 switch (*s) { 116 case KDELIM: 117 case VDELIM: 118 return (enum markers)j; 119 default: 120 return Nomatch; 121 } 122 } 123 } 124 return(Nomatch); 125} 126
|
| 127setIncExc(arg) 128 char *arg; 129/* Sets up the ExpandKeyword table according to command-line flags */ 130{ 131 char *key; 132 int include = 0, j; 133 134 arg += 2; 135 switch (*arg++) { 136 case 'e': 137 include = false; 138 break; 139 case 'i': 140 include = true; 141 break; 142 default: 143 return(false); 144 } 145 if (include) 146 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) 147 ExpandKeyword[j] = false; 148 key = strtok(arg, ","); 149 while (key) { 150 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) 151 if (!strcmp(key, Keyword[j])) 152 ExpandKeyword[j] = include; 153 key = strtok(NULL, ","); 154 } 155 return(true); 156}
|
| |