Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / sbr / RCS / smatch.c,v
1 head    1.5;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.5
9 date    92.12.15.00.20.22;      author jromine; state Exp;
10 branches;
11 next    1.4;
12
13 1.4
14 date    92.05.19.20.58.04;      author jromine; state Exp;
15 branches;
16 next    1.3;
17
18 1.3
19 date    90.04.05.15.32.17;      author sources; state Exp;
20 branches;
21 next    1.2;
22
23 1.2
24 date    90.04.05.14.49.48;      author sources; state Exp;
25 branches;
26 next    1.1;
27
28 1.1
29 date    90.02.09.09.33.31;      author sources; state Exp;
30 branches;
31 next    ;
32
33
34 desc
35 @@
36
37
38 1.5
39 log
40 @endif sugar
41 @
42 text
43 @/* smatch.c - match a switch */
44 #ifndef lint
45 static char ident[] = "@@(#)$Id: smatch.c,v 1.4 1992/05/19 20:58:04 jromine Exp jromine $";
46 #endif  /* lint */
47
48 #include "../h/mh.h"
49
50 #ifndef abs
51 #define abs(i) (i < 0 ? -i : i)
52 #endif
53
54 smatch(string, swp)
55 register char *string;
56 register struct swit *swp;
57 {
58     register char  *sp,
59                    *tcp;
60     struct swit *tp;
61     int     firstone,
62             stringlen;
63
64     firstone = UNKWNSW;
65
66     if (string == 0)
67         return firstone;
68
69     for (stringlen = strlen (string), tp = swp; tcp = tp -> sw; tp++) {
70         if (stringlen < abs (tp -> minchars))
71             continue;           /* no match */
72         for (sp = string; *sp == *tcp++;) {
73             if (*sp++ == 0)
74                 return (tp - swp);/* exact match */
75         }
76         if (*sp != 0) {
77             if (*sp != ' ')
78                 continue;       /* no match */
79             if (*--tcp == 0)
80                 return (tp - swp);/* exact match */
81         }
82         if (firstone == UNKWNSW)
83             firstone = tp - swp;
84         else
85             firstone = AMBIGSW;
86     }
87
88     return (firstone);
89 }
90 @
91
92
93 1.4
94 log
95 @AIX
96 @
97 text
98 @d3 2
99 a4 2
100 static char ident[] = "@@(#)$Id: smatch.c,v 1.3 1990/04/05 15:32:17 sources Exp jromine $";
101 #endif  lint
102 @
103
104
105 1.3
106 log
107 @add ID
108 @
109 text
110 @d3 1
111 a3 1
112 static char ident[] = "@@(#)$Id:$";
113 d8 1
114 a8 1
115
116 d10 1
117 a10 1
118
119 @
120
121
122 1.2
123 log
124 @add ID
125 @
126 text
127 @d3 1
128 a3 1
129 static char ident[] = "$Id:";
130 @
131
132
133 1.1
134 log
135 @Initial revision
136 @
137 text
138 @d2 3
139 @