/[pcre]/code/trunk/internal.h
ViewVC logotype

Diff of /code/trunk/internal.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3 by nigel, Sat Feb 24 21:38:01 2007 UTC revision 33 by nigel, Sat Feb 24 21:39:01 2007 UTC
# Line 3  Line 3 
3  *************************************************/  *************************************************/
4    
5    
6  #define PCRE_VERSION       "1.00 18-Nov-1997"  #define PCRE_VERSION       "2.05 21-Apr-1999"
7    
8    
9  /* This is a library of functions to support regular expressions whose syntax  /* This is a library of functions to support regular expressions whose syntax
# Line 12  the file Tech.Notes for some information Line 12  the file Tech.Notes for some information
12    
13  Written by: Philip Hazel <ph10@cam.ac.uk>  Written by: Philip Hazel <ph10@cam.ac.uk>
14    
15             Copyright (c) 1997 University of Cambridge             Copyright (c) 1997-1999 University of Cambridge
16    
17  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
18  Permission is granted to anyone to use this software for any purpose on any  Permission is granted to anyone to use this software for any purpose on any
# Line 28  restrictions: Line 28  restrictions:
28    
29  3. Altered versions must be plainly marked as such, and must not be  3. Altered versions must be plainly marked as such, and must not be
30     misrepresented as being the original software.     misrepresented as being the original software.
31    
32    4. If PCRE is embedded in any software that is released under the GNU
33       General Purpose Licence (GPL), then the terms of that licence shall
34       supersede any condition above with which it is incompatible.
35  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
36  */  */
37    
# Line 38  modules, but which are not relevant to t Line 42  modules, but which are not relevant to t
42  define a macro for memmove() if USE_BCOPY is defined. */  define a macro for memmove() if USE_BCOPY is defined. */
43    
44  #ifdef USE_BCOPY  #ifdef USE_BCOPY
45    #undef  memmove        /* some systems may have a macro */
46  #define memmove(a, b, c) bcopy(b, a, c)  #define memmove(a, b, c) bcopy(b, a, c)
47  #endif  #endif
48    
# Line 45  define a macro for memmove() if USE_BCOP Line 50  define a macro for memmove() if USE_BCOP
50    
51  #include <ctype.h>  #include <ctype.h>
52  #include <limits.h>  #include <limits.h>
 #include <setjmp.h>  
53  #include <stddef.h>  #include <stddef.h>
54  #include <stdio.h>  #include <stdio.h>
55  #include <stdlib.h>  #include <stdlib.h>
56  #include <string.h>  #include <string.h>
57  #include "pcre.h"  #include "pcre.h"
58    
59    /* In case there is no definition of offsetof() provided - though any proper
60    Standard C system should have one. */
61    
62    #ifndef offsetof
63    #define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
64    #endif
65    
66    /* These are the public options that can change during matching. */
67    
68    #define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)
69    
70  /* Private options flags start at the most significant end of the two bytes.  /* Private options flags start at the most significant end of the two bytes.
71  The public options defined in pcre.h start at the least significant end. Make  The public options defined in pcre.h start at the least significant end. Make
72  sure they don't overlap! */  sure they don't overlap! */
73    
74  #define PCRE_FIRSTSET           0x8000  /* first_char is set */  #define PCRE_FIRSTSET           0x8000  /* first_char is set */
75  #define PCRE_STARTLINE          0x4000  /* start after \n for multiline */  #define PCRE_STARTLINE          0x4000  /* start after \n for multiline */
76  #define PCRE_COMPILED_CASELESS  0x2000  /* like it says */  #define PCRE_INGROUP            0x2000  /* compiling inside a group */
77    
78  /* Options for the "extra" block produced by pcre_study(). */  /* Options for the "extra" block produced by pcre_study(). */
79    
80  #define PCRE_STUDY_CASELESS 0x01     /* study was caseless */  #define PCRE_STUDY_MAPPED   0x01     /* a map of starting chars exists */
 #define PCRE_STUDY_MAPPED   0x02     /* a map of starting chars exists */  
81    
82  /* Masks for identifying the public options: all permitted at compile time,  /* Masks for identifying the public options which are permitted at compile
83  only some permitted at run or study time. */  time, run time or study time, respectively. */
84    
85  #define PUBLIC_OPTIONS \  #define PUBLIC_OPTIONS \
86    (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \    (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
87     PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA)     PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY)
88    
89  #define PUBLIC_EXEC_OPTIONS \  #define PUBLIC_EXEC_OPTIONS (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL)
   (PCRE_CASELESS|PCRE_ANCHORED|PCRE_MULTILINE|PCRE_NOTBOL|PCRE_NOTEOL| \  
    PCRE_DOTALL|PCRE_DOLLAR_ENDONLY)  
