/[pcre]/code/tags/pcre-4.4/internal.h
ViewVC logotype

Contents of /code/tags/pcre-4.4/internal.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 72 - (hide annotations) (download)
Sat Feb 24 21:40:26 2007 UTC (6 years, 2 months ago) by nigel
File MIME type: text/plain
File size: 28334 byte(s)
Tag code/trunk as code/tags/pcre-4.4.

1 nigel 3 /*************************************************
2     * Perl-Compatible Regular Expressions *
3     *************************************************/
4    
5    
6     /* This is a library of functions to support regular expressions whose syntax
7     and semantics are as close as possible to those of the Perl 5 language. See
8     the file Tech.Notes for some information on the internals.
9    
10     Written by: Philip Hazel <ph10@cam.ac.uk>
11    
12 nigel 63 Copyright (c) 1997-2003 University of Cambridge
13 nigel 3
14     -----------------------------------------------------------------------------
15     Permission is granted to anyone to use this software for any purpose on any
16     computer system, and to redistribute it freely, subject to the following
17     restrictions:
18    
19     1. This software is distributed in the hope that it will be useful,
20     but WITHOUT ANY WARRANTY; without even the implied warranty of
21     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22    
23     2. The origin of this software must not be misrepresented, either by
24     explicit claim or by omission.
25    
26     3. Altered versions must be plainly marked as such, and must not be
27     misrepresented as being the original software.
28 nigel 29
29     4. If PCRE is embedded in any software that is released under the GNU
30     General Purpose Licence (GPL), then the terms of that licence shall
31     supersede any condition above with which it is incompatible.
32 nigel 3 -----------------------------------------------------------------------------
33     */
34    
35     /* This header contains definitions that are shared between the different
36     modules, but which are not relevant to the outside. */
37    
38 nigel 41 /* Get the definitions provided by running "configure" */
39    
40     #include "config.h"
41    
42 nigel 63 /* When compiling for use with the Virtual Pascal compiler, these functions
43     need to have their names changed. PCRE must be compiled with the -DVPCOMPAT
44     option on the command line. */
45    
46     #ifdef VPCOMPAT
47     #define strncmp(s1,s2,m) _strncmp(s1,s2,m)
48     #define memcpy(d,s,n) _memcpy(d,s,n)
49     #define memmove(d,s,n) _memmove(d,s,n)
50     #define memset(s,c,n) _memset(s,c,n)
51     #else /* VPCOMPAT */
52    
53 nigel 3 /* To cope with SunOS4 and other systems that lack memmove() but have bcopy(),
54 nigel 47 define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY
55     is set. Otherwise, include an emulating function for those systems that have
56     neither (there some non-Unix environments where this is the case). This assumes
57     that all calls to memmove are moving strings upwards in store, which is the
58     case in PCRE. */
59 nigel 3
60 nigel 43 #if ! HAVE_MEMMOVE
61 nigel 9 #undef memmove /* some systems may have a macro */
62 nigel 47 #if HAVE_BCOPY
63 nigel 3 #define memmove(a, b, c) bcopy(b, a, c)
64 nigel 63 #else /* HAVE_BCOPY */
65 nigel 47 void *
66     pcre_memmove(unsigned char *dest, const unsigned char *src, size_t n)
67     {
68     int i;
69     dest += n;
70     src += n;
71     for (i = 0; i < n; ++i) *(--dest) = *(--src);
72     }
73     #define memmove(a, b, c) pcre_memmove(a, b, c)
74 nigel 63 #endif /* not HAVE_BCOPY */
75     #endif /* not HAVE_MEMMOVE */
76     #endif /* not VPCOMPAT */
77    
78    
79     /* PCRE keeps offsets in its compiled code as 2-byte quantities by default.
80     These are used, for example, to link from the start of a subpattern to its
81     alternatives and its end. The use of 2 bytes per offset limits the size of the
82     compiled regex to around 64K, which is big enough for almost everybody.
83     However, I received a request for an even bigger limit. For this reason, and
84     also to make the code easier to maintain, the storing and loading of offsets
85     from the byte string is now handled by the macros that are defined here.
86    
87     The macros are controlled by the value of LINK_SIZE. This defaults to 2 in
88     the config.h file, but can be overridden by using -D on the command line. This
89     is automated on Unix systems via the "configure" command. */
90    
91     #if LINK_SIZE == 2
92    
93     #define PUT(a,n,d) \
94     (a[n] = (d) >> 8), \
95     (a[(n)+1] = (d) & 255)
96    
97     #define GET(a,n) \
98     (((a)[n] << 8) | (a)[(n)+1])
99    
100     #define MAX_PATTERN_SIZE (1 << 16)
101    
102    
103     #elif LINK_SIZE == 3
104    
105     #define PUT(a,n,d) \
106     (a[n] = (d) >> 16), \
107     (a[(n)+1] = (d) >> 8), \
108     (a[(n)+2] = (d) & 255)
109    
110     #define GET(a,n) \
111     (((a)[n] << 16) | ((a)[(n)+1] << 8) | (a)[(n)+2])
112    
113     #define MAX_PATTERN_SIZE (1 << 24)
114    
115    
116     #elif LINK_SIZE == 4
117    
118     #define PUT(a,n,d) \
119     (a[n] = (d) >> 24), \
120     (a[(n)+1] = (d) >> 16), \
121     (a[(n)+2] = (d) >> 8), \
122     (a[(n)+3] = (d) & 255)
123    
124     #define GET(a,n) \
125     (((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])
126    
127     #define MAX_PATTERN_SIZE (1 << 30) /* Keep it positive */
128    
129    
130     #else
131     #error LINK_SIZE must be either 2, 3, or 4
132 nigel 3 #endif
133    
134 nigel 63
135     /* Convenience macro defined in terms of the others */
136    
137     #define PUTINC(a,n,d) PUT(a,n,d), a += LINK_SIZE
138    
139    
140     /* PCRE uses some other 2-byte quantities that do not change when the size of
141     offsets changes. There are used for repeat counts and for other things such as
142     capturing parenthesis numbers in back references. */
143    
144     #define PUT2(a,n,d) \
145     a[n] = (d) >> 8; \
146     a[(n)+1] = (d) & 255
147    
148     #define GET2(a,n) \
149     (((a)[n] << 8) | (a)[(n)+1])
150    
151     #define PUT2INC(a,n,d) PUT2(a,n,d), a += 2
152    
153    
154 nigel 3 /* Standard C headers plus the external interface definition */
155    
156     #include <ctype.h>
157     #include <limits.h>
158     #include <stddef.h>
159     #include <stdio.h>
160     #include <stdlib.h>
161     #include <string.h>
162 nigel 63
163     #ifndef PCRE_SPY
164     #define PCRE_DEFINITION /* Win32 __declspec(export) trigger for .dll */
165     #endif
166    
167 nigel 3 #include "pcre.h"
168    
169 nigel 9 /* In case there is no definition of offsetof() provided - though any proper
170     Standard C system should have one. */
171    
172     #ifndef offsetof
173 nigel 11 #define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
174 nigel 9 #endif
175    
176 nigel 23 /* These are the public options that can change during matching. */
177    
178     #define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)
179    
180 nigel 37 /* Private options flags start at the most significant end of the four bytes,
181     but skip the top bit so we can use ints for convenience without getting tangled
182     with negative values. The public options defined in pcre.h start at the least
183     significant end. Make sure they don't overlap, though now that we have expanded
184     to four bytes there is plenty of space. */
185 nigel 3
186 nigel 63 #define PCRE_FIRSTSET 0x40000000 /* first_byte is set */
187     #define PCRE_REQCHSET 0x20000000 /* req_byte is set */
188 nigel 37 #define PCRE_STARTLINE 0x10000000 /* start after \n for multiline */
189 nigel 63 #define PCRE_ICHANGED 0x08000000 /* i option changes within regex */
190 nigel 3
191     /* Options for the "extra" block produced by pcre_study(). */
192    
193 nigel 23 #define PCRE_STUDY_MAPPED 0x01 /* a map of starting chars exists */
194 nigel 3
195 nigel 23 /* Masks for identifying the public options which are permitted at compile
196     time, run time or study time, respectively. */
197 nigel 3
198     #define PUBLIC_OPTIONS \
199     (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
200 nigel 63 PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \
201 nigel 71 PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK)
202 nigel 3
203 nigel 37 #define PUBLIC_EXEC_OPTIONS \
204 nigel 71 (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK)
205 nigel 3
206 nigel 23 #define PUBLIC_STUDY_OPTIONS 0 /* None defined */
207 nigel 3
208     /* Magic number to provide a small check against being handed junk. */
209    
210 nigel 33 #define MAGIC_NUMBER 0x50435245UL /* 'PCRE' */
211 nigel 3
212 nigel 63 /* Negative values for the firstchar and reqchar variables */
213    
214     #define REQ_UNSET (-2)
215     #define REQ_NONE (-1)
216    
217 nigel 65 /* Flags added to firstbyte or reqbyte; a "non-literal" item is either a
218     variable-length repeat, or a anything other than literal characters. */
219 nigel 63
220     #define REQ_CASELESS 0x0100 /* indicates caselessness */
221 nigel 65 #define REQ_VARY 0x0200 /* reqbyte followed non-literal item */
222 nigel 63
223 nigel 3 /* Miscellaneous definitions */
224    
225     typedef int BOOL;
226    
227     #define FALSE 0
228     #define TRUE 1
229    
230 nigel 53 /* Escape items that are just an encoding of a particular data value. Note that
231 nigel 63 ESC_n is defined as yet another macro, which is set in config.h to either \n
232 nigel 53 (the default) or \r (which some people want). */
233    
234 nigel 63 #ifndef ESC_e
235     #define ESC_e 27
236 nigel 53 #endif
237    
238 nigel 63 #ifndef ESC_f
239     #define ESC_f '\f'
240 nigel 53 #endif
241    
242 nigel 63 #ifndef ESC_n
243     #define ESC_n NEWLINE
244 nigel 53 #endif
245    
246 nigel 63 #ifndef ESC_r
247     #define ESC_r '\r'
248 nigel 53 #endif
249    
250 nigel 69 /* We can't officially use ESC_t because it is a POSIX reserved identifier
251     (presumably because of all the others like size_t). */
252    
253     #ifndef ESC_tee
254     #define ESC_tee '\t'
255 nigel 53 #endif
256    
257 nigel 3 /* These are escaped items that aren't just an encoding of a particular data
258     value such as \n. They must have non-zero values, as check_escape() returns
259     their negation. Also, they must appear in the same order as in the opcode
260 nigel 63 definitions below, up to ESC_z. There's a dummy for OP_ANY because it
261     corresponds to "." rather than an escape sequence. The final one must be
262     ESC_REF as subsequent values are used for \1, \2, \3, etc. There is are two
263     tests in the code for an escape greater than ESC_b and less than ESC_Z to
264     detect the types that may be repeated. These are the types that consume a
265     character. If any new escapes are put in between that don't consume a
266     character, that code will have to change. */
267 nigel 3
268 nigel 63 enum { ESC_A = 1, ESC_G, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W,
269     ESC_w, ESC_dum1, ESC_C, ESC_Z, ESC_z, ESC_E, ESC_Q, ESC_REF };
270 nigel 3
271 nigel 63 /* Flag bits and data types for the extended class (OP_XCLASS) for classes that
272     contain UTF-8 characters with values greater than 255. */
273    
274     #define XCL_NOT 0x01 /* Flag: this is a negative class */
275     #define XCL_MAP 0x02 /* Flag: a 32-byte map is present */
276    
277     #define XCL_END 0 /* Marks end of individual items */
278     #define XCL_SINGLE 1 /* Single item (one multibyte char) follows */
279     #define XCL_RANGE 2 /* A range (two multibyte chars) follows */
280    
281    
282 nigel 3 /* Opcode table: OP_BRA must be last, as all values >= it are used for brackets
283     that extract substrings. Starting from 1 (i.e. after OP_END), the values up to
284 nigel 63 OP_EOD must correspond in order to the list of escapes immediately above.
285     Note that whenever this list is updated, the two macro definitions that follow
286     must also be updated to match. */
287 nigel 3
288     enum {
289 nigel 63 OP_END, /* 0 End of pattern */
290 nigel 3
291     /* Values corresponding to backslashed metacharacters */
292    
293 nigel 63 OP_SOD, /* 1 Start of data: \A */
294     OP_SOM, /* 2 Start of match (subject + offset): \G */
295     OP_NOT_WORD_BOUNDARY, /* 3 \B */
296     OP_WORD_BOUNDARY, /* 4 \b */
297     OP_NOT_DIGIT, /* 5 \D */
298     OP_DIGIT, /* 6 \d */
299     OP_NOT_WHITESPACE, /* 7 \S */
300     OP_WHITESPACE, /* 8 \s */
301     OP_NOT_WORDCHAR, /* 9 \W */
302     OP_WORDCHAR, /* 10 \w */
303     OP_ANY, /* 11 Match any character */
304     OP_ANYBYTE, /* 12 Match any byte (\C); different to OP_ANY for UTF-8 */
305     OP_EODN, /* 13 End of data or \n at end of data: \Z. */
306     OP_EOD, /* 14 End of data: \z */
307 nigel 3
308 nigel 63 OP_OPT, /* 15 Set runtime options */
309     OP_CIRC, /* 16 Start of line - varies with multiline switch */
310     OP_DOLL, /* 17 End of line - varies with multiline switch */
311     OP_CHARS, /* 18 Match string of characters */
312     OP_NOT, /* 19 Match anything but the following char */
313 nigel 3
314 nigel 63 OP_STAR, /* 20 The maximizing and minimizing versions of */
315     OP_MINSTAR, /* 21 all these opcodes must come in pairs, with */
316     OP_PLUS, /* 22 the minimizing one second. */
317     OP_MINPLUS, /* 23 This first set applies to single characters */
318     OP_QUERY, /* 24 */
319     OP_MINQUERY, /* 25 */
320     OP_UPTO, /* 26 From 0 to n matches */
321     OP_MINUPTO, /* 27 */
322     OP_EXACT, /* 28 Exactly n matches */
323 nigel 3
324 nigel 63 OP_NOTSTAR, /* 29 The maximizing and minimizing versions of */
325     OP_NOTMINSTAR, /* 30 all these opcodes must come in pairs, with */
326     OP_NOTPLUS, /* 31 the minimizing one second. */
327     OP_NOTMINPLUS, /* 32 This set applies to "not" single characters */
328     OP_NOTQUERY, /* 33 */
329     OP_NOTMINQUERY, /* 34 */
330     OP_NOTUPTO, /* 35 From 0 to n matches */
331     OP_NOTMINUPTO, /* 36 */
332     OP_NOTEXACT, /* 37 Exactly n matches */
333 nigel 3
334 nigel 63 OP_TYPESTAR, /* 38 The maximizing and minimizing versions of */
335     OP_TYPEMINSTAR, /* 39 all these opcodes must come in pairs, with */
336     OP_TYPEPLUS, /* 40 the minimizing one second. These codes must */
337     OP_TYPEMINPLUS, /* 41 be in exactly the same order as those above. */
338     OP_TYPEQUERY, /* 42 This set applies to character types such as \d */
339     OP_TYPEMINQUERY, /* 43 */
340     OP_TYPEUPTO, /* 44 From 0 to n matches */
341     OP_TYPEMINUPTO, /* 45 */
342     OP_TYPEEXACT, /* 46 Exactly n matches */
343 nigel 3
344 nigel 63 OP_CRSTAR, /* 47 The maximizing and minimizing versions of */
345     OP_CRMINSTAR, /* 48 all these opcodes must come in pairs, with */
346     OP_CRPLUS, /* 49 the minimizing one second. These codes must */
347     OP_CRMINPLUS, /* 50 be in exactly the same order as those above. */
348     OP_CRQUERY, /* 51 These are for character classes and back refs */
349     OP_CRMINQUERY, /* 52 */
350     OP_CRRANGE, /* 53 These are different to the three seta above. */
351     OP_CRMINRANGE, /* 54 */
352 nigel 3
353 nigel 63 OP_CLASS, /* 55 Match a character class, chars < 256 only */
354     OP_NCLASS, /* 56 Same, but the bitmap was created from a negative
355     class - the difference is relevant only when a UTF-8
356     character > 255 is encountered. */
357 nigel 3
358 nigel 63 OP_XCLASS, /* 56 Extended class for handling UTF-8 chars within the
359     class. This does both positive and negative. */
360 nigel 3
361 nigel 63 OP_REF, /* 57 Match a back reference */
362     OP_RECURSE, /* 58 Match a numbered subpattern (possibly recursive) */
363     OP_CALLOUT, /* 59 Call out to external function if provided */
364    
365     OP_ALT, /* 60 Start of alternation */
366     OP_KET, /* 61 End of group that doesn't have an unbounded repeat */
367     OP_KETRMAX, /* 62 These two must remain together and in this */
368     OP_KETRMIN, /* 63 order. They are for groups the repeat for ever. */
369    
370 nigel 23 /* The assertions must come before ONCE and COND */
371    
372 nigel 63 OP_ASSERT, /* 64 Positive lookahead */
373     OP_ASSERT_NOT, /* 65 Negative lookahead */
374     OP_ASSERTBACK, /* 66 Positive lookbehind */
375     OP_ASSERTBACK_NOT, /* 67 Negative lookbehind */
376     OP_REVERSE, /* 68 Move pointer back - used in lookbehind assertions */
377 nigel 23
378     /* ONCE and COND must come after the assertions, with ONCE first, as there's
379     a test for >= ONCE for a subpattern that isn't an assertion. */
380    
381 nigel 63 OP_ONCE, /* 69 Once matched, don't back up into the subpattern */
382     OP_COND, /* 70 Conditional group */
383     OP_CREF, /* 71 Used to hold an extraction string number (cond ref) */
384 nigel 3
385 nigel 63 OP_BRAZERO, /* 72 These two must remain together and in this */
386     OP_BRAMINZERO, /* 73 order. */
387 nigel 3
388 nigel 63 OP_BRANUMBER, /* 74 Used for extracting brackets whose number is greater
389     than can fit into an opcode. */
390 nigel 53
391 nigel 63 OP_BRA /* 75 This and greater values are used for brackets that
392     extract substrings up to a basic limit. After that,
393     use is made of OP_BRANUMBER. */
394 nigel 3 };
395    
396 nigel 63 /* WARNING: There is an implicit assumption in study.c that all opcodes are
397     less than 128 in value. This makes handling UTF-8 character sequences easier.
398     */
399    
400    
401     /* This macro defines textual names for all the opcodes. There are used only
402     for debugging, in pcre.c when DEBUG is defined, and also in pcretest.c. The
403     macro is referenced only in printint.c. */
404    
405     #define OP_NAME_LIST \
406     "End", "\\A", "\\G", "\\B", "\\b", "\\D", "\\d", \
407     "\\S", "\\s", "\\W", "\\w", "Any", "Anybyte", "\\Z", "\\z", \
408     "Opt", "^", "$", "chars", "not", \
409     "*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
410     "*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
411     "*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
412     "*", "*?", "+", "+?", "?", "??", "{", "{", \
413     "class", "nclass", "xclass", "Ref", "Recurse", "Callout", \
414     "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not", \
415     "AssertB", "AssertB not", "Reverse", "Once", "Cond", "Cond ref",\
416     "Brazero", "Braminzero", "Branumber", "Bra"
417    
418    
419     /* This macro defines the length of fixed length operations in the compiled
420     regex. The lengths are used when searching for specific things, and also in the
421     debugging printing of a compiled regex. We use a macro so that it can be
422     incorporated both into pcre.c and pcretest.c without being publicly exposed.
423    
424     As things have been extended, some of these are no longer fixed lenths, but are
425     minima instead. For example, the length of a single-character repeat may vary
426     in UTF-8 mode. The code that uses this table must know about such things. */
427    
428     #define OP_LENGTHS \
429     1, /* End */ \
430     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* \A, \G, \B, \B, \D, \d, \S, \s, \W, \w */ \
431     1, 1, 1, 1, 2, 1, 1, /* Any, Anybyte, \Z, \z, Opt, ^, $ */ \
432     2, /* Chars - the minimum length */ \
433     2, /* not */ \
434     /* Positive single-char repeats */ \
435     2, 2, 2, 2, 2, 2, /* *, *?, +, +?, ?, ?? ** These are */ \
436     4, 4, 4, /* upto, minupto, exact ** minima */ \
437     /* Negative single-char repeats */ \
438     2, 2, 2, 2, 2, 2, /* NOT *, *?, +, +?, ?, ?? */ \
439     4, 4, 4, /* NOT upto, minupto, exact */ \
440     /* Positive type repeats */ \
441     2, 2, 2, 2, 2, 2, /* Type *, *?, +, +?, ?, ?? */ \
442     4, 4, 4, /* Type upto, minupto, exact */ \
443     /* Character class & ref repeats */ \
444     1, 1, 1, 1, 1, 1, /* *, *?, +, +?, ?, ?? */ \
445     5, 5, /* CRRANGE, CRMINRANGE */ \
446     33, /* CLASS */ \
447     33, /* NCLASS */ \
448     0, /* XCLASS - variable length */ \
449     3, /* REF */ \
450     1+LINK_SIZE, /* RECURSE */ \
451     2, /* CALLOUT */ \
452     1+LINK_SIZE, /* Alt */ \
453     1+LINK_SIZE, /* Ket */ \
454     1+LINK_SIZE, /* KetRmax */ \
455     1+LINK_SIZE, /* KetRmin */ \
456     1+LINK_SIZE, /* Assert */ \
457     1+LINK_SIZE, /* Assert not */ \
458     1+LINK_SIZE, /* Assert behind */ \
459     1+LINK_SIZE, /* Assert behind not */ \
460     1+LINK_SIZE, /* Reverse */ \
461     1+LINK_SIZE, /* Once */ \
462     1+LINK_SIZE, /* COND */ \
463     3, /* CREF */ \
464     1, 1, /* BRAZERO, BRAMINZERO */ \
465     3, /* BRANUMBER */ \
466     1+LINK_SIZE /* BRA */ \
467    
468    
469 nigel 53 /* The highest extraction number before we have to start using additional
470     bytes. (Originally PCRE didn't have support for extraction counts highter than
471     this number.) The value is limited by the number of opcodes left after OP_BRA,
472     i.e. 255 - OP_BRA. We actually set it a bit lower to leave room for additional
473     opcodes. */
474 nigel 3
475 nigel 53 #define EXTRACT_BASIC_MAX 150
476 nigel 3
477 nigel 63 /* A magic value for OP_CREF to indicate the "in recursion" condition. */
478    
479     #define CREF_RECURSE 0xffff
480    
481 nigel 3 /* The texts of compile-time error messages are defined as macros here so that
482     they can be accessed by the POSIX wrapper and converted into error codes. Yes,
483     I could have used error codes in the first place, but didn't feel like changing
484     just to accommodate the POSIX wrapper. */
485    
486     #define ERR1 "\\ at end of pattern"
487     #define ERR2 "\\c at end of pattern"
488     #define ERR3 "unrecognized character follows \\"
489     #define ERR4 "numbers out of order in {} quantifier"
490     #define ERR5 "number too big in {} quantifier"
491     #define ERR6 "missing terminating ] for character class"
492     #define ERR7 "invalid escape sequence in character class"
493     #define ERR8 "range out of order in character class"
494     #define ERR9 "nothing to repeat"
495     #define ERR10 "operand of unlimited repeat could match the empty string"
496     #define ERR11 "internal error: unexpected repeat"
497     #define ERR12 "unrecognized character after (?"
498 nigel 63 #define ERR13 "POSIX named classes are supported only within a class"
499 nigel 3 #define ERR14 "missing )"
500 nigel 63 #define ERR15 "reference to non-existent subpattern"
501 nigel 3 #define ERR16 "erroffset passed as NULL"
502     #define ERR17 "unknown option bit(s) set"
503     #define ERR18 "missing ) after comment"
504 nigel 53 #define ERR19 "parentheses nested too deeply"
505 nigel 3 #define ERR20 "regular expression too large"
506     #define ERR21 "failed to get memory"
507 nigel 23 #define ERR22 "unmatched parentheses"
508 nigel 3 #define ERR23 "internal error: code overflow"
509 nigel 23 #define ERR24 "unrecognized character after (?<"
510     #define ERR25 "lookbehind assertion is not fixed length"
511     #define ERR26 "malformed number after (?("
512     #define ERR27 "conditional group contains more than two branches"
513     #define ERR28 "assertion expected after (?("
514 nigel 63 #define ERR29 "(?R or (?digits must be followed by )"
515 nigel 43 #define ERR30 "unknown POSIX class name"
516     #define ERR31 "POSIX collating elements are not supported"
517 nigel 49 #define ERR32 "this version of PCRE is not compiled with PCRE_UTF8 support"
518 nigel 63 #define ERR33 "spare error"
519 nigel 49 #define ERR34 "character value in \\x{...} sequence is too large"
520 nigel 51 #define ERR35 "invalid condition (?(0)"
521 nigel 63 #define ERR36 "\\C not allowed in lookbehind assertion"
522     #define ERR37 "PCRE does not support \\L, \\l, \\N, \\P, \\p, \\U, \\u, or \\X"
523     #define ERR38 "number after (?C is > 255"
524     #define ERR39 "closing ) for (?C expected"
525     #define ERR40 "recursive call could loop indefinitely"
526     #define ERR41 "unrecognized character after (?P"
527     #define ERR42 "syntax error after (?P"
528     #define ERR43 "two named groups have the same name"
529 nigel 71 #define ERR44 "invalid UTF-8 string"
530 nigel 3
531     /* All character handling must be done as unsigned characters. Otherwise there
532     are problems with top-bit-set characters and functions such as isspace().
533     However, we leave the interface to the outside world as char *, because that
534     should make things easier for callers. We define a short type for unsigned char
535     to save lots of typing. I tried "uchar", but it causes problems on Digital
536     Unix, where it is defined in sys/types, so use "uschar" instead. */
537    
538     typedef unsigned char uschar;
539    
540 nigel 63 /* The real format of the start of the pcre block; the index of names and the
541     code vector run on as long as necessary after the end. */
542 nigel 3
543     typedef struct real_pcre {
544 nigel 33 unsigned long int magic_number;
545 nigel 63 size_t size; /* Total that was malloced */
546     const unsigned char *tables; /* Pointer to tables */
547 nigel 37 unsigned long int options;
548 nigel 53 unsigned short int top_bracket;
549     unsigned short int top_backref;
550 nigel 63 unsigned short int first_byte;
551     unsigned short int req_byte;
552     unsigned short int name_entry_size; /* Size of any name items; 0 => none */
553     unsigned short int name_count; /* Number of name items */
554 nigel 3 } real_pcre;
555    
556 nigel 63 /* The format of the block used to store data from pcre_study(). */
557 nigel 3
558 nigel 63 typedef struct pcre_study_data {
559     size_t size; /* Total that was malloced */
560 nigel 37 uschar options;
561     uschar start_bits[32];
562 nigel 63 } pcre_study_data;
563 nigel 3
564 nigel 25 /* Structure for passing "static" information around between the functions
565     doing the compiling, so that they are thread-safe. */
566 nigel 3
567 nigel 25 typedef struct compile_data {
568     const uschar *lcc; /* Points to lower casing table */
569 nigel 37 const uschar *fcc; /* Points to case-flipping table */
570 nigel 25 const uschar *cbits; /* Points to character type table */
571     const uschar *ctypes; /* Points to table of type maps */
572 nigel 63 const uschar *start_code; /* The start of the compiled code */
573     uschar *name_table; /* The name/number table */
574     int names_found; /* Number of entries so far */
575     int name_entry_size; /* Size of each entry */
576     int top_backref; /* Maximum back reference */
577     unsigned int backref_map; /* Bitmap of low back refs */
578 nigel 65 int req_varyopt; /* "After variable item" flag for reqbyte */
579 nigel 25 } compile_data;
580 nigel 3
581 nigel 63 /* Structure for maintaining a chain of pointers to the currently incomplete
582     branches, for testing for left recursion. */
583    
584     typedef struct branch_chain {
585     struct branch_chain *outer;
586     uschar *current;
587     } branch_chain;
588    
589     /* Structure for items in a linked list that represents an explicit recursive
590     call within the pattern. */
591    
592     typedef struct recursion_info {
593     struct recursion_info *prev; /* Previous recursion record (or NULL) */
594     int group_num; /* Number of group that was called */
595     const uschar *after_call; /* "Return value": points after the call in the expr */
596     const uschar *save_start; /* Old value of md->start_match */
597     int *offset_save; /* Pointer to start of saved offsets */
598     int saved_max; /* Number of saved offsets */
599     } recursion_info;
600    
601 nigel 25 /* Structure for passing "static" information around between the functions
602     doing the matching, so that they are thread-safe. */
603    
604     typedef struct match_data {
605 nigel 67 unsigned long int match_call_count; /* As it says */
606 nigel 65 unsigned long int match_limit;/* As it says */
607 nigel 25 int *offset_vector; /* Offset vector */
608     int offset_end; /* One past the end */
609     int offset_max; /* The maximum usable for return data */
610     const uschar *lcc; /* Points to lower casing table */
611     const uschar *ctypes; /* Points to table of type maps */
612     BOOL offset_overflow; /* Set if too many extractions */
613     BOOL notbol; /* NOTBOL flag */
614     BOOL noteol; /* NOTEOL flag */
615 nigel 49 BOOL utf8; /* UTF8 flag */
616 nigel 25 BOOL endonly; /* Dollar not before final \n */
617 nigel 37 BOOL notempty; /* Empty string match not wanted */
618 nigel 63 const uschar *start_code; /* For use when recursing */
619 nigel 25 const uschar *start_subject; /* Start of the subject string */
620     const uschar *end_subject; /* End of the subject string */
621 nigel 37 const uschar *start_match; /* Start of this match attempt */
622 nigel 25 const uschar *end_match_ptr; /* Subject position at end match */
623 nigel 43 int end_offset_top; /* Highwater mark at end of match */
624 nigel 63 int capture_last; /* Most recent capture number */
625     int start_offset; /* The start offset value */
626     recursion_info *recursive; /* Linked list of recursion data */
627     void *callout_data; /* To pass back to callouts */
628 nigel 25 } match_data;
629    
630     /* Bit definitions for entries in the pcre_ctypes table. */
631    
632 nigel 3 #define ctype_space 0x01
633     #define ctype_letter 0x02
634     #define ctype_digit 0x04
635     #define ctype_xdigit 0x08
636     #define ctype_word 0x10 /* alphameric or '_' */
637     #define ctype_meta 0x80 /* regexp meta char or zero (end pattern) */
638    
639 nigel 25 /* Offsets for the bitmap tables in pcre_cbits. Each table contains a set
640 nigel 43 of bits for a class map. Some classes are built by combining these tables. */
641 nigel 3
642 nigel 43 #define cbit_space 0 /* [:space:] or \s */
643     #define cbit_xdigit 32 /* [:xdigit:] */
644     #define cbit_digit 64 /* [:digit:] or \d */
645     #define cbit_upper 96 /* [:upper:] */
646     #define cbit_lower 128 /* [:lower:] */
647     #define cbit_word 160 /* [:word:] or \w */
648     #define cbit_graph 192 /* [:graph:] */
649     #define cbit_print 224 /* [:print:] */
650     #define cbit_punct 256 /* [:punct:] */
651     #define cbit_cntrl 288 /* [:cntrl:] */
652     #define cbit_length 320 /* Length of the cbits table */
653 nigel 3
654 nigel 25 /* Offsets of the various tables from the base tables pointer, and
655     total length. */
656    
657     #define lcc_offset 0
658     #define fcc_offset 256
659     #define cbits_offset 512
660     #define ctypes_offset (cbits_offset + cbit_length)
661     #define tables_length (ctypes_offset + 256)
662    
663 nigel 3 /* End of internal.h */

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12