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 ***********************************************************************/
24 * regexp interface and partial implementation
25 * what a novel approach
28 * OBSOLETE: use <regex.h>
38 char* re_braslist
[NBRA
];
39 char* re_braelist
[NBRA
];
49 #define braslist _re_info.re_braslist
50 #define braelist _re_info.re_braelist
51 #define circf _re_info.re_circf
52 #define loc1 _re_info.re_loc1
53 #define loc2 _re_info.re_loc2
54 #define locs _re_info.re_locs
55 #define nbra _re_info.re_nbra
56 #define nodelim _re_info.re_nodelim
57 #define sed _re_info.re_sed
59 #define advance(a,b) _re_exec(&_re_info,a,b,1)
60 #define compile(a,b,c,d) _re_read(&_re_info,a,b,c,d)
61 #define step(a,b) _re_exec(&_re_info,a,b,0)
63 #if _BLD_ast && defined(__EXPORT__)
64 #define extern __EXPORT__
67 extern int _re_comp(regexp_t
*, const char*, char*, unsigned int);
68 extern int _re_exec(regexp_t
*, const char*, const char*, int);
69 extern char* _re_putc(int);
70 extern char* _re_read(regexp_t
*, const char*, char*, const char*, int);
74 #ifndef _REGEXP_DECLARE
79 _re_read(register regexp_t
* re
, const char* instring
, char* ep
, const char* endbuf
, int seof
)
83 static const char* prev
;
90 if ((c
= GETC()) == seof
|| c
== '\n' || c
== -1 || c
== 0)
97 if (!re
->re_sed
&& !prev
)
99 RETURN((char*)endbuf
);
105 if ((c
= GETC()) == seof
|| c
== '\n' || c
== -1 || c
== 0)
116 if ((c
= GETC()) == seof
|| c
== '\n' || c
== -1 || c
== 0)
121 if (c
= _re_comp(re
, _re_putc(0), ep
, (char*)endbuf
- ep
))