90    
91  #define PUBLIC_STUDY_OPTIONS (PCRE_CASELESS)  #define PUBLIC_STUDY_OPTIONS 0   /* None defined */
92    
93  /* Magic number to provide a small check against being handed junk. */  /* Magic number to provide a small check against being handed junk. */
94    
95  #define MAGIC_NUMBER  0x50435245   /* 'PCRE' */  #define MAGIC_NUMBER  0x50435245UL   /* 'PCRE' */
96    
97  /* Miscellaneous definitions */  /* Miscellaneous definitions */
98    
# Line 92  typedef int BOOL; Line 104  typedef int BOOL;
104  /* These are escaped items that aren't just an encoding of a particular data  /* These are escaped items that aren't just an encoding of a particular data
105  value such as \n. They must have non-zero values, as check_escape() returns  value such as \n. They must have non-zero values, as check_escape() returns
106  their negation. Also, they must appear in the same order as in the opcode  their negation. Also, they must appear in the same order as in the opcode
107  definitions below, up to ESC_Z. The final one must be ESC_REF as subsequent  definitions below, up to ESC_z. The final one must be ESC_REF as subsequent
108  values are used for \1, \2, \3, etc. There is a test in the code for an escape  values are used for \1, \2, \3, etc. There is a test in the code for an escape
109  greater than ESC_b and less than ESC_X to detect the types that may be  greater than ESC_b and less than ESC_X to detect the types that may be
110  repeated. If any new escapes are put in-between that don't consume a character,  repeated. If any new escapes are put in-between that don't consume a character,
111  that code will have to change. */  that code will have to change. */
112    
113  enum { ESC_A = 1, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W, ESC_w,  enum { ESC_A = 1, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W, ESC_w,
114           ESC_Z, ESC_z, ESC_REF };
                     /* These are not Perl escapes, so can't appear in the */  
        ESC_X,       /* simple table-lookup because they must be conditional */  
                     /* on PCRE_EXTRA. */  
        ESC_Z,  
        ESC_REF };  
