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 ***********************************************************************/
28 * return RE expression given strmatch() pattern
29 * 0 returned for invalid RE
34 typedef struct Stack_s
44 register char* s
= (char*)as
;
55 c
= 2 * strlen(s
) + 1;
58 if (*s
!= '*' || *(s
+ 1) == '(' || *(s
+ 1) == '-' && *(s
+ 2) == '(')
69 if (!(c
= *s
++) || c
== '{' || c
== '}')
72 if ((*t
++ = c
) == '(' && *s
== '|')
81 if ((c
= *s
++) == '!')
88 if ((c
= *s
++) == ']')
100 if ((c
= *s
++) == ']')
110 for (x
= s
; *x
&& *x
!= '}'; x
++);
111 if (*x
++ && (*x
== '(' || *x
== '-' && *(x
+ 1) == '('))
113 if (p
>= &stack
[elementsof(stack
)])
118 if (p
->min
= *s
== '-')
138 if (*s
== '(' || c
!= '~' && *s
== '-' && *(s
+ 1) == '(')
140 if (p
>= &stack
[elementsof(stack
)])
145 if (*(s
+ 1) == 'E' && *(s
+ 2) == ')')
147 for (s
+= 3; *t
= *s
; t
++, s
++);
158 if (p
->min
= *s
== '-')
183 if (p
>= &stack
[elementsof(stack
)])
196 for (c
= 0; c
< p
->len
; c
++)
208 if (t
== buf
|| *(t
- 1) == '(')
211 if (!*s
|| *s
== ')')