1cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes/*	$NetBSD: regex2.h,v 1.13 2011/10/09 18:23:00 christos Exp $	*/
24fa7b105644222d9b35347c9d226ca8e011072ebColin Cross
34fa7b105644222d9b35347c9d226ca8e011072ebColin Cross/*-
44fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * Copyright (c) 1992, 1993, 1994
54fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *	The Regents of the University of California.  All rights reserved.
64fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *
74fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * This code is derived from software contributed to Berkeley by
84fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * Henry Spencer.
94fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *
104fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * Redistribution and use in source and binary forms, with or without
114fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * modification, are permitted provided that the following conditions
124fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * are met:
134fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * 1. Redistributions of source code must retain the above copyright
144fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *    notice, this list of conditions and the following disclaimer.
154fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * 2. Redistributions in binary form must reproduce the above copyright
164fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *    notice, this list of conditions and the following disclaimer in the
174fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *    documentation and/or other materials provided with the distribution.
184fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * 3. Neither the name of the University nor the names of its contributors
194fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *    may be used to endorse or promote products derived from this software
204fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *    without specific prior written permission.
214fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *
224fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
234fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
244fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
254fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
264fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
274fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
284fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
294fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
304fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
314fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
324fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * SUCH DAMAGE.
334fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *
344fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *	@(#)regex2.h	8.4 (Berkeley) 3/20/94
354fa7b105644222d9b35347c9d226ca8e011072ebColin Cross */
364fa7b105644222d9b35347c9d226ca8e011072ebColin Cross
37cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes/*-
38cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * Copyright (c) 1992, 1993, 1994 Henry Spencer.
39cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes *
40cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * This code is derived from software contributed to Berkeley by
41cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * Henry Spencer.
42cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes *
43cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * Redistribution and use in source and binary forms, with or without
44cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * modification, are permitted provided that the following conditions
45cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * are met:
46cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 1. Redistributions of source code must retain the above copyright
47cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes *    notice, this list of conditions and the following disclaimer.
48cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 2. Redistributions in binary form must reproduce the above copyright
49cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes *    notice, this list of conditions and the following disclaimer in the
50cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes *    documentation and/or other materials provided with the distribution.
51cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 3. All advertising materials mentioning features or use of this software
52cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes *    must display the following acknowledgement:
53cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes *	This product includes software developed by the University of
54cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes *	California, Berkeley and its contributors.
55cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * 4. Neither the name of the University nor the names of its contributors
56cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes *    may be used to endorse or promote products derived from this software
57cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes *    without specific prior written permission.
58cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes *
59cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
60cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
62cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
63cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * SUCH DAMAGE.
70cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes *
71cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes *	@(#)regex2.h	8.4 (Berkeley) 3/20/94
72cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes */
73cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes
74cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes/*
75cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes * First, the stuff that ends up in the outside-world include file
76cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes = typedef off_t regoff_t;
77cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes = typedef struct {
78cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes = 	int re_magic;
79cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes = 	size_t re_nsub;		// number of parenthesized subexpressions
80cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes = 	const char *re_endp;	// end pointer for REG_PEND
81cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes = 	struct re_guts *re_g;	// none of your business :-)
82cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes = } regex_t;
83cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes = typedef struct {
84cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes = 	regoff_t rm_so;		// start of match
85cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes = 	regoff_t rm_eo;		// end of match
86cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes = } regmatch_t;
87cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes */
884fa7b105644222d9b35347c9d226ca8e011072ebColin Cross/*
894fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * internals of regex_t
904fa7b105644222d9b35347c9d226ca8e011072ebColin Cross */
914fa7b105644222d9b35347c9d226ca8e011072ebColin Cross#define	MAGIC1	((('r'^0200)<<8) | 'e')
924fa7b105644222d9b35347c9d226ca8e011072ebColin Cross
934fa7b105644222d9b35347c9d226ca8e011072ebColin Cross/*
944fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * The internal representation is a *strip*, a sequence of
954fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * operators ending with an endmarker.  (Some terminology etc. is a
964fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * historical relic of earlier versions which used multiple strips.)
974fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * Certain oddities in the representation are there to permit running
984fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * the machinery backwards; in particular, any deviation from sequential
994fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * flow must be marked at both its source and its destination.  Some
1004fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * fine points:
1014fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *
1024fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * - OPLUS_ and O_PLUS are *inside* the loop they create.
1034fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * - OQUEST_ and O_QUEST are *outside* the bypass they create.
1044fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * - OCH_ and O_CH are *outside* the multi-way branch they create, while
1054fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *   OOR1 and OOR2 are respectively the end and the beginning of one of
1064fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *   the branches.  Note that there is an implicit OOR2 following OCH_
1074fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *   and an implicit OOR1 preceding O_CH.
1084fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *
1094fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * In state representations, an operator's bit is on to signify a state
1104fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * immediately *preceding* "execution" of that operator.
1114fa7b105644222d9b35347c9d226ca8e011072ebColin Cross */
112cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughestypedef u_int32_t sop;	/* strip operator */
113cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughestypedef size_t sopno;
114cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OPRMASK	((u_int32_t)0xf8000000UL)
115cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OPDMASK	((u_int32_t)0x07ffffffUL)
1164fa7b105644222d9b35347c9d226ca8e011072ebColin Cross#define	OPSHIFT	((unsigned)27)
1174fa7b105644222d9b35347c9d226ca8e011072ebColin Cross#define	OP(n)	((n)&OPRMASK)
118cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OPND(n)	((int)((n)&OPDMASK))
1194fa7b105644222d9b35347c9d226ca8e011072ebColin Cross#define	SOP(op, opnd)	((op)|(opnd))
120cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes
121cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define OPC(n)	(((u_int32_t)(n))<<OPSHIFT)
122cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes/* operators		   meaning	operand			*/
123cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes/*					(back, fwd are offsets)	*/
124cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OEND	OPC(1)	/* endmarker	-			*/
125cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OCHAR	OPC(2)	/* character	unsigned char		*/
126cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OBOL	OPC(3)	/* left anchor	-			*/
127cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OEOL	OPC(4)	/* right anchor	-			*/
128cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OANY	OPC(5)	/* .		-			*/
129cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OANYOF	OPC(6)	/* [...]	set number		*/
130cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OBACK_	OPC(7)	/* begin \d	paren number		*/
131cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	O_BACK	OPC(8)	/* end \d	paren number		*/
132cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OPLUS_	OPC(9)	/* + prefix	fwd to suffix		*/
133cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	O_PLUS	OPC(10)	/* + suffix	back to prefix		*/
134cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OQUEST_	OPC(11)	/* ? prefix	fwd to suffix		*/
135cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	O_QUEST	OPC(12)	/* ? suffix	back to prefix		*/
136cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OLPAREN	OPC(13)	/* (		fwd to )		*/
137cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	ORPAREN	OPC(14)	/* )		back to (		*/
138cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OCH_	OPC(15)	/* begin choice	fwd to OOR2		*/
139cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OOR1	OPC(16)	/* | pt. 1	back to OOR1 or OCH_	*/
140cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OOR2	OPC(17)	/* | pt. 2	fwd to OOR2 or O_CH	*/
141cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	O_CH	OPC(18)	/* end choice	back to OOR1		*/
142cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OBOW	OPC(19)	/* begin word	-			*/
143cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	OEOW	OPC(20)	/* end word	-			*/
1444fa7b105644222d9b35347c9d226ca8e011072ebColin Cross
1454fa7b105644222d9b35347c9d226ca8e011072ebColin Cross/*
1464fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * Structure for [] character-set representation.  Character sets are
1474fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * done as bit vectors, grouped 8 to a byte vector for compactness.
1484fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * The individual set therefore has both a pointer to the byte vector
1494fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * and a mask to pick out the relevant bit of each byte.  A hash code
1504fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * simplifies testing whether two sets could be identical.
1514fa7b105644222d9b35347c9d226ca8e011072ebColin Cross *
1524fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * This will get trickier for multicharacter collating elements.  As
1534fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * preliminary hooks for dealing with such things, we also carry along
1544fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * a string of multi-character elements, and decide the size of the
1554fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * vectors at run time.
1564fa7b105644222d9b35347c9d226ca8e011072ebColin Cross */
1574fa7b105644222d9b35347c9d226ca8e011072ebColin Crosstypedef struct {
1584fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	uch *ptr;		/* -> uch [csetsize] */
1594fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	uch mask;		/* bit within array */
1604fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	uch hash;		/* hash code */
1614fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	size_t smultis;
1624fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	char *multis;		/* -> char[smulti]  ab\0cd\0ef\0\0 */
1634fa7b105644222d9b35347c9d226ca8e011072ebColin Cross} cset;
1644fa7b105644222d9b35347c9d226ca8e011072ebColin Cross/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */
1654fa7b105644222d9b35347c9d226ca8e011072ebColin Cross#define	CHadd(cs, c)	((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c))
1664fa7b105644222d9b35347c9d226ca8e011072ebColin Cross#define	CHsub(cs, c)	((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c))
1674fa7b105644222d9b35347c9d226ca8e011072ebColin Cross#define	CHIN(cs, c)	((cs)->ptr[(uch)(c)] & (cs)->mask)
1684fa7b105644222d9b35347c9d226ca8e011072ebColin Cross#define	MCadd(p, cs, cp)	mcadd(p, cs, cp)	/* regcomp() internal fns */
1694fa7b105644222d9b35347c9d226ca8e011072ebColin Cross#define	MCsub(p, cs, cp)	mcsub(p, cs, cp)
1704fa7b105644222d9b35347c9d226ca8e011072ebColin Cross#define	MCin(p, cs, cp)	mcin(p, cs, cp)
1714fa7b105644222d9b35347c9d226ca8e011072ebColin Cross
1724fa7b105644222d9b35347c9d226ca8e011072ebColin Cross/* stuff for character categories */
1734fa7b105644222d9b35347c9d226ca8e011072ebColin Crosstypedef unsigned char cat_t;
1744fa7b105644222d9b35347c9d226ca8e011072ebColin Cross
1754fa7b105644222d9b35347c9d226ca8e011072ebColin Cross/*
1764fa7b105644222d9b35347c9d226ca8e011072ebColin Cross * main compiled-expression structure
1774fa7b105644222d9b35347c9d226ca8e011072ebColin Cross */
1784fa7b105644222d9b35347c9d226ca8e011072ebColin Crossstruct re_guts {
1794fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	int magic;
1804fa7b105644222d9b35347c9d226ca8e011072ebColin Cross#		define	MAGIC2	((('R'^0200)<<8)|'E')
1814fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	sop *strip;		/* malloced area for strip */
182cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes	size_t csetsize;	/* number of bits in a cset vector */
183cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes	size_t ncsets;		/* number of csets in use */
1844fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	cset *sets;		/* -> cset [ncsets] */
1854fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	uch *setbits;		/* -> uch[csetsize][ncsets/CHAR_BIT] */
1864fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	int cflags;		/* copy of regcomp() cflags argument */
1874fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	sopno nstates;		/* = number of sops */
1884fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	sopno firststate;	/* the initial OEND (normally 0) */
1894fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	sopno laststate;	/* the final OEND */
1904fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	int iflags;		/* internal flags */
1914fa7b105644222d9b35347c9d226ca8e011072ebColin Cross#		define	USEBOL	01	/* used ^ */
1924fa7b105644222d9b35347c9d226ca8e011072ebColin Cross#		define	USEEOL	02	/* used $ */
1934fa7b105644222d9b35347c9d226ca8e011072ebColin Cross#		define	BAD	04	/* something wrong */
194cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes	size_t nbol;		/* number of ^ used */
195cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes	size_t neol;		/* number of $ used */
196cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes	size_t ncategories;	/* how many character categories */
1974fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	cat_t *categories;	/* ->catspace[-CHAR_MIN] */
1984fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	char *must;		/* match must contain this string */
199cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes	size_t mlen;		/* length of must */
2004fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	size_t nsub;		/* copy of re_nsub */
2014fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	int backrefs;		/* does it use back references? */
2024fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	sopno nplus;		/* how deep does it nest +s? */
2034fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	/* catspace must be last */
2044fa7b105644222d9b35347c9d226ca8e011072ebColin Cross	cat_t catspace[1];	/* actually [NC] */
2054fa7b105644222d9b35347c9d226ca8e011072ebColin Cross};
2064fa7b105644222d9b35347c9d226ca8e011072ebColin Cross
2074fa7b105644222d9b35347c9d226ca8e011072ebColin Cross/* misc utilities */
2084fa7b105644222d9b35347c9d226ca8e011072ebColin Cross#define	OUT	(CHAR_MAX+1)	/* a non-character value */
209cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8Elliott Hughes#define	ISWORD(c)	(isalnum((unsigned char)c) || (c) == '_')
210