pcre_internal.h

Go to the documentation of this file.
00001 
00002 /*  $Id: pcre_internal.h 355 2005-01-11 22:48:55Z andreradke $    */
00003 
00004 /*************************************************
00005 *      Perl-Compatible Regular Expressions       *
00006 *************************************************/
00007 
00008 
00009 /* This is a library of functions to support regular expressions whose syntax
00010 and semantics are as close as possible to those of the Perl 5 language. See
00011 the file Tech.Notes for some information on the internals.
00012 
00013 Written by: Philip Hazel <ph10@cam.ac.uk>
00014 
00015            Copyright (c) 1997-2003 University of Cambridge
00016 
00017 -----------------------------------------------------------------------------
00018 Permission is granted to anyone to use this software for any purpose on any
00019 computer system, and to redistribute it freely, subject to the following
00020 restrictions:
00021 
00022 1. This software is distributed in the hope that it will be useful,
00023    but WITHOUT ANY WARRANTY; without even the implied warranty of
00024    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00025 
00026 2. The origin of this software must not be misrepresented, either by
00027    explicit claim or by omission.
00028 
00029 3. Altered versions must be plainly marked as such, and must not be
00030    misrepresented as being the original software.
00031 
00032 4. If PCRE is embedded in any software that is released under the GNU
00033    General Purpose Licence (GPL), then the terms of that licence shall
00034    supersede any condition above with which it is incompatible.
00035 -----------------------------------------------------------------------------
00036 */
00037 
00038 /* This header contains definitions that are shared between the different
00039 modules, but which are not relevant to the outside. */
00040 
00041 /* Get the definitions provided by running "configure" */
00042 
00043 #include "pcre_config.h"
00044 
00045 /* When compiling for use with the Virtual Pascal compiler, these functions
00046 need to have their names changed. PCRE must be compiled with the -DVPCOMPAT
00047 option on the command line. */
00048 
00049 #ifdef VPCOMPAT
00050 #define strncmp(s1,s2,m) _strncmp(s1,s2,m)
00051 #define memcpy(d,s,n)    _memcpy(d,s,n)
00052 #define memmove(d,s,n)   _memmove(d,s,n)
00053 #define memset(s,c,n)    _memset(s,c,n)
00054 #else  /* VPCOMPAT */
00055 
00056 /* To cope with SunOS4 and other systems that lack memmove() but have bcopy(),
00057 define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY
00058 is set. Otherwise, include an emulating function for those systems that have
00059 neither (there some non-Unix environments where this is the case). This assumes
00060 that all calls to memmove are moving strings upwards in store, which is the
00061 case in PCRE. */
00062 
00063 #if ! HAVE_MEMMOVE
00064 #undef  memmove        /* some systems may have a macro */
00065 #if HAVE_BCOPY
00066 #define memmove(a, b, c) bcopy(b, a, c)
00067 #else  /* HAVE_BCOPY */
00068 void *
00069 pcre_memmove(unsigned char *dest, const unsigned char *src, size_t n)
00070 {
00071 int i;
00072 dest += n;
00073 src += n;
00074 for (i = 0; i < n; ++i) *(--dest) =  *(--src);
00075 }
00076 #define memmove(a, b, c) pcre_memmove(a, b, c)
00077 #endif   /* not HAVE_BCOPY */
00078 #endif   /* not HAVE_MEMMOVE */
00079 #endif   /* not VPCOMPAT */
00080 
00081 
00082 /* PCRE keeps offsets in its compiled code as 2-byte quantities by default.
00083 These are used, for example, to link from the start of a subpattern to its
00084 alternatives and its end. The use of 2 bytes per offset limits the size of the
00085 compiled regex to around 64K, which is big enough for almost everybody.
00086 However, I received a request for an even bigger limit. For this reason, and
00087 also to make the code easier to maintain, the storing and loading of offsets
00088 from the byte string is now handled by the macros that are defined here.
00089 
00090 The macros are controlled by the value of LINK_SIZE. This defaults to 2 in
00091 the config.h file, but can be overridden by using -D on the command line. This
00092 is automated on Unix systems via the "configure" command. */
00093 
00094 #if LINK_SIZE == 2
00095 
00096 #define PUT(a,n,d)   \
00097   (a[n] = (d) >> 8), \
00098   (a[(n)+1] = (d) & 255)
00099 
00100 #define GET(a,n) \
00101   (((a)[n] << 8) | (a)[(n)+1])
00102 
00103 #define MAX_PATTERN_SIZE (1 << 16)
00104 
00105 
00106 #elif LINK_SIZE == 3
00107 
00108 #define PUT(a,n,d)       \
00109   (a[n] = (d) >> 16),    \
00110   (a[(n)+1] = (d) >> 8), \
00111   (a[(n)+2] = (d) & 255)
00112 
00113 #define GET(a,n) \
00114   (((a)[n] << 16) | ((a)[(n)+1] << 8) | (a)[(n)+2])
00115 
00116 #define MAX_PATTERN_SIZE (1 << 24)
00117 
00118 
00119 #elif LINK_SIZE == 4
00120 
00121 #define PUT(a,n,d)        \
00122   (a[n] = (d) >> 24),     \
00123   (a[(n)+1] = (d) >> 16), \
00124   (a[(n)+2] = (d) >> 8),  \
00125   (a[(n)+3] = (d) & 255)
00126 
00127 #define GET(a,n) \
00128   (((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])
00129 
00130 #define MAX_PATTERN_SIZE (1 << 30)   /* Keep it positive */
00131 
00132 
00133 #else
00134 #error LINK_SIZE must be either 2, 3, or 4
00135 #endif
00136 
00137 
00138 /* Convenience macro defined in terms of the others */
00139 
00140 #define PUTINC(a,n,d)   PUT(a,n,d), a += LINK_SIZE
00141 
00142 
00143 /* PCRE uses some other 2-byte quantities that do not change when the size of
00144 offsets changes. There are used for repeat counts and for other things such as
00145 capturing parenthesis numbers in back references. */
00146 
00147 #define PUT2(a,n,d)   \
00148   a[n] = (d) >> 8; \
00149   a[(n)+1] = (d) & 255
00150 
00151 #define GET2(a,n) \
00152   (((a)[n] << 8) | (a)[(n)+1])
00153 
00154 #define PUT2INC(a,n,d)  PUT2(a,n,d), a += 2
00155 
00156 
00157 /* Standard C headers plus the external interface definition */
00158 
00159 #include <ctype.h>
00160 #include <limits.h>
00161 #include <stddef.h>
00162 #include <stdio.h>
00163 #include <stdlib.h>
00164 #include <string.h>
00165 
00166 #ifndef PCRE_SPY
00167 #define PCRE_DEFINITION       /* Win32 __declspec(export) trigger for .dll */
00168 #endif
00169 
00170 #include "pcre.h"
00171 
00172 /* In case there is no definition of offsetof() provided - though any proper
00173 Standard C system should have one. */
00174 
00175 #ifndef offsetof
00176 #define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
00177 #endif
00178 
00179 /* These are the public options that can change during matching. */
00180 
00181 #define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)
00182 
00183 /* Private options flags start at the most significant end of the four bytes,
00184 but skip the top bit so we can use ints for convenience without getting tangled
00185 with negative values. The public options defined in pcre.h start at the least
00186 significant end. Make sure they don't overlap, though now that we have expanded
00187 to four bytes there is plenty of space. */
00188 
00189 #define PCRE_FIRSTSET      0x40000000  /* first_byte is set */
00190 #define PCRE_REQCHSET      0x20000000  /* req_byte is set */
00191 #define PCRE_STARTLINE     0x10000000  /* start after \n for multiline */
00192 #define PCRE_ICHANGED      0x08000000  /* i option changes within regex */
00193 
00194 /* Options for the "extra" block produced by pcre_study(). */
00195 
00196 #define PCRE_STUDY_MAPPED   0x01     /* a map of starting chars exists */
00197 
00198 /* Masks for identifying the public options which are permitted at compile
00199 time, run time or study time, respectively. */
00200 
00201 #define PUBLIC_OPTIONS \
00202   (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
00203    PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \
00204    PCRE_NO_AUTO_CAPTURE)
00205 
00206 #define PUBLIC_EXEC_OPTIONS \
00207   (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY)
00208 
00209 #define PUBLIC_STUDY_OPTIONS 0   /* None defined */
00210 
00211 /* Magic number to provide a small check against being handed junk. */
00212 
00213 #define MAGIC_NUMBER  0x50435245UL   /* 'PCRE' */
00214 
00215 /* Negative values for the firstchar and reqchar variables */
00216 
00217 #define REQ_UNSET (-2)
00218 #define REQ_NONE  (-1)
00219 
00220 /* Flags added to firstbyte or reqbyte; a "non-literal" item is either a
00221 variable-length repeat, or a anything other than literal characters. */
00222 
00223 #define REQ_CASELESS 0x0100    /* indicates caselessness */
00224 #define REQ_VARY     0x0200    /* reqbyte followed non-literal item */
00225 
00226 /* Miscellaneous definitions */
00227 
00228 #if !defined(__WINE_WINDEF_H)
00229 /* 2004-12-29 trt: BOOL defined by MS WIN32 SDK windef.h - WINE doesn't define/use _WINDEF_H  */
00230 typedef int BOOL;
00231 #endif
00232 
00233 #undef FALSE        /*2003-05-03 AR*/
00234 #undef TRUE         /*2003-05-03 AR*/
00235 
00236 #define FALSE   0
00237 #define TRUE    1
00238 
00239 /* Escape items that are just an encoding of a particular data value. Note that
00240 ESC_n is defined as yet another macro, which is set in config.h to either \n
00241 (the default) or \r (which some people want). */
00242 
00243 #ifndef ESC_e
00244 #define ESC_e 27
00245 #endif
00246 
00247 #ifndef ESC_f
00248 #define ESC_f '\f'
00249 #endif
00250 
00251 #ifndef ESC_n
00252 #define ESC_n NEWLINE
00253 #endif
00254 
00255 #ifndef ESC_r
00256 #define ESC_r '\r'
00257 #endif
00258 
00259 #ifndef ESC_t
00260 #define ESC_t '\t'
00261 #endif
00262 
00263 /* These are escaped items that aren't just an encoding of a particular data
00264 value such as \n. They must have non-zero values, as check_escape() returns
00265 their negation. Also, they must appear in the same order as in the opcode
00266 definitions below, up to ESC_z. There's a dummy for OP_ANY because it
00267 corresponds to "." rather than an escape sequence. The final one must be
00268 ESC_REF as subsequent values are used for \1, \2, \3, etc. There is are two
00269 tests in the code for an escape greater than ESC_b and less than ESC_Z to
00270 detect the types that may be repeated. These are the types that consume a
00271 character. If any new escapes are put in between that don't consume a
00272 character, that code will have to change. */
00273 
00274 enum { ESC_A = 1, ESC_G, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W,
00275        ESC_w, ESC_dum1, ESC_C, ESC_Z, ESC_z, ESC_E, ESC_Q, ESC_REF };
00276 
00277 /* Flag bits and data types for the extended class (OP_XCLASS) for classes that
00278 contain UTF-8 characters with values greater than 255. */
00279 
00280 #define XCL_NOT    0x01    /* Flag: this is a negative class */
00281 #define XCL_MAP    0x02    /* Flag: a 32-byte map is present */
00282 
00283 #define XCL_END       0    /* Marks end of individual items */
00284 #define XCL_SINGLE    1    /* Single item (one multibyte char) follows */
00285 #define XCL_RANGE     2    /* A range (two multibyte chars) follows */
00286 
00287 
00288 /* Opcode table: OP_BRA must be last, as all values >= it are used for brackets
00289 that extract substrings. Starting from 1 (i.e. after OP_END), the values up to
00290 OP_EOD must correspond in order to the list of escapes immediately above.
00291 Note that whenever this list is updated, the two macro definitions that follow
00292 must also be updated to match. */
00293 
00294 enum {
00295   OP_END,            /* 0 End of pattern */
00296 
00297   /* Values corresponding to backslashed metacharacters */
00298 
00299   OP_SOD,            /* 1 Start of data: \A */
00300   OP_SOM,            /* 2 Start of match (subject + offset): \G */
00301   OP_NOT_WORD_BOUNDARY,  /*  3 \B */
00302   OP_WORD_BOUNDARY,      /*  4 \b */
00303   OP_NOT_DIGIT,          /*  5 \D */
00304   OP_DIGIT,              /*  6 \d */
00305   OP_NOT_WHITESPACE,     /*  7 \S */
00306   OP_WHITESPACE,         /*  8 \s */
00307   OP_NOT_WORDCHAR,       /*  9 \W */
00308   OP_WORDCHAR,           /* 10 \w */
00309   OP_ANY,            /* 11 Match any character */
00310   OP_ANYBYTE,        /* 12 Match any byte (\C); different to OP_ANY for UTF-8 */
00311   OP_EODN,           /* 13 End of data or \n at end of data: \Z. */
00312   OP_EOD,            /* 14 End of data: \z */
00313 
00314   OP_OPT,            /* 15 Set runtime options */
00315   OP_CIRC,           /* 16 Start of line - varies with multiline switch */
00316   OP_DOLL,           /* 17 End of line - varies with multiline switch */
00317   OP_CHARS,          /* 18 Match string of characters */
00318   OP_NOT,            /* 19 Match anything but the following char */
00319 
00320   OP_STAR,           /* 20 The maximizing and minimizing versions of */
00321   OP_MINSTAR,        /* 21 all these opcodes must come in pairs, with */
00322   OP_PLUS,           /* 22 the minimizing one second. */
00323   OP_MINPLUS,        /* 23 This first set applies to single characters */
00324   OP_QUERY,          /* 24 */
00325   OP_MINQUERY,       /* 25 */
00326   OP_UPTO,           /* 26 From 0 to n matches */
00327   OP_MINUPTO,        /* 27 */
00328   OP_EXACT,          /* 28 Exactly n matches */
00329 
00330   OP_NOTSTAR,        /* 29 The maximizing and minimizing versions of */
00331   OP_NOTMINSTAR,     /* 30 all these opcodes must come in pairs, with */
00332   OP_NOTPLUS,        /* 31 the minimizing one second. */
00333   OP_NOTMINPLUS,     /* 32 This set applies to "not" single characters */
00334   OP_NOTQUERY,       /* 33 */
00335   OP_NOTMINQUERY,    /* 34 */
00336   OP_NOTUPTO,        /* 35 From 0 to n matches */
00337   OP_NOTMINUPTO,     /* 36 */
00338   OP_NOTEXACT,       /* 37 Exactly n matches */
00339 
00340   OP_TYPESTAR,       /* 38 The maximizing and minimizing versions of */
00341   OP_TYPEMINSTAR,    /* 39 all these opcodes must come in pairs, with */
00342   OP_TYPEPLUS,       /* 40 the minimizing one second. These codes must */
00343   OP_TYPEMINPLUS,    /* 41 be in exactly the same order as those above. */
00344   OP_TYPEQUERY,      /* 42 This set applies to character types such as \d */
00345   OP_TYPEMINQUERY,   /* 43 */
00346   OP_TYPEUPTO,       /* 44 From 0 to n matches */
00347   OP_TYPEMINUPTO,    /* 45 */
00348   OP_TYPEEXACT,      /* 46 Exactly n matches */
00349 
00350   OP_CRSTAR,         /* 47 The maximizing and minimizing versions of */
00351   OP_CRMINSTAR,      /* 48 all these opcodes must come in pairs, with */
00352   OP_CRPLUS,         /* 49 the minimizing one second. These codes must */
00353   OP_CRMINPLUS,      /* 50 be in exactly the same order as those above. */
00354   OP_CRQUERY,        /* 51 These are for character classes and back refs */
00355   OP_CRMINQUERY,     /* 52 */
00356   OP_CRRANGE,        /* 53 These are different to the three seta above. */
00357   OP_CRMINRANGE,     /* 54 */
00358 
00359   OP_CLASS,          /* 55 Match a character class, chars < 256 only */
00360   OP_NCLASS,         /* 56 Same, but the bitmap was created from a negative
00361                            class - the difference is relevant only when a UTF-8
00362                            character > 255 is encountered. */
00363 
00364   OP_XCLASS,         /* 56 Extended class for handling UTF-8 chars within the
00365                            class. This does both positive and negative. */
00366 
00367   OP_REF,            /* 57 Match a back reference */
00368   OP_RECURSE,        /* 58 Match a numbered subpattern (possibly recursive) */
00369   OP_CALLOUT,        /* 59 Call out to external function if provided */
00370 
00371   OP_ALT,            /* 60 Start of alternation */
00372   OP_KET,            /* 61 End of group that doesn't have an unbounded repeat */
00373   OP_KETRMAX,        /* 62 These two must remain together and in this */
00374   OP_KETRMIN,        /* 63 order. They are for groups the repeat for ever. */
00375 
00376   /* The assertions must come before ONCE and COND */
00377 
00378   OP_ASSERT,         /* 64 Positive lookahead */
00379   OP_ASSERT_NOT,     /* 65 Negative lookahead */
00380   OP_ASSERTBACK,     /* 66 Positive lookbehind */
00381   OP_ASSERTBACK_NOT, /* 67 Negative lookbehind */
00382   OP_REVERSE,        /* 68 Move pointer back - used in lookbehind assertions */
00383 
00384   /* ONCE and COND must come after the assertions, with ONCE first, as there's
00385   a test for >= ONCE for a subpattern that isn't an assertion. */
00386 
00387   OP_ONCE,           /* 69 Once matched, don't back up into the subpattern */
00388   OP_COND,           /* 70 Conditional group */
00389   OP_CREF,           /* 71 Used to hold an extraction string number (cond ref) */
00390 
00391   OP_BRAZERO,        /* 72 These two must remain together and in this */
00392   OP_BRAMINZERO,     /* 73 order. */
00393 
00394   OP_BRANUMBER,      /* 74 Used for extracting brackets whose number is greater
00395                            than can fit into an opcode. */
00396 
00397   OP_BRA             /* 75 This and greater values are used for brackets that
00398                            extract substrings up to a basic limit. After that,
00399                            use is made of OP_BRANUMBER. */
00400 };
00401 
00402 /* WARNING: There is an implicit assumption in study.c that all opcodes are
00403 less than 128 in value. This makes handling UTF-8 character sequences easier.
00404 */
00405 
00406 
00407 /* This macro defines textual names for all the opcodes. There are used only
00408 for debugging, in pcre.c when DEBUG is defined, and also in pcretest.c. The
00409 macro is referenced only in printint.c. */
00410 
00411 #define OP_NAME_LIST \
00412   "End", "\\A", "\\G", "\\B", "\\b", "\\D", "\\d",                \
00413   "\\S", "\\s", "\\W", "\\w", "Any", "Anybyte", "\\Z", "\\z",     \
00414   "Opt", "^", "$", "chars", "not",                                \
00415   "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \
00416   "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \
00417   "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \
00418   "*", "*?", "+", "+?", "?", "??", "{", "{",                      \
00419   "class", "nclass", "xclass", "Ref", "Recurse", "Callout",       \
00420   "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not",     \
00421   "AssertB", "AssertB not", "Reverse", "Once", "Cond", "Cond ref",\
00422   "Brazero", "Braminzero", "Branumber", "Bra"
00423 
00424 
00425 /* This macro defines the length of fixed length operations in the compiled
00426 regex. The lengths are used when searching for specific things, and also in the
00427 debugging printing of a compiled regex. We use a macro so that it can be
00428 incorporated both into pcre.c and pcretest.c without being publicly exposed.
00429 
00430 As things have been extended, some of these are no longer fixed lenths, but are
00431 minima instead. For example, the length of a single-character repeat may vary
00432 in UTF-8 mode. The code that uses this table must know about such things. */
00433 
00434 #define OP_LENGTHS \
00435   1,                             /* End                                    */ \
00436   1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* \A, \G, \B, \B, \D, \d, \S, \s, \W, \w */ \
00437   1, 1, 1, 1, 2, 1, 1,           /* Any, Anybyte, \Z, \z, Opt, ^, $        */ \
00438   2,                             /* Chars - the minimum length             */ \
00439   2,                             /* not                                    */ \
00440   /* Positive single-char repeats                                          */ \
00441   2, 2, 2, 2, 2, 2,              /* *, *?, +, +?, ?, ??      ** These are  */ \
00442   4, 4, 4,                       /* upto, minupto, exact     ** minima     */ \
00443   /* Negative single-char repeats                                          */ \
00444   2, 2, 2, 2, 2, 2,              /* NOT *, *?, +, +?, ?, ??                */ \
00445   4, 4, 4,                       /* NOT upto, minupto, exact               */ \
00446   /* Positive type repeats                                                 */ \
00447   2, 2, 2, 2, 2, 2,              /* Type *, *?, +, +?, ?, ??               */ \
00448   4, 4, 4,                       /* Type upto, minupto, exact              */ \
00449   /* Character class & ref repeats                                         */ \
00450   1, 1, 1, 1, 1, 1,              /* *, *?, +, +?, ?, ??                    */ \
00451   5, 5,                          /* CRRANGE, CRMINRANGE                    */ \
00452  33,                             /* CLASS                                  */ \
00453  33,                             /* NCLASS                                 */ \
00454   0,                             /* XCLASS - variable length               */ \
00455   3,                             /* REF                                    */ \
00456   1+LINK_SIZE,                   /* RECURSE                                */ \
00457   2,                             /* CALLOUT                                */ \
00458   1+LINK_SIZE,                   /* Alt                                    */ \
00459   1+LINK_SIZE,                   /* Ket                                    */ \
00460   1+LINK_SIZE,                   /* KetRmax                                */ \
00461   1+LINK_SIZE,                   /* KetRmin                                */ \
00462   1+LINK_SIZE,                   /* Assert                                 */ \
00463   1+LINK_SIZE,                   /* Assert not                             */ \
00464   1+LINK_SIZE,                   /* Assert behind                          */ \
00465   1+LINK_SIZE,                   /* Assert behind not                      */ \
00466   1+LINK_SIZE,                   /* Reverse                                */ \
00467   1+LINK_SIZE,                   /* Once                                   */ \
00468   1+LINK_SIZE,                   /* COND                                   */ \
00469   3,                             /* CREF                                   */ \
00470   1, 1,                          /* BRAZERO, BRAMINZERO                    */ \
00471   3,                             /* BRANUMBER                              */ \
00472   1+LINK_SIZE                    /* BRA                                    */ \
00473 
00474 
00475 /* The highest extraction number before we have to start using additional
00476 bytes. (Originally PCRE didn't have support for extraction counts highter than
00477 this number.) The value is limited by the number of opcodes left after OP_BRA,
00478 i.e. 255 - OP_BRA. We actually set it a bit lower to leave room for additional
00479 opcodes. */
00480 
00481 #define EXTRACT_BASIC_MAX  150
00482 
00483 /* A magic value for OP_CREF to indicate the "in recursion" condition. */
00484 
00485 #define CREF_RECURSE  0xffff
00486 
00487 /* The texts of compile-time error messages are defined as macros here so that
00488 they can be accessed by the POSIX wrapper and converted into error codes.  Yes,
00489 I could have used error codes in the first place, but didn't feel like changing
00490 just to accommodate the POSIX wrapper. */
00491 
00492 #define ERR1  "\\ at end of pattern"
00493 #define ERR2  "\\c at end of pattern"
00494 #define ERR3  "unrecognized character follows \\"
00495 #define ERR4  "numbers out of order in {} quantifier"
00496 #define ERR5  "number too big in {} quantifier"
00497 #define ERR6  "missing terminating ] for character class"
00498 #define ERR7  "invalid escape sequence in character class"
00499 #define ERR8  "range out of order in character class"
00500 #define ERR9  "nothing to repeat"
00501 #define ERR10 "operand of unlimited repeat could match the empty string"
00502 #define ERR11 "internal error: unexpected repeat"
00503 #define ERR12 "unrecognized character after (?"
00504 #define ERR13 "POSIX named classes are supported only within a class"
00505 #define ERR14 "missing )"
00506 #define ERR15 "reference to non-existent subpattern"
00507 #define ERR16 "erroffset passed as NULL"
00508 #define ERR17 "unknown option bit(s) set"
00509 #define ERR18 "missing ) after comment"
00510 #define ERR19 "parentheses nested too deeply"
00511 #define ERR20 "regular expression too large"
00512 #define ERR21 "failed to get memory"
00513 #define ERR22 "unmatched parentheses"
00514 #define ERR23 "internal error: code overflow"
00515 #define ERR24 "unrecognized character after (?<"
00516 #define ERR25 "lookbehind assertion is not fixed length"
00517 #define ERR26 "malformed number after (?("
00518 #define ERR27 "conditional group contains more than two branches"
00519 #define ERR28 "assertion expected after (?("
00520 #define ERR29 "(?R or (?digits must be followed by )"
00521 #define ERR30 "unknown POSIX class name"
00522 #define ERR31 "POSIX collating elements are not supported"
00523 #define ERR32 "this version of PCRE is not compiled with PCRE_UTF8 support"
00524 #define ERR33 "spare error"
00525 #define ERR34 "character value in \\x{...} sequence is too large"
00526 #define ERR35 "invalid condition (?(0)"
00527 #define ERR36 "\\C not allowed in lookbehind assertion"
00528 #define ERR37 "PCRE does not support \\L, \\l, \\N, \\P, \\p, \\U, \\u, or \\X"
00529 #define ERR38 "number after (?C is > 255"
00530 #define ERR39 "closing ) for (?C expected"
00531 #define ERR40 "recursive call could loop indefinitely"
00532 #define ERR41 "unrecognized character after (?P"
00533 #define ERR42 "syntax error after (?P"
00534 #define ERR43 "two named groups have the same name"
00535 
00536 /* All character handling must be done as unsigned characters. Otherwise there
00537 are problems with top-bit-set characters and functions such as isspace().
00538 However, we leave the interface to the outside world as char *, because that
00539 should make things easier for callers. We define a short type for unsigned char
00540 to save lots of typing. I tried "uchar", but it causes problems on Digital
00541 Unix, where it is defined in sys/types, so use "uschar" instead. */
00542 
00543 typedef unsigned char uschar;
00544 
00545 /* The real format of the start of the pcre block; the index of names and the
00546 code vector run on as long as necessary after the end. */
00547 
00548 typedef struct real_pcre {
00549   unsigned long int magic_number;
00550   size_t size;                        /* Total that was malloced */
00551   const unsigned char *tables;        /* Pointer to tables */
00552   unsigned long int options;
00553   unsigned short int top_bracket;
00554   unsigned short int top_backref;
00555   unsigned short int first_byte;
00556   unsigned short int req_byte;
00557   unsigned short int name_entry_size; /* Size of any name items; 0 => none */
00558   unsigned short int name_count;      /* Number of name items */
00559 } real_pcre;
00560 
00561 /* The format of the block used to store data from pcre_study(). */
00562 
00563 typedef struct pcre_study_data {
00564   size_t size;                        /* Total that was malloced */
00565   uschar options;
00566   uschar start_bits[32];
00567 } pcre_study_data;
00568 
00569 /* Structure for passing "static" information around between the functions
00570 doing the compiling, so that they are thread-safe. */
00571 
00572 typedef struct compile_data {
00573   const uschar *lcc;            /* Points to lower casing table */
00574   const uschar *fcc;            /* Points to case-flipping table */
00575   const uschar *cbits;          /* Points to character type table */
00576   const uschar *ctypes;         /* Points to table of type maps */
00577   const uschar *start_code;     /* The start of the compiled code */
00578   uschar *name_table;           /* The name/number table */
00579   int  names_found;             /* Number of entries so far */
00580   int  name_entry_size;         /* Size of each entry */
00581   int  top_backref;             /* Maximum back reference */
00582   unsigned int backref_map;     /* Bitmap of low back refs */
00583   int  req_varyopt;             /* "After variable item" flag for reqbyte */
00584 } compile_data;
00585 
00586 /* Structure for maintaining a chain of pointers to the currently incomplete
00587 branches, for testing for left recursion. */
00588 
00589 typedef struct branch_chain {
00590   struct branch_chain *outer;
00591   uschar *current;
00592 } branch_chain;
00593 
00594 /* Structure for items in a linked list that represents an explicit recursive
00595 call within the pattern. */
00596 
00597 typedef struct recursion_info {
00598   struct recursion_info *prev;  /* Previous recursion record (or NULL) */
00599   int group_num;                /* Number of group that was called */
00600   const uschar *after_call;     /* "Return value": points after the call in the expr */
00601   const uschar *save_start;     /* Old value of md->start_match */
00602   int *offset_save;             /* Pointer to start of saved offsets */
00603   int saved_max;                /* Number of saved offsets */
00604 } recursion_info;
00605 
00606 /* Structure for passing "static" information around between the functions
00607 doing the matching, so that they are thread-safe. */
00608 
00609 typedef struct match_data {
00610   unsigned long int match_call_count; /* As it says */
00611   unsigned long int match_limit;/* As it says */
00612   int   *offset_vector;         /* Offset vector */
00613   int    offset_end;            /* One past the end */
00614   int    offset_max;            /* The maximum usable for return data */
00615   const uschar *lcc;            /* Points to lower casing table */
00616   const uschar *ctypes;         /* Points to table of type maps */
00617   BOOL   offset_overflow;       /* Set if too many extractions */
00618   BOOL   notbol;                /* NOTBOL flag */
00619   BOOL   noteol;                /* NOTEOL flag */
00620   BOOL   utf8;                  /* UTF8 flag */
00621   BOOL   endonly;               /* Dollar not before final \n */
00622   BOOL   notempty;              /* Empty string match not wanted */
00623   const uschar *start_code;     /* For use when recursing */
00624   const uschar *start_subject;  /* Start of the subject string */
00625   const uschar *end_subject;    /* End of the subject string */
00626   const uschar *start_match;    /* Start of this match attempt */
00627   const uschar *end_match_ptr;  /* Subject position at end match */
00628   int    end_offset_top;        /* Highwater mark at end of match */
00629   int    capture_last;          /* Most recent capture number */
00630   int    start_offset;          /* The start offset value */
00631   recursion_info *recursive;    /* Linked list of recursion data */
00632   void  *callout_data;          /* To pass back to callouts */
00633 } match_data;
00634 
00635 /* Bit definitions for entries in the pcre_ctypes table. */
00636 
00637 #define ctype_space   0x01
00638 #define ctype_letter  0x02
00639 #define ctype_digit   0x04
00640 #define ctype_xdigit  0x08
00641 #define ctype_word    0x10   /* alphameric or '_' */
00642 #define ctype_meta    0x80   /* regexp meta char or zero (end pattern) */
00643 
00644 /* Offsets for the bitmap tables in pcre_cbits. Each table contains a set
00645 of bits for a class map. Some classes are built by combining these tables. */
00646 
00647 #define cbit_space     0      /* [:space:] or \s */
00648 #define cbit_xdigit   32      /* [:xdigit:] */
00649 #define cbit_digit    64      /* [:digit:] or \d */
00650 #define cbit_upper    96      /* [:upper:] */
00651 #define cbit_lower   128      /* [:lower:] */
00652 #define cbit_word    160      /* [:word:] or \w */
00653 #define cbit_graph   192      /* [:graph:] */
00654 #define cbit_print   224      /* [:print:] */
00655 #define cbit_punct   256      /* [:punct:] */
00656 #define cbit_cntrl   288      /* [:cntrl:] */
00657 #define cbit_length  320      /* Length of the cbits table */
00658 
00659 /* Offsets of the various tables from the base tables pointer, and
00660 total length. */
00661 
00662 #define lcc_offset      0
00663 #define fcc_offset    256
00664 #define cbits_offset  512
00665 #define ctypes_offset (cbits_offset + cbit_length)
00666 #define tables_length (ctypes_offset + 256)
00667 
00668 /* Only relevant for the POSIX interface, but defined to make pcre.c work. */
00669 
00670 #define POSIX_MALLOC_THRESHOLD 10 /* 2003-04-23 AR */
00671 
00672 /* End of internal.h */

Generated on Wed May 31 18:19:59 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6