28 |
|
#define memcpy(to,from,len) bcopy(from,to,len) |
29 |
|
#endif |
30 |
|
|
31 |
+ |
static int advance(), cclass(); |
32 |
+ |
|
33 |
|
static char expbuf[ESIZE]; |
34 |
|
static int iflag; |
35 |
|
static int circf; |
107 |
|
if ((c = *sp++) == '\0') |
108 |
|
return(-1); |
109 |
|
if (c == '<') { |
110 |
< |
*ep++ = CBRC; |
110 |
> |
if (ep == expbuf || ep[-1] != CBRC) |
111 |
> |
*ep++ = CBRC; |
112 |
|
continue; |
113 |
|
} |
114 |
|
if (c == '>') { |
149 |
|
} |
150 |
|
|
151 |
|
char * |
152 |
< |
eindex(sp) /* find the expression in str */ |
152 |
> |
eindex(sp) /* find the expression in string sp */ |
153 |
|
register char *sp; |
154 |
|
{ |
155 |
< |
if (circf) { |
156 |
< |
if (advance(sp, expbuf)) |
157 |
< |
return(sp); |
155 |
> |
/* check for match at beginning of line, watch CBRC */ |
156 |
> |
if (advance(sp, expbuf[0]==CBRC ? expbuf+1 : expbuf)) |
157 |
> |
return(sp); |
158 |
> |
if (circf) |
159 |
|
return(NULL); |
156 |
– |
} |
160 |
|
/* fast check for first character */ |
161 |
|
if (expbuf[0]==CCHR) { |
162 |
|
register c = expbuf[1]; |
163 |
< |
do { |
163 |
> |
while (*++sp) |
164 |
|
if (same(*sp, c) && advance(sp, expbuf)) |
165 |
|
return(sp); |
163 |
– |
} while (*sp++); |
166 |
|
return(NULL); |
167 |
|
} |
168 |
|
/* regular algorithm */ |
169 |
< |
do { |
169 |
> |
while (*++sp) |
170 |
|
if (advance(sp, expbuf)) |
171 |
|
return(sp); |
170 |
– |
} while (*sp++); |
172 |
|
return(NULL); |
173 |
|
} |
174 |
|
|
246 |
|
return(0); |
247 |
|
|
248 |
|
case CBRC: |
248 |
– |
if (lp == alp) |
249 |
– |
continue; |
249 |
|
if ((isalnum(*lp) || *lp == '_') && !(isalnum(lp[-1]) || lp[-1] == '_')) |
250 |
|
continue; |
251 |
|
return (0); |