annotate regexp.h @ 0:1493bea5ac22 0.1

Initial version of the standalone heirloom-ed
author markus schnalke <meillo@marmaro.de>
date Mon, 05 Sep 2011 16:31:35 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1 /*
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
2 * Simple Regular Expression functions. Derived from Unix 7th Edition,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
3 * /usr/src/cmd/expr.y
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
4 *
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
5 * Modified by Gunnar Ritter, Freiburg i. Br., Germany, February 2002.
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
6 *
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
7 * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
8 *
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
9 * Redistribution and use in source and binary forms, with or without
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
10 * modification, are permitted provided that the following conditions
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
11 * are met:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
12 * Redistributions of source code and documentation must retain the
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
13 * above copyright notice, this list of conditions and the following
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
14 * disclaimer.
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
15 * Redistributions in binary form must reproduce the above copyright
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
16 * notice, this list of conditions and the following disclaimer in the
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
17 * documentation and/or other materials provided with the distribution.
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
18 * All advertising materials mentioning features or use of this software
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
19 * must display the following acknowledgement:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
20 * This product includes software developed or owned by Caldera
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
21 * International, Inc.
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
22 * Neither the name of Caldera International, Inc. nor the names of
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
23 * other contributors may be used to endorse or promote products
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
24 * derived from this software without specific prior written permission.
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
25 *
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
26 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
27 * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
28 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
29 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
30 * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
31 * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
34 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
35 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
36 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
37 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
38 */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
39
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
40 #if __GNUC__ >= 3 && __GNUC_MINOR__ >= 4 || __GNUC__ >= 4
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
41 #define REGEXP_H_USED __attribute__ ((used))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
42 #elif defined __GNUC__
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
43 #define REGEXP_H_USED __attribute__ ((unused))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
44 #else
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
45 #define REGEXP_H_USED
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
46 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
47 static const char regexp_h_sccsid[] REGEXP_H_USED =
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
48 "@(#)regexp.sl 1.56 (gritter) 5/29/05";
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
49
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
50 #if !defined (REGEXP_H_USED_FROM_VI) && !defined (__dietlibc__)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
51 #define REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
52 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
53
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
54 #define CBRA 2
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
55 #define CCHR 4
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
56 #define CDOT 8
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
57 #define CCL 12
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
58 /* CLNUM 14 used in sed */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
59 /* CEND 16 used in sed */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
60 #define CDOL 20
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
61 #define CCEOF 22
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
62 #define CKET 24
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
63 #define CBACK 36
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
64 #define CNCL 40
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
65 #define CBRC 44
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
66 #define CLET 48
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
67 #define CCH1 52
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
68 #define CCH2 56
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
69 #define CCH3 60
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
70
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
71 #define STAR 01
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
72 #define RNGE 03
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
73 #define REGEXP_H_LEAST 0100
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
74
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
75 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
76 #define CMB 0200
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
77 #else /* !REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
78 #define CMB 0
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
79 #endif /* !REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
80
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
81 #define NBRA 9
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
82
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
83 #define PLACE(c) ep[c >> 3] |= bittab[c & 07]
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
84 #define ISTHERE(c) (ep[c >> 3] & bittab[c & 07])
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
85
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
86 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
87 #define REGEXP_H_IS_THERE(ep, c) ((ep)[c >> 3] & bittab[c & 07])
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
88 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
89
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
90 #include <ctype.h>
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
91 #include <string.h>
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
92 #include <limits.h>
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
93 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
94 #include <stdlib.h>
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
95 #include <wchar.h>
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
96 #include <wctype.h>
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
97 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
98
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
99 #define regexp_h_uletter(c) (isalpha(c) || (c) == '_')
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
100 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
101 #define regexp_h_wuletter(c) (iswalpha(c) || (c) == L'_')
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
102
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
103 /*
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
104 * Used to allocate memory for the multibyte star algorithm.
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
105 */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
106 #ifndef regexp_h_malloc
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
107 #define regexp_h_malloc(n) malloc(n)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
108 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
109 #ifndef regexp_h_free
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
110 #define regexp_h_free(p) free(p)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
111 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
112
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
113 /*
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
114 * Can be predefined to 'inline' to inline some multibyte functions;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
115 * may improve performance for files that contain many multibyte
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
116 * sequences.
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
117 */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
118 #ifndef regexp_h_inline
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
119 #define regexp_h_inline
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
120 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
121
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
122 /*
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
123 * Mask to determine whether the first byte of a sequence possibly
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
124 * starts a multibyte character. Set to 0377 to force mbtowc() for
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
125 * any byte sequence (except 0).
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
126 */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
127 #ifndef REGEXP_H_MASK
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
128 #define REGEXP_H_MASK 0200
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
129 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
130 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
131
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
132 /*
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
133 * For regexpr.h.
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
134 */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
135 #ifndef regexp_h_static
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
136 #define regexp_h_static
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
137 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
138 #ifndef REGEXP_H_STEP_INIT
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
139 #define REGEXP_H_STEP_INIT
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
140 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
141 #ifndef REGEXP_H_ADVANCE_INIT
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
142 #define REGEXP_H_ADVANCE_INIT
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
143 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
144
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
145 char *braslist[NBRA];
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
146 char *braelist[NBRA];
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
147 int nbra;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
148 char *loc1, *loc2, *locs;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
149 int sed;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
150 int nodelim;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
151
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
152 regexp_h_static int circf;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
153 regexp_h_static int low;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
154 regexp_h_static int size;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
155
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
156 regexp_h_static unsigned char bittab[] = {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
157 1,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
158 2,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
159 4,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
160 8,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
161 16,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
162 32,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
163 64,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
164 128
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
165 };
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
166 static int regexp_h_advance(register const char *lp,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
167 register const char *ep);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
168 static void regexp_h_getrnge(register const char *str, int least);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
169
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
170 static const char *regexp_h_bol; /* beginning of input line (for \<) */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
171
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
172 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
173 static int regexp_h_wchars;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
174 static int regexp_h_mbcurmax;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
175
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
176 static const char *regexp_h_firstwc; /* location of first
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
177 multibyte character
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
178 on input line */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
179
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
180 #define regexp_h_getwc(c) { \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
181 if (regexp_h_wchars) { \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
182 char mbbuf[MB_LEN_MAX + 1], *mbptr; \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
183 wchar_t wcbuf; \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
184 int mb, len; \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
185 mbptr = mbbuf; \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
186 do { \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
187 mb = GETC(); \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
188 *mbptr++ = mb; \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
189 *mbptr = '\0'; \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
190 } while ((len = mbtowc(&wcbuf, mbbuf, regexp_h_mbcurmax)) < 0 \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
191 && mb != eof && mbptr < mbbuf + MB_LEN_MAX); \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
192 if (len == -1) \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
193 ERROR(67); \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
194 c = wcbuf; \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
195 } else { \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
196 c = GETC(); \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
197 } \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
198 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
199
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
200 #define regexp_h_store(wc, mb, me) { \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
201 int len; \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
202 if (wc == WEOF) \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
203 ERROR(67); \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
204 if ((len = me - mb) <= regexp_h_mbcurmax) { \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
205 char mt[MB_LEN_MAX]; \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
206 if (wctomb(mt, wc) >= len) \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
207 ERROR(50); \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
208 } \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
209 switch (len = wctomb(mb, wc)) { \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
210 case -1: \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
211 ERROR(67); \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
212 case 0: \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
213 mb++; \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
214 break; \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
215 default: \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
216 mb += len; \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
217 } \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
218 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
219
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
220 static regexp_h_inline wint_t
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
221 regexp_h_fetchwc(const char **mb, int islp)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
222 {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
223 wchar_t wc;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
224 int len;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
225
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
226 if ((len = mbtowc(&wc, *mb, regexp_h_mbcurmax)) < 0) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
227 (*mb)++;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
228 return WEOF;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
229 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
230 if (islp && regexp_h_firstwc == NULL)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
231 regexp_h_firstwc = *mb;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
232 /*if (len == 0) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
233 (*mb)++;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
234 return L'\0';
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
235 } handled in singlebyte code */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
236 *mb += len;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
237 return wc;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
238 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
239
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
240 #define regexp_h_fetch(mb, islp) ((*(mb) & REGEXP_H_MASK) == 0 ? \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
241 (*(mb)++&0377): \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
242 regexp_h_fetchwc(&(mb), islp))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
243
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
244 static regexp_h_inline wint_t
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
245 regexp_h_showwc(const char *mb)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
246 {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
247 wchar_t wc;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
248
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
249 if (mbtowc(&wc, mb, regexp_h_mbcurmax) < 0)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
250 return WEOF;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
251 return wc;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
252 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
253
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
254 #define regexp_h_show(mb) ((*(mb) & REGEXP_H_MASK) == 0 ? (*(mb)&0377): \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
255 regexp_h_showwc(mb))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
256
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
257 /*
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
258 * Return the character immediately preceding mb. Since no byte is
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
259 * required to be the first byte of a character, the longest multibyte
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
260 * character ending at &[mb-1] is searched.
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
261 */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
262 static regexp_h_inline wint_t
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
263 regexp_h_previous(const char *mb)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
264 {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
265 const char *p = mb;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
266 wchar_t wc, lastwc = WEOF;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
267 int len, max = 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
268
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
269 if (regexp_h_firstwc == NULL || mb <= regexp_h_firstwc)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
270 return (mb > regexp_h_bol ? (mb[-1] & 0377) : WEOF);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
271 while (p-- > regexp_h_bol) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
272 mbtowc(NULL, NULL, 0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
273 if ((len = mbtowc(&wc, p, mb - p)) >= 0) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
274 if (len < max || len < mb - p)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
275 break;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
276 max = len;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
277 lastwc = wc;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
278 } else if (len < 0 && max > 0)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
279 break;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
280 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
281 return lastwc;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
282 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
283
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
284 #define regexp_h_cclass(set, c, af) \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
285 ((c) == 0 || (c) == WEOF ? 0 : ( \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
286 ((c) > 0177) ? \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
287 regexp_h_cclass_wc(set, c, af) : ( \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
288 REGEXP_H_IS_THERE((set)+1, (c)) ? (af) : !(af) \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
289 ) \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
290 ) \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
291 )
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
292
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
293 static regexp_h_inline int
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
294 regexp_h_cclass_wc(const char *set, register wint_t c, int af)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
295 {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
296 register wint_t wc, wl = WEOF;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
297 const char *end;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
298
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
299 end = &set[18] + set[0] - 1;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
300 set += 17;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
301 while (set < end) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
302 wc = regexp_h_fetch(set, 0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
303 #ifdef REGEXP_H_VI_BACKSLASH
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
304 if (wc == '\\' && set < end &&
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
305 (*set == ']' || *set == '-' ||
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
306 *set == '^' || *set == '\\')) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
307 wc = regexp_h_fetch(set, 0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
308 } else
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
309 #endif /* REGEXP_H_VI_BACKSLASH */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
310 if (wc == '-' && wl != WEOF && set < end) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
311 wc = regexp_h_fetch(set, 0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
312 #ifdef REGEXP_H_VI_BACKSLASH
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
313 if (wc == '\\' && set < end &&
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
314 (*set == ']' || *set == '-' ||
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
315 *set == '^' || *set == '\\')) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
316 wc = regexp_h_fetch(set, 0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
317 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
318 #endif /* REGEXP_H_VI_BACKSLASH */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
319 if (c > wl && c < wc)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
320 return af;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
321 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
322 if (c == wc)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
323 return af;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
324 wl = wc;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
325 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
326 return !af;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
327 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
328 #else /* !REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
329 #define regexp_h_wchars 0
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
330 #define regexp_h_getwc(c) { c = GETC(); }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
331 #endif /* !REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
332
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
333 regexp_h_static char *
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
334 compile(char *instring, char *ep, const char *endbuf, int seof)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
335 {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
336 INIT /* Dependent declarations and initializations */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
337 register int c;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
338 register int eof = seof;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
339 char *lastep = instring;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
340 int cclcnt;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
341 char bracket[NBRA], *bracketp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
342 int closed;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
343 char neg;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
344 int lc;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
345 int i, cflg;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
346
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
347 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
348 char *eq;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
349 regexp_h_mbcurmax = MB_CUR_MAX;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
350 regexp_h_wchars = regexp_h_mbcurmax > 1 ? CMB : 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
351 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
352 lastep = 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
353 bracketp = bracket;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
354 if((c = GETC()) == eof || c == '\n') {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
355 if (c == '\n') {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
356 UNGETC(c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
357 nodelim = 1;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
358 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
359 if(*ep == 0 && !sed)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
360 ERROR(41);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
361 if (bracketp > bracket)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
362 ERROR(42);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
363 RETURN(ep);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
364 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
365 circf = closed = nbra = 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
366 if (c == '^')
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
367 circf++;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
368 else
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
369 UNGETC(c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
370 for (;;) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
371 if (ep >= endbuf)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
372 ERROR(50);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
373 regexp_h_getwc(c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
374 if(c != '*' && ((c != '\\') || (PEEKC() != '{')))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
375 lastep = ep;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
376 if (c == eof) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
377 *ep++ = CCEOF;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
378 if (bracketp > bracket)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
379 ERROR(42);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
380 RETURN(ep);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
381 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
382 switch (c) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
383
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
384 case '.':
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
385 *ep++ = CDOT|regexp_h_wchars;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
386 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
387
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
388 case '\n':
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
389 if (sed == 0) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
390 UNGETC(c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
391 *ep++ = CCEOF;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
392 nodelim = 1;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
393 RETURN(ep);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
394 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
395 ERROR(36);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
396 case '*':
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
397 if (lastep==0 || *lastep==CBRA || *lastep==CKET ||
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
398 *lastep==(CBRC|regexp_h_wchars) ||
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
399 *lastep==(CLET|regexp_h_wchars))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
400 goto defchar;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
401 *lastep |= STAR;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
402 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
403
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
404 case '$':
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
405 if(PEEKC() != eof)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
406 goto defchar;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
407 *ep++ = CDOL;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
408 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
409
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
410 case '[':
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
411 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
412 if (regexp_h_wchars == 0) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
413 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
414 if(&ep[33] >= endbuf)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
415 ERROR(50);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
416
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
417 *ep++ = CCL;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
418 lc = 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
419 for(i = 0; i < 32; i++)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
420 ep[i] = 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
421
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
422 neg = 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
423 if((c = GETC()) == '^') {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
424 neg = 1;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
425 c = GETC();
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
426 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
427
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
428 do {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
429 c &= 0377;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
430 if(c == '\0' || c == '\n')
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
431 ERROR(49);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
432 #ifdef REGEXP_H_VI_BACKSLASH
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
433 if(c == '\\' && ((c = PEEKC()) == ']' ||
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
434 c == '-' || c == '^' ||
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
435 c == '\\')) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
436 c = GETC();
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
437 c &= 0377;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
438 } else
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
439 #endif /* REGEXP_H_VI_BACKSLASH */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
440 if(c == '-' && lc != 0) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
441 if ((c = GETC()) == ']') {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
442 PLACE('-');
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
443 break;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
444 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
445 #ifdef REGEXP_H_VI_BACKSLASH
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
446 if(c == '\\' &&
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
447 ((c = PEEKC()) == ']' ||
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
448 c == '-' ||
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
449 c == '^' ||
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
450 c == '\\'))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
451 c = GETC();
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
452 #endif /* REGEXP_H_VI_BACKSLASH */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
453 c &= 0377;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
454 while(lc < c) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
455 PLACE(lc);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
456 lc++;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
457 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
458 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
459 lc = c;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
460 PLACE(c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
461 } while((c = GETC()) != ']');
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
462 if(neg) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
463 for(cclcnt = 0; cclcnt < 32; cclcnt++)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
464 ep[cclcnt] ^= 0377;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
465 ep[0] &= 0376;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
466 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
467
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
468 ep += 32;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
469 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
470 } else {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
471 if (&ep[18] >= endbuf)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
472 ERROR(50);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
473 *ep++ = CCL|CMB;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
474 *ep++ = 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
475 lc = 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
476 for (i = 0; i < 16; i++)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
477 ep[i] = 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
478 eq = &ep[16];
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
479 regexp_h_getwc(c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
480 if (c == L'^') {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
481 regexp_h_getwc(c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
482 ep[-2] = CNCL|CMB;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
483 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
484 do {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
485 if (c == '\0' || c == '\n')
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
486 ERROR(49);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
487 #ifdef REGEXP_H_VI_BACKSLASH
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
488 if(c == '\\' && ((c = PEEKC()) == ']' ||
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
489 c == '-' || c == '^' ||
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
490 c == '\\')) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
491 regexp_h_store(c, eq, endbuf);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
492 regexp_h_getwc(c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
493 } else
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
494 #endif /* REGEXP_H_VI_BACKSLASH */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
495 if (c == '-' && lc != 0 && lc <= 0177) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
496 regexp_h_store(c, eq, endbuf);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
497 regexp_h_getwc(c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
498 if (c == ']') {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
499 PLACE('-');
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
500 break;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
501 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
502 #ifdef REGEXP_H_VI_BACKSLASH
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
503 if(c == '\\' &&
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
504 ((c = PEEKC()) == ']' ||
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
505 c == '-' ||
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
506 c == '^' ||
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
507 c == '\\')) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
508 regexp_h_store(c, eq,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
509 endbuf);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
510 regexp_h_getwc(c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
511 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
512 #endif /* REGEXP_H_VI_BACKSLASH */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
513 while (lc < (c & 0177)) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
514 PLACE(lc);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
515 lc++;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
516 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
517 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
518 lc = c;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
519 if (c <= 0177)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
520 PLACE(c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
521 regexp_h_store(c, eq, endbuf);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
522 regexp_h_getwc(c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
523 } while (c != L']');
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
524 if ((i = eq - &ep[16]) > 255)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
525 ERROR(50);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
526 lastep[1] = i;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
527 ep = eq;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
528 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
529 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
530
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
531 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
532
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
533 case '\\':
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
534 regexp_h_getwc(c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
535 switch(c) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
536
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
537 case '(':
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
538 if(nbra >= NBRA)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
539 ERROR(43);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
540 *bracketp++ = nbra;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
541 *ep++ = CBRA;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
542 *ep++ = nbra++;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
543 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
544
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
545 case ')':
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
546 if(bracketp <= bracket)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
547 ERROR(42);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
548 *ep++ = CKET;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
549 *ep++ = *--bracketp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
550 closed++;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
551 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
552
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
553 case '<':
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
554 *ep++ = CBRC|regexp_h_wchars;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
555 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
556
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
557 case '>':
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
558 *ep++ = CLET|regexp_h_wchars;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
559 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
560
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
561 case '{':
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
562 if(lastep == (char *) (0))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
563 goto defchar;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
564 *lastep |= RNGE;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
565 cflg = 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
566 nlim:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
567 c = GETC();
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
568 i = 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
569 do {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
570 if ('0' <= c && c <= '9')
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
571 i = 10 * i + c - '0';
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
572 else
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
573 ERROR(16);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
574 } while(((c = GETC()) != '\\') && (c != ','));
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
575 if (i > 255)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
576 ERROR(11);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
577 *ep++ = i;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
578 if (c == ',') {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
579 if(cflg++)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
580 ERROR(44);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
581 if((c = GETC()) == '\\') {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
582 *ep++ = (char)255;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
583 *lastep |= REGEXP_H_LEAST;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
584 } else {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
585 UNGETC(c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
586 goto nlim; /* get 2'nd number */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
587 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
588 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
589 if(GETC() != '}')
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
590 ERROR(45);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
591 if(!cflg) /* one number */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
592 *ep++ = i;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
593 else if((ep[-1] & 0377) < (ep[-2] & 0377))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
594 ERROR(46);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
595 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
596
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
597 case '\n':
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
598 ERROR(36);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
599
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
600 case 'n':
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
601 c = '\n';
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
602 goto defchar;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
603
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
604 default:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
605 if(c >= '1' && c <= '9') {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
606 if((c -= '1') >= closed)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
607 ERROR(25);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
608 *ep++ = CBACK;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
609 *ep++ = c;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
610 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
611 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
612 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
613 /* Drop through to default to use \ to turn off special chars */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
614
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
615 defchar:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
616 default:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
617 lastep = ep;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
618 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
619 if (regexp_h_wchars == 0) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
620 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
621 *ep++ = CCHR;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
622 *ep++ = c;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
623 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
624 } else {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
625 char mbbuf[MB_LEN_MAX];
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
626
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
627 switch (wctomb(mbbuf, c)) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
628 case 1: *ep++ = CCH1;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
629 break;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
630 case 2: *ep++ = CCH2;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
631 break;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
632 case 3: *ep++ = CCH3;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
633 break;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
634 default:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
635 *ep++ = CCHR|CMB;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
636 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
637 regexp_h_store(c, ep, endbuf);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
638 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
639 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
640 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
641 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
642 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
643
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
644 int
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
645 step(const char *p1, const char *p2)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
646 {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
647 register int c;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
648 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
649 register int d;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
650 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
651
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
652 REGEXP_H_STEP_INIT /* get circf */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
653 regexp_h_bol = p1;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
654 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
655 regexp_h_firstwc = NULL;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
656 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
657 if (circf) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
658 loc1 = (char *)p1;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
659 return(regexp_h_advance(p1, p2));
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
660 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
661 /* fast check for first character */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
662 if (*p2==CCHR) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
663 c = p2[1] & 0377;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
664 do {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
665 if ((*p1 & 0377) != c)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
666 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
667 if (regexp_h_advance(p1, p2)) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
668 loc1 = (char *)p1;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
669 return(1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
670 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
671 } while (*p1++);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
672 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
673 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
674 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
675 else if (*p2==CCH1) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
676 do {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
677 if (p1[0] == p2[1] && regexp_h_advance(p1, p2)) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
678 loc1 = (char *)p1;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
679 return(1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
680 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
681 c = regexp_h_fetch(p1, 1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
682 } while (c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
683 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
684 } else if (*p2==CCH2) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
685 do {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
686 if (p1[0] == p2[1] && p1[1] == p2[2] &&
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
687 regexp_h_advance(p1, p2)) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
688 loc1 = (char *)p1;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
689 return(1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
690 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
691 c = regexp_h_fetch(p1, 1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
692 } while (c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
693 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
694 } else if (*p2==CCH3) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
695 do {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
696 if (p1[0] == p2[1] && p1[1] == p2[2] && p1[2] == p2[3]&&
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
697 regexp_h_advance(p1, p2)) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
698 loc1 = (char *)p1;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
699 return(1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
700 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
701 c = regexp_h_fetch(p1, 1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
702 } while (c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
703 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
704 } else if ((*p2&0377)==(CCHR|CMB)) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
705 d = regexp_h_fetch(p2, 0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
706 do {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
707 c = regexp_h_fetch(p1, 1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
708 if (c == d && regexp_h_advance(p1, p2)) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
709 loc1 = (char *)p1;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
710 return(1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
711 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
712 } while(c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
713 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
714 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
715 /* regular algorithm */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
716 if (regexp_h_wchars)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
717 do {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
718 if (regexp_h_advance(p1, p2)) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
719 loc1 = (char *)p1;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
720 return(1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
721 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
722 c = regexp_h_fetch(p1, 1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
723 } while (c);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
724 else
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
725 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
726 do {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
727 if (regexp_h_advance(p1, p2)) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
728 loc1 = (char *)p1;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
729 return(1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
730 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
731 } while (*p1++);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
732 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
733 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
734
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
735 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
736 /*
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
737 * It is painfully slow to read character-wise backwards in a
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
738 * multibyte string (see regexp_h_previous() above). For the star
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
739 * algorithm, we therefore keep track of every character as it is
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
740 * read in forward direction.
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
741 *
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
742 * Don't use alloca() for stack blocks since there is no measurable
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
743 * speedup and huge amounts of memory are used up for long input
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
744 * lines.
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
745 */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
746 #ifndef REGEXP_H_STAKBLOK
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
747 #define REGEXP_H_STAKBLOK 1000
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
748 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
749
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
750 struct regexp_h_stack {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
751 struct regexp_h_stack *s_nxt;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
752 struct regexp_h_stack *s_prv;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
753 const char *s_ptr[REGEXP_H_STAKBLOK];
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
754 };
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
755
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
756 #define regexp_h_push(sb, sp, sc, lp) (regexp_h_wchars ? \
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
757 regexp_h_pushwc(sb, sp, sc, lp) : (void)0)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
758
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
759 static regexp_h_inline void
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
760 regexp_h_pushwc(struct regexp_h_stack **sb,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
761 struct regexp_h_stack **sp,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
762 const char ***sc, const char *lp)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
763 {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
764 if (regexp_h_firstwc == NULL || lp < regexp_h_firstwc)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
765 return;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
766 if (*sb == NULL) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
767 if ((*sb = regexp_h_malloc(sizeof **sb)) == NULL)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
768 return;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
769 (*sb)->s_nxt = (*sb)->s_prv = NULL;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
770 *sp = *sb;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
771 *sc = &(*sb)->s_ptr[0];
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
772 } else if (*sc >= &(*sp)->s_ptr[REGEXP_H_STAKBLOK]) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
773 if ((*sp)->s_nxt == NULL) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
774 struct regexp_h_stack *bq;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
775
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
776 if ((bq = regexp_h_malloc(sizeof *bq)) == NULL)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
777 return;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
778 bq->s_nxt = NULL;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
779 bq->s_prv = *sp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
780 (*sp)->s_nxt = bq;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
781 *sp = bq;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
782 } else
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
783 *sp = (*sp)->s_nxt;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
784 *sc = &(*sp)->s_ptr[0];
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
785 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
786 *(*sc)++ = lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
787 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
788
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
789 static regexp_h_inline const char *
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
790 regexp_h_pop(struct regexp_h_stack **sb, struct regexp_h_stack **sp,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
791 const char ***sc, const char *lp)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
792 {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
793 if (regexp_h_firstwc == NULL || lp <= regexp_h_firstwc)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
794 return &lp[-1];
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
795 if (*sp == NULL)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
796 return regexp_h_firstwc;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
797 if (*sc == &(*sp)->s_ptr[0]) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
798 if ((*sp)->s_prv == NULL) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
799 regexp_h_free(*sp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
800 *sp = NULL;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
801 *sb = NULL;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
802 return regexp_h_firstwc;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
803 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
804 *sp = (*sp)->s_prv;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
805 regexp_h_free((*sp)->s_nxt);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
806 (*sp)->s_nxt = NULL ;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
807 *sc = &(*sp)->s_ptr[REGEXP_H_STAKBLOK];
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
808 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
809 return *(--(*sc));
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
810 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
811
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
812 static void
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
813 regexp_h_zerostak(struct regexp_h_stack **sb, struct regexp_h_stack **sp)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
814 {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
815 for (*sp = *sb; *sp && (*sp)->s_nxt; *sp = (*sp)->s_nxt)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
816 if ((*sp)->s_prv)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
817 regexp_h_free((*sp)->s_prv);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
818 if (*sp) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
819 if ((*sp)->s_prv)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
820 regexp_h_free((*sp)->s_prv);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
821 regexp_h_free(*sp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
822 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
823 *sp = *sb = NULL;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
824 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
825 #else /* !REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
826 #define regexp_h_push(sb, sp, sc, lp)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
827 #endif /* !REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
828
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
829 static int
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
830 regexp_h_advance(const char *lp, const char *ep)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
831 {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
832 register const char *curlp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
833 int c, least;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
834 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
835 int d;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
836 struct regexp_h_stack *sb = NULL, *sp = NULL;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
837 const char **sc;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
838 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
839 char *bbeg;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
840 int ct;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
841
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
842 for (;;) switch (least = *ep++ & 0377, least & ~REGEXP_H_LEAST) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
843
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
844 case CCHR:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
845 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
846 case CCH1:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
847 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
848 if (*ep++ == *lp++)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
849 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
850 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
851
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
852 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
853 case CCHR|CMB:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
854 if (regexp_h_fetch(ep, 0) == regexp_h_fetch(lp, 1))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
855 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
856 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
857
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
858 case CCH2:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
859 if (ep[0] == lp[0] && ep[1] == lp[1]) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
860 ep += 2, lp += 2;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
861 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
862 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
863 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
864
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
865 case CCH3:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
866 if (ep[0] == lp[0] && ep[1] == lp[1] && ep[2] == lp[2]) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
867 ep += 3, lp += 3;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
868 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
869 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
870 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
871 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
872
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
873 case CDOT:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
874 if (*lp++)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
875 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
876 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
877 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
878 case CDOT|CMB:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
879 if ((c = regexp_h_fetch(lp, 1)) != L'\0' && c != WEOF)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
880 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
881 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
882 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
883
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
884 case CDOL:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
885 if (*lp==0)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
886 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
887 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
888
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
889 case CCEOF:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
890 loc2 = (char *)lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
891 return(1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
892
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
893 case CCL:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
894 c = *lp++ & 0377;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
895 if(ISTHERE(c)) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
896 ep += 32;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
897 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
898 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
899 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
900
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
901 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
902 case CCL|CMB:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
903 case CNCL|CMB:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
904 c = regexp_h_fetch(lp, 1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
905 if (regexp_h_cclass(ep, c, (ep[-1] & 0377) == (CCL|CMB))) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
906 ep += (*ep & 0377) + 17;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
907 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
908 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
909 return 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
910 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
911
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
912 case CBRA:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
913 braslist[*ep++ & 0377] = (char *)lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
914 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
915
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
916 case CKET:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
917 braelist[*ep++ & 0377] = (char *)lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
918 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
919
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
920 case CBRC:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
921 if (lp == regexp_h_bol && locs == NULL)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
922 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
923 if ((isdigit(lp[0] & 0377) || regexp_h_uletter(lp[0] & 0377))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
924 && !regexp_h_uletter(lp[-1] & 0377)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
925 && !isdigit(lp[-1] & 0377))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
926 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
927 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
928
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
929 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
930 case CBRC|CMB:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
931 c = regexp_h_show(lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
932 d = regexp_h_previous(lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
933 if ((iswdigit(c) || regexp_h_wuletter(c))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
934 && !regexp_h_wuletter(d)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
935 && !iswdigit(d))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
936 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
937 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
938 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
939
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
940 case CLET:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
941 if (!regexp_h_uletter(lp[0] & 0377) && !isdigit(lp[0] & 0377))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
942 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
943 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
944
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
945 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
946 case CLET|CMB:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
947 c = regexp_h_show(lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
948 if (!regexp_h_wuletter(c) && !iswdigit(c))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
949 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
950 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
951 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
952
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
953 case CCHR|RNGE:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
954 c = *ep++;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
955 regexp_h_getrnge(ep, least);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
956 while(low--)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
957 if(*lp++ != c)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
958 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
959 curlp = lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
960 while(size--) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
961 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
962 if(*lp++ != c)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
963 break;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
964 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
965 if(size < 0) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
966 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
967 lp++;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
968 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
969 ep += 2;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
970 goto star;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
971
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
972 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
973 case CCHR|RNGE|CMB:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
974 case CCH1|RNGE:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
975 case CCH2|RNGE:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
976 case CCH3|RNGE:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
977 c = regexp_h_fetch(ep, 0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
978 regexp_h_getrnge(ep, least);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
979 while (low--)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
980 if (regexp_h_fetch(lp, 1) != c)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
981 return 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
982 curlp = lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
983 while (size--) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
984 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
985 if (regexp_h_fetch(lp, 1) != c)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
986 break;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
987 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
988 if(size < 0) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
989 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
990 regexp_h_fetch(lp, 1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
991 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
992 ep += 2;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
993 goto star;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
994 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
995
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
996 case CDOT|RNGE:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
997 regexp_h_getrnge(ep, least);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
998 while(low--)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
999 if(*lp++ == '\0')
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1000 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1001 curlp = lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1002 while(size--) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1003 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1004 if(*lp++ == '\0')
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1005 break;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1006 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1007 if(size < 0) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1008 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1009 lp++;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1010 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1011 ep += 2;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1012 goto star;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1013
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1014 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1015 case CDOT|RNGE|CMB:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1016 regexp_h_getrnge(ep, least);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1017 while (low--)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1018 if ((c = regexp_h_fetch(lp, 1)) == L'\0' || c == WEOF)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1019 return 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1020 curlp = lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1021 while (size--) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1022 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1023 if ((c = regexp_h_fetch(lp, 1)) == L'\0' || c == WEOF)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1024 break;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1025 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1026 if (size < 0) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1027 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1028 regexp_h_fetch(lp, 1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1029 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1030 ep += 2;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1031 goto star;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1032 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1033
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1034 case CCL|RNGE:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1035 regexp_h_getrnge(ep + 32, least);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1036 while(low--) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1037 c = *lp++ & 0377;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1038 if(!ISTHERE(c))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1039 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1040 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1041 curlp = lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1042 while(size--) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1043 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1044 c = *lp++ & 0377;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1045 if(!ISTHERE(c))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1046 break;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1047 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1048 if(size < 0) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1049 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1050 lp++;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1051 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1052 ep += 34; /* 32 + 2 */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1053 goto star;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1054
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1055 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1056 case CCL|RNGE|CMB:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1057 case CNCL|RNGE|CMB:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1058 regexp_h_getrnge(ep + (*ep & 0377) + 17, least);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1059 while (low--) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1060 c = regexp_h_fetch(lp, 1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1061 if (!regexp_h_cclass(ep, c,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1062 (ep[-1] & 0377 & ~REGEXP_H_LEAST)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1063 == (CCL|RNGE|CMB)))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1064 return 0;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1065 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1066 curlp = lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1067 while (size--) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1068 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1069 c = regexp_h_fetch(lp, 1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1070 if (!regexp_h_cclass(ep, c,
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1071 (ep[-1] & 0377 & ~REGEXP_H_LEAST)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1072 == (CCL|RNGE|CMB)))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1073 break;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1074 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1075 if (size < 0) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1076 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1077 regexp_h_fetch(lp, 1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1078 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1079 ep += (*ep & 0377) + 19;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1080 goto star;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1081 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1082
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1083 case CBACK:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1084 bbeg = braslist[*ep & 0377];
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1085 ct = braelist[*ep++ & 0377] - bbeg;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1086
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1087 if(strncmp(bbeg, lp, ct) == 0) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1088 lp += ct;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1089 continue;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1090 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1091 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1092
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1093 case CBACK|STAR:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1094 bbeg = braslist[*ep & 0377];
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1095 ct = braelist[*ep++ & 0377] - bbeg;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1096 curlp = lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1097 while(strncmp(bbeg, lp, ct) == 0)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1098 lp += ct;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1099
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1100 while(lp >= curlp) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1101 if(regexp_h_advance(lp, ep)) return(1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1102 lp -= ct;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1103 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1104 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1105
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1106
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1107 case CDOT|STAR:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1108 curlp = lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1109 do
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1110 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1111 while (*lp++);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1112 goto star;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1113
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1114 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1115 case CDOT|STAR|CMB:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1116 curlp = lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1117 do
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1118 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1119 while ((c = regexp_h_fetch(lp, 1)) != L'\0' && c != WEOF);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1120 goto star;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1121 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1122
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1123 case CCHR|STAR:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1124 curlp = lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1125 do
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1126 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1127 while (*lp++ == *ep);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1128 ep++;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1129 goto star;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1130
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1131 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1132 case CCHR|STAR|CMB:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1133 case CCH1|STAR:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1134 case CCH2|STAR:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1135 case CCH3|STAR:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1136 curlp = lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1137 d = regexp_h_fetch(ep, 0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1138 do
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1139 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1140 while (regexp_h_fetch(lp, 1) == d);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1141 goto star;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1142 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1143
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1144 case CCL|STAR:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1145 curlp = lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1146 do {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1147 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1148 c = *lp++ & 0377;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1149 } while(ISTHERE(c));
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1150 ep += 32;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1151 goto star;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1152
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1153 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1154 case CCL|STAR|CMB:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1155 case CNCL|STAR|CMB:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1156 curlp = lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1157 do {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1158 regexp_h_push(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1159 c = regexp_h_fetch(lp, 1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1160 } while (regexp_h_cclass(ep, c, (ep[-1] & 0377)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1161 == (CCL|STAR|CMB)));
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1162 ep += (*ep & 0377) + 17;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1163 goto star;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1164 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1165
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1166 star:
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1167 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1168 if (regexp_h_wchars == 0) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1169 #endif
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1170 do {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1171 if(--lp == locs)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1172 break;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1173 if (regexp_h_advance(lp, ep))
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1174 return(1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1175 } while (lp > curlp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1176 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1177 } else {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1178 do {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1179 lp = regexp_h_pop(&sb, &sp, &sc, lp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1180 if (lp <= locs)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1181 break;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1182 if (regexp_h_advance(lp, ep)) {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1183 regexp_h_zerostak(&sb, &sp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1184 return(1);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1185 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1186 } while (lp > curlp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1187 regexp_h_zerostak(&sb, &sp);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1188 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1189 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1190 return(0);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1191
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1192 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1193 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1194
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1195 static void
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1196 regexp_h_getrnge(register const char *str, int least)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1197 {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1198 low = *str++ & 0377;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1199 size = least & REGEXP_H_LEAST ? /*20000*/INT_MAX : (*str & 0377) - low;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1200 }
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1201
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1202 int
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1203 advance(const char *lp, const char *ep)
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1204 {
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1205 REGEXP_H_ADVANCE_INIT /* skip past circf */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1206 regexp_h_bol = lp;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1207 #ifdef REGEXP_H_WCHARS
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1208 regexp_h_firstwc = NULL;
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1209 #endif /* REGEXP_H_WCHARS */
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1210 return regexp_h_advance(lp, ep);
1493bea5ac22 Initial version of the standalone heirloom-ed
markus schnalke <meillo@marmaro.de>
parents:
diff changeset
1211 }