Deleted Added
full compact
rcskeys.c (10) rcskeys.c (1494)
1/*
2 * RCS keyword table and match operation
3 */
4
5/* Copyright (C) 1982, 1988, 1989 Walter Tichy
6 Copyright 1990, 1991 by Paul Eggert
7 Distributed under license by the Free Software Foundation, Inc.
8

--- 17 unchanged lines hidden (view full) ---

26
27 rcs-bugs@cs.purdue.edu
28
29*/
30
31
32
33/* $Log: rcskeys.c,v $
1/*
2 * RCS keyword table and match operation
3 */
4
5/* Copyright (C) 1982, 1988, 1989 Walter Tichy
6 Copyright 1990, 1991 by Paul Eggert
7 Distributed under license by the Free Software Foundation, Inc.
8

--- 17 unchanged lines hidden (view full) ---

26
27 rcs-bugs@cs.purdue.edu
28
29*/
30
31
32
33/* $Log: rcskeys.c,v $
34 * Revision 1.1.1.1 1993/06/18 04:22:12 jkh
35 * Updated GNU utilities
36 *
34 * Revision 5.2 1991/08/19 03:13:55 eggert
35 * Say `T const' instead of `const T'; it's less confusing for pointer types.
36 * (This change was made in other source files too.)
37 *
38 * Revision 5.1 1991/04/21 11:58:25 eggert
39 * Don't put , just before } in initializer.
40 *
41 * Revision 5.0 1990/08/22 08:12:54 eggert

--- 13 unchanged lines hidden (view full) ---

55 * Revision 4.1 83/05/04 10:06:53 wft
56 * Initial revision.
57 *
58 */
59
60
61#include "rcsbase.h"
62
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

--- 13 unchanged lines hidden (view full) ---

58 * Revision 4.1 83/05/04 10:06:53 wft
59 * Initial revision.
60 *
61 */
62
63
64#include "rcsbase.h"
65
63libId(keysId, "$Id: rcskeys.c,v 5.2 1991/08/19 03:13:55 eggert Exp $")
66libId(keysId, "$Id: rcskeys.c,v 1.1.1.1 1993/06/18 04:22:12 jkh Exp $")
64
65
66char const *const Keyword[] = {
67 /* This must be in the same order as rcsbase.h's enum markers type. */
68 nil,
69 AUTHOR, DATE, HEADER, IDH,
67
68
69char const *const Keyword[] = {
70 /* This must be in the same order as rcsbase.h's enum markers type. */
71 nil,
72 AUTHOR, DATE, HEADER, IDH,
70 LOCKER, LOG, RCSFILE, REVISION, SOURCE, STATE
73 LOCKER, LOG, RCSFILE, REVISION, SOURCE, STATE, FREEBSD
71};
72
73
74};
75
76
77/* Expand all keywords by default */
74
78
79static int ExpandKeyword[] = {
80 nil,
81 true, true, true, true,
82 true, true, true, true, true, true, true, true
83};
84
75 enum markers
76trymatch(string)
77 char const *string;
78/* function: Checks whether string starts with a keyword followed
79 * by a KDELIM or a VDELIM.
80 * If successful, returns the appropriate marker, otherwise Nomatch.
81 */
82{
83 register int j;
84 register char const *p, *s;
85 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) {
85 enum markers
86trymatch(string)
87 char const *string;
88/* function: Checks whether string starts with a keyword followed
89 * by a KDELIM or a VDELIM.
90 * If successful, returns the appropriate marker, otherwise Nomatch.
91 */
92{
93 register int j;
94 register char const *p, *s;
95 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) {
96 if (!ExpandKeyword[j])
97 continue;
86 /* try next keyword */
87 p = Keyword[j];
88 s = string;
89 while (*p++ == *s++) {
90 if (!*p)
91 switch (*s) {
92 case KDELIM:
93 case VDELIM:
94 return (enum markers)j;
95 default:
96 return Nomatch;
97 }
98 }
99 }
100 return(Nomatch);
101}
102
98 /* try next keyword */
99 p = Keyword[j];
100 s = string;
101 while (*p++ == *s++) {
102 if (!*p)
103 switch (*s) {
104 case KDELIM:
105 case VDELIM:
106 return (enum markers)j;
107 default:
108 return Nomatch;
109 }
110 }
111 }
112 return(Nomatch);
113}
114
115
116setIncExc(arg)
117 char *arg;
118/* Sets up the ExpandKeyword table according to command-line flags */
119{
120 char *key;
121 int include = 0, j;
122
123 arg += 2;
124 switch (*arg++) {
125 case 'e':
126 include = false;
127 break;
128 case 'i':
129 include = true;
130 break;
131 default:
132 return(false);
133 }
134 if (include)
135 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); )
136 ExpandKeyword[j] = false;
137 key = strtok(arg, ",");
138 while (key) {
139 for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); )
140 if (!strcmp(key, Keyword[j]))
141 ExpandKeyword[j] = include;
142 key = strtok(NULL, ",");
143 }
144 return(true);
145}
146