115    
116  /* Opcode table: OP_BRA must be last, as all values >= it are used for brackets  /* Opcode table: OP_BRA must be last, as all values >= it are used for brackets
117  that extract substrings. Starting from 1 (i.e. after OP_END), the values up to  that extract substrings. Starting from 1 (i.e. after OP_END), the values up to
118  OP_EOL must correspond in order to the list of escapes immediately above. */  OP_EOD must correspond in order to the list of escapes immediately above. */
119    
120  enum {  enum {
121    OP_END,            /* End of pattern */    OP_END,            /* End of pattern */
# Line 124  enum { Line 131  enum {
131    OP_WHITESPACE,         /* \s */    OP_WHITESPACE,         /* \s */
132    OP_NOT_WORDCHAR,       /* \W */    OP_NOT_WORDCHAR,       /* \W */
133    OP_WORDCHAR,           /* \w */    OP_WORDCHAR,           /* \w */
134    OP_CUT,            /* The analogue of Prolog's "cut" operation (extension) */    OP_EODN,           /* End of data or \n at end of data: \Z. */
135    OP_EOD,            /* End of data: or \Z. This must always be the last    OP_EOD,            /* End of data: \z */
                         of the backslashed meta values. */  
136    
137      OP_OPT,            /* Set runtime options */
138    OP_CIRC,           /* Start of line - varies with multiline switch */    OP_CIRC,           /* Start of line - varies with multiline switch */
139    OP_DOLL,           /* End of line - varies with multiline switch */    OP_DOLL,           /* End of line - varies with multiline switch */
140    OP_ANY,            /* Match any character */    OP_ANY,            /* Match any character */
# Line 181  enum { Line 188  enum {
188    OP_KETRMAX,        /* These two must remain together and in this */    OP_KETRMAX,        /* These two must remain together and in this */
189    OP_KETRMIN,        /* order. They are for groups the repeat for ever. */    OP_KETRMIN,        /* order. They are for groups the repeat for ever. */
190    
191    OP_ASSERT,    /* The assertions must come before ONCE and COND */
192    OP_ASSERT_NOT,  
193      OP_ASSERT,         /* Positive lookahead */
194      OP_ASSERT_NOT,     /* Negative lookahead */
195      OP_ASSERTBACK,     /* Positive lookbehind */
196      OP_ASSERTBACK_NOT, /* Negative lookbehind */
197      OP_REVERSE,        /* Move pointer back - used in lookbehind assertions */
198    
199      /* ONCE and COND must come after the assertions, with ONCE first, as there's
200      a test for >= ONCE for a subpattern that isn't an assertion. */
201    
202    OP_ONCE,           /* Once matched, don't back up into the subpattern */    OP_ONCE,           /* Once matched, don't back up into the subpattern */
203      OP_COND,           /* Conditional group */
204      OP_CREF,           /* Used to hold an extraction string number */
205    
206    OP_BRAZERO,        /* These two must remain together and in this */    OP_BRAZERO,        /* These two must remain together and in this */
207    OP_BRAMINZERO,     /* order. */    OP_BRAMINZERO,     /* order. */
# Line 223  just to accommodate the POSIX wrapper. * Line 241  just to accommodate the POSIX wrapper. *
241  #define ERR19 "too many sets of parentheses"  #define ERR19 "too many sets of parentheses"
242  #define ERR20 "regular expression too large"  #define ERR20 "regular expression too large"
243  #define ERR21 "failed to get memory"  #define ERR21 "failed to get memory"
244  #define ERR22 "unmatched brackets"  #define ERR22 "unmatched parentheses"
245  #define ERR23 "internal error: code overflow"  #define ERR23 "internal error: code overflow"
246    #define ERR24 "unrecognized character after (?<"
247    #define ERR25 "lookbehind assertion is not fixed length"
248    #define ERR26 "malformed number after (?("
249    #define ERR27 "conditional group contains more than two branches"
250    #define ERR28 "assertion expected after (?("
251    
252  /* All character handling must be done as unsigned characters. Otherwise there  /* All character handling must be done as unsigned characters. Otherwise there
253  are problems with top-bit-set characters and functions such as isspace().  are problems with top-bit-set characters and functions such as isspace().
# Line 239  typedef unsigned char uschar; Line 262  typedef unsigned char uschar;
262  runs on as long as necessary after the end. */  runs on as long as necessary after the end. */
263    
264  typedef struct real_pcre {  typedef struct real_pcre {
265    unsigned int  magic_number;    unsigned long int magic_number;
266      const unsigned char *tables;
267    unsigned short int options;    unsigned short int options;
268    unsigned char top_bracket;    unsigned char top_bracket;
269    unsigned char top_backref;    unsigned char top_backref;
# Line 254  typedef struct real_pcre_extra { Line 278  typedef struct real_pcre_extra {
278    unsigned char start_bits[32];    unsigned char start_bits[32];
279  } real_pcre_extra;  } real_pcre_extra;
280    
 /* Global tables from chartables.c */  
281    
282  extern uschar pcre_lcc[];  /* Structure for passing "static" information around between the functions
283  extern uschar pcre_fcc[];  doing the compiling, so that they are thread-safe. */
284  extern uschar pcre_cbits[];  
285  extern uschar pcre_ctypes[];  typedef struct compile_data {
286      const uschar *lcc;            /* Points to lower casing table */
287      const uschar *fcc;            /* Points to case-flippint table */
288      const uschar *cbits;          /* Points to character type table */
289      const uschar *ctypes;         /* Points to table of type maps */
290    } compile_data;
291    
292    /* Structure for passing "static" information around between the functions
293    doing the matching, so that they are thread-safe. */
294    
295    typedef struct match_data {
296      int    errorcode;             /* As it says */
297      int   *offset_vector;         /* Offset vector */
298      int    offset_end;            /* One past the end */
299      int    offset_max;            /* The maximum usable for return data */
300      const uschar *lcc;            /* Points to lower casing table */
301      const uschar *ctypes;         /* Points to table of type maps */
302      BOOL   offset_overflow;       /* Set if too many extractions */
303      BOOL   notbol;                /* NOTBOL flag */
304      BOOL   noteol;                /* NOTEOL flag */
305      BOOL   endonly;               /* Dollar not before final \n */
306      const uschar *start_subject;  /* Start of the subject string */
307      const uschar *end_subject;    /* End of the subject string */
308      const uschar *end_match_ptr;  /* Subject position at end match */
309      int     end_offset_top;       /* Highwater mark at end of match */
310    } match_data;
311    
312  /* Bit definitions for entries in pcre_ctypes[]. */  /* Bit definitions for entries in the pcre_ctypes table. */
313    
314  #define ctype_space   0x01  #define ctype_space   0x01
315  #define ctype_letter  0x02  #define ctype_letter  0x02
# Line 270  extern uschar pcre_ctypes[]; Line 318  extern uschar pcre_ctypes[];
318  #define ctype_word    0x10   /* alphameric or '_' */  #define ctype_word    0x10   /* alphameric or '_' */
319  #define ctype_meta    0x80   /* regexp meta char or zero (end pattern) */  #define ctype_meta    0x80   /* regexp meta char or zero (end pattern) */
320    
321  /* Offsets for the bitmap tables */  /* Offsets for the bitmap tables in pcre_cbits. Each table contains a set
322    of bits for a class map. */
323    
324  #define cbit_digit    0  #define cbit_digit    0      /* for \d */
325  #define cbit_letter  32  #define cbit_word    32      /* for \w */
326  #define cbit_word    64  #define cbit_space   64      /* for \s */
327  #define cbit_space   96  #define cbit_length  96      /* Length of the cbits table */
328  #define cbit_length 128      /* Length of the cbits table */  
329    /* Offsets of the various tables from the base tables pointer, and
330    total length. */
331    
332    #define lcc_offset      0
333    #define fcc_offset    256
334    #define cbits_offset  512
335    #define ctypes_offset (cbits_offset + cbit_length)
336    #define tables_length (ctypes_offset + 256)
337    
338  /* End of internal.h */  /* End of internal.h */

Legend:
Removed from v.3  
changed lines
  Added in v.33

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12