1da2e3ebdSchin
2da2e3ebdSchin /* : : generated by proto : : */
3da2e3ebdSchin /***********************************************************************
4da2e3ebdSchin * *
5da2e3ebdSchin * This software is part of the ast package *
6*3e14f97fSRoger A. Faulkner * Copyright (c) 1985-2010 AT&T Intellectual Property *
7da2e3ebdSchin * and is licensed under the *
8da2e3ebdSchin * Common Public License, Version 1.0 *
97c2fbfb3SApril Chin * by AT&T Intellectual Property *
10da2e3ebdSchin * *
11da2e3ebdSchin * A copy of the License is available at *
12da2e3ebdSchin * http://www.opensource.org/licenses/cpl1.0.txt *
13da2e3ebdSchin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
14da2e3ebdSchin * *
15da2e3ebdSchin * Information and Software Systems Research *
16da2e3ebdSchin * AT&T Research *
17da2e3ebdSchin * Florham Park NJ *
18da2e3ebdSchin * *
19da2e3ebdSchin * Glenn Fowler <gsf@research.att.com> *
20da2e3ebdSchin * David Korn <dgk@research.att.com> *
21da2e3ebdSchin * Phong Vo <kpv@research.att.com> *
22da2e3ebdSchin * *
23da2e3ebdSchin ***********************************************************************/
24da2e3ebdSchin
25da2e3ebdSchin /*
26da2e3ebdSchin * regexp interface and partial implementation
27da2e3ebdSchin * what a novel approach
28da2e3ebdSchin * don't do it again
29da2e3ebdSchin *
30da2e3ebdSchin * OBSOLETE: use <regex.h>
31da2e3ebdSchin */
32da2e3ebdSchin
33da2e3ebdSchin #ifndef _REGEXP_H
34da2e3ebdSchin #if !defined(__PROTO__)
35da2e3ebdSchin #include <prototyped.h>
36da2e3ebdSchin #endif
37da2e3ebdSchin #if !defined(__LINKAGE__)
38da2e3ebdSchin #define __LINKAGE__ /* 2004-08-11 transition */
39da2e3ebdSchin #endif
40da2e3ebdSchin
41da2e3ebdSchin #define _REGEXP_H
42da2e3ebdSchin
43da2e3ebdSchin #define NBRA 9
44da2e3ebdSchin
45da2e3ebdSchin typedef struct
46da2e3ebdSchin {
47da2e3ebdSchin char* re_braslist[NBRA];
48da2e3ebdSchin char* re_braelist[NBRA];
49da2e3ebdSchin char* re_loc1;
50da2e3ebdSchin char* re_loc2;
51da2e3ebdSchin char* re_locs;
52da2e3ebdSchin int re_circf;
53da2e3ebdSchin int re_nbra;
54da2e3ebdSchin int re_nodelim;
55da2e3ebdSchin int re_sed;
56da2e3ebdSchin } regexp_t;
57da2e3ebdSchin
58da2e3ebdSchin #define braslist _re_info.re_braslist
59da2e3ebdSchin #define braelist _re_info.re_braelist
60da2e3ebdSchin #define circf _re_info.re_circf
61da2e3ebdSchin #define loc1 _re_info.re_loc1
62da2e3ebdSchin #define loc2 _re_info.re_loc2
63da2e3ebdSchin #define locs _re_info.re_locs
64da2e3ebdSchin #define nbra _re_info.re_nbra
65da2e3ebdSchin #define nodelim _re_info.re_nodelim
66da2e3ebdSchin #define sed _re_info.re_sed
67da2e3ebdSchin
68da2e3ebdSchin #define advance(a,b) _re_exec(&_re_info,a,b,1)
69da2e3ebdSchin #define compile(a,b,c,d) _re_read(&_re_info,a,b,c,d)
70da2e3ebdSchin #define step(a,b) _re_exec(&_re_info,a,b,0)
71da2e3ebdSchin
72da2e3ebdSchin #if _BLD_ast && defined(__EXPORT__)
73da2e3ebdSchin #undef __MANGLE__
74da2e3ebdSchin #define __MANGLE__ __LINKAGE__ __EXPORT__
75da2e3ebdSchin #endif
76da2e3ebdSchin
77da2e3ebdSchin extern __MANGLE__ int _re_comp __PROTO__((regexp_t*, const char*, char*, unsigned int));
78da2e3ebdSchin extern __MANGLE__ int _re_exec __PROTO__((regexp_t*, const char*, const char*, int));
79da2e3ebdSchin extern __MANGLE__ char* _re_putc __PROTO__((int));
80da2e3ebdSchin extern __MANGLE__ char* _re_read __PROTO__((regexp_t*, const char*, char*, const char*, int));
81da2e3ebdSchin
82da2e3ebdSchin #undef __MANGLE__
83da2e3ebdSchin #define __MANGLE__ __LINKAGE__
84da2e3ebdSchin
85da2e3ebdSchin #ifndef _REGEXP_DECLARE
86da2e3ebdSchin
87da2e3ebdSchin regexp_t _re_info;
88da2e3ebdSchin
89da2e3ebdSchin char*
__OTORP__(register regexp_t * re;const char * instring;char * ep;const char * endbuf;int seof;)90da2e3ebdSchin _re_read __PARAM__((register regexp_t* re, const char* instring, char* ep, const char* endbuf, int seof), (re, instring, ep, endbuf, seof)) __OTORP__(register regexp_t* re; const char* instring; char* ep; const char* endbuf; int seof;){
91da2e3ebdSchin register int c;
92da2e3ebdSchin
93da2e3ebdSchin static const char* prev;
94da2e3ebdSchin
95da2e3ebdSchin #ifdef INIT
96da2e3ebdSchin INIT;
97da2e3ebdSchin #endif
98da2e3ebdSchin
99da2e3ebdSchin re->re_nodelim = 0;
100da2e3ebdSchin if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
101da2e3ebdSchin {
102da2e3ebdSchin if (c != seof)
103da2e3ebdSchin {
104da2e3ebdSchin UNGETC(c);
105da2e3ebdSchin re->re_nodelim = 1;
106da2e3ebdSchin }
107da2e3ebdSchin if (!re->re_sed && !prev)
108da2e3ebdSchin { ERROR(41); }
109da2e3ebdSchin RETURN((char*)endbuf);
110da2e3ebdSchin }
111da2e3ebdSchin UNGETC(c);
112da2e3ebdSchin prev = 0;
113da2e3ebdSchin for (;;)
114da2e3ebdSchin {
115da2e3ebdSchin if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
116da2e3ebdSchin {
117da2e3ebdSchin if (re->re_sed)
118da2e3ebdSchin { ERROR(36); }
119da2e3ebdSchin UNGETC(c);
120da2e3ebdSchin re->re_nodelim = 1;
121da2e3ebdSchin break;
122da2e3ebdSchin }
123da2e3ebdSchin if (c == '\\')
124da2e3ebdSchin {
125da2e3ebdSchin _re_putc(c);
126da2e3ebdSchin if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
127da2e3ebdSchin { ERROR(36); }
128da2e3ebdSchin }
129da2e3ebdSchin _re_putc(c);
130da2e3ebdSchin }
131da2e3ebdSchin if (c = _re_comp(re, _re_putc(0), ep, (char*)endbuf - ep))
132da2e3ebdSchin { ERROR(c); }
133da2e3ebdSchin prev = endbuf;
134da2e3ebdSchin RETURN((char*)prev);
135da2e3ebdSchin }
136da2e3ebdSchin
137da2e3ebdSchin #endif
138da2e3ebdSchin
139da2e3ebdSchin #endif
140