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