|
|
1.1 root 1: /*
2: * RCS keyword table and match operation
3: */
4: #ifndef lint
5: static char rcsid[]= "$Id: rcskeys.c,v 4.3 89/05/01 15:13:02 narten Exp $ Purdue CS";
6: #endif
7:
8: /* Copyright (C) 1982, 1988, 1989 Walter Tichy
9: * All rights reserved.
10: *
11: * Redistribution and use in source and binary forms are permitted
12: * provided that the above copyright notice and this paragraph are
13: * duplicated in all such forms and that any documentation,
14: * advertising materials, and other materials related to such
15: * distribution and use acknowledge that the software was developed
16: * by Walter Tichy.
17: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
18: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
19: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20: *
21: * Report all problems and direct all questions to:
22: * [email protected]
23: *
24:
25:
26:
27:
28:
29:
30:
31: */
32:
33:
34:
35: /* $Log: rcskeys.c,v $
36: * Revision 4.3 89/05/01 15:13:02 narten
37: * changed copyright header to reflect current distribution rules
38: *
39: * Revision 4.2 87/10/18 10:36:33 narten
40: * Updating version numbers. Changes relative to 1.1 actuallyt
41: * relative to 4.1
42: *
43: * Revision 1.2 87/09/24 14:00:10 narten
44: * Sources now pass through lint (if you ignore printf/sprintf/fprintf
45: * warnings)
46: *
47: * Revision 1.1 84/01/23 14:50:32 kcs
48: * Initial revision
49: *
50: * Revision 4.1 83/05/04 10:06:53 wft
51: * Initial revision.
52: *
53: */
54:
55:
56: #include "rcsbase.h"
57:
58:
59:
60: struct { char * keyword; enum markers marker;} markertable[] =
61: {{AUTHOR, Author },
62: {DATE, Date },
63: {HEADER, Header },
64: {IDH, Id },
65: {LOCKER, Locker },
66: {LOG, Log },
67: {RCSFILE, RCSfile },
68: {REVISION, Revision},
69: {SOURCE, Source },
70: {STATE, State },
71: {nil, Nomatch }};
72:
73:
74:
75: enum markers trymatch(string,onlyvdelim)
76: char * string;
77: /* function: Checks whether string starts with a keyword followed
78: * by a KDELIM or a VDELIM. If onlyvdelim==true, only a VDELIM
79: * may follow the keyword.
80: * If successful, returns the appropriate marker, otherwise Nomatch.
81: */
82: {
83: register int j;
84: register char * p, * s;
85: for (j=0; markertable[j].keyword!=nil; j++ ) {
86: /* try next keyword */
87: p = markertable[j].keyword; s = string;
88: while (*p!='\0' && *s!='\0' && *p == *s) {
89: p++; s++;
90: }
91: if (*p != '\0') continue; /* no match */
92: if ((*s == VDELIM) || (!onlyvdelim && (*s == KDELIM)))
93: return(markertable[j].marker);
94: }
95: return(Nomatch);
96: }
97:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.