1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
27 * return strmatch() expression given REG_AUGMENTED RE
28 * 0 returned for invalid RE
34 fmtmatch(const char* as
)
36 register char* s
= (char*)as
;
50 c
= 3 * (strlen(s
) + 1);
98 if ((c
= *s
++) == '^')
115 if ((c
= *s
++) == ']')
126 for (y
= t
+ 2, t
--; t
>= x
; t
--)
136 if (p
>= &stack
[elementsof(stack
)])
142 if (*s
== 'K' && *(s
+ 1) == ')')
174 for (y
= ++t
; y
> x
; y
--)
180 for (z
= s
; *z
!= '}'; z
++)
187 for (y
= t
+= n
; y
> x
; y
--)
189 for (x
= *p
; s
< z
; *x
++ = *s
++);
233 if (t
== b
|| n
== '(' || n
== '|')
238 for (z
= s
; *z
!= '}'; z
++)
241 for (; s
<= z
; *t
++ = *s
++);
254 if (t
== b
|| *(t
- 1) == '(')
257 if (!*s
|| *s
== ')')
259 if (p
== stack
&& b
== buf
+ 3)
280 if (!a
&& (*b
!= '*' || *(b
+ 1) == '(' || (*(b
+ 1) == '-' || *(b
+ 1) == '~') && *(b
+ 2) == '('))