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

Diff of /code/trunk/pcre_internal.h

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

revision 613 by ph10, Sat Jul 2 16:59:52 2011 UTC revision 723 by ph10, Sat Oct 8 15:55:23 2011 UTC
# Line 7  Line 7 
7  and semantics are as close as possible to those of the Perl 5 language.  and semantics are as close as possible to those of the Perl 5 language.
8    
9                         Written by Philip Hazel                         Written by Philip Hazel
10             Copyright (c) 1997-2010 University of Cambridge             Copyright (c) 1997-2011 University of Cambridge
11    
12  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
13  Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
# Line 594  compatibility. */ Line 594  compatibility. */
594  #define PCRE_STARTLINE     0x0008  /* start after \n for multiline */  #define PCRE_STARTLINE     0x0008  /* start after \n for multiline */
595  #define PCRE_JCHANGED      0x0010  /* j option used in regex */  #define PCRE_JCHANGED      0x0010  /* j option used in regex */
596  #define PCRE_HASCRORLF     0x0020  /* explicit \r or \n in pattern */  #define PCRE_HASCRORLF     0x0020  /* explicit \r or \n in pattern */
597    #define PCRE_HASTHEN       0x0040  /* pattern contains (*THEN) */
598    
599  /* Flags for the "extra" block produced by pcre_study(). */  /* Flags for the "extra" block produced by pcre_study(). */
600    
# Line 624  time, run time, or study time, respectiv Line 625  time, run time, or study time, respectiv
625     PCRE_DFA_RESTART|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \     PCRE_DFA_RESTART|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \
626     PCRE_NO_START_OPTIMIZE)     PCRE_NO_START_OPTIMIZE)
627    
628  #define PUBLIC_STUDY_OPTIONS 0   /* None defined */  #define PUBLIC_STUDY_OPTIONS \
629       PCRE_STUDY_JIT_COMPILE
630    
631  /* Magic number to provide a small check against being handed junk. Also used  /* Magic number to provide a small check against being handed junk. Also used
632  to detect whether a pattern was compiled on a host of different endianness. */  to detect whether a pattern was compiled on a host of different endianness. */
# Line 1448  enum { Line 1450  enum {
1450    /* The assertions must come before BRA, CBRA, ONCE, and COND, and the four    /* The assertions must come before BRA, CBRA, ONCE, and COND, and the four
1451    asserts must remain in order. */    asserts must remain in order. */
1452    
1453    OP_ASSERT,         /* 118 Positive lookahead */    OP_REVERSE,        /* 118 Move pointer back - used in lookbehind assertions */
1454    OP_ASSERT_NOT,     /* 119 Negative lookahead */    OP_ASSERT,         /* 119 Positive lookahead */
1455    OP_ASSERTBACK,     /* 120 Positive lookbehind */    OP_ASSERT_NOT,     /* 120 Negative lookahead */
1456    OP_ASSERTBACK_NOT, /* 121 Negative lookbehind */    OP_ASSERTBACK,     /* 121 Positive lookbehind */
1457    OP_REVERSE,        /* 122 Move pointer back - used in lookbehind assertions */    OP_ASSERTBACK_NOT, /* 122 Negative lookbehind */
1458    
1459    /* ONCE, BRA, BRAPOS, CBRA, CBRAPOS, and COND must come after the assertions,    /* ONCE, ONCE_NC, BRA, BRAPOS, CBRA, CBRAPOS, and COND must come immediately
1460    with ONCE first, as there's a test for >= ONCE for a subpattern that isn't an    after the assertions, with ONCE first, as there's a test for >= ONCE for a
1461    assertion. The POS versions must immediately follow the non-POS versions in    subpattern that isn't an assertion. The POS versions must immediately follow
1462    each case. */    the non-POS versions in each case. */
1463    
1464    OP_ONCE,           /* 123 Atomic group */    OP_ONCE,           /* 123 Atomic group, contains captures */
1465    OP_BRA,            /* 124 Start of non-capturing bracket */    OP_ONCE_NC,        /* 124 Atomic group containing no captures */
1466    OP_BRAPOS,         /* 125 Ditto, with unlimited, possessive repeat */    OP_BRA,            /* 125 Start of non-capturing bracket */
1467    OP_CBRA,           /* 126 Start of capturing bracket */    OP_BRAPOS,         /* 126 Ditto, with unlimited, possessive repeat */
1468    OP_CBRAPOS,        /* 127 Ditto, with unlimited, possessive repeat */    OP_CBRA,           /* 127 Start of capturing bracket */
1469    OP_COND,           /* 128 Conditional group */    OP_CBRAPOS,        /* 128 Ditto, with unlimited, possessive repeat */
1470      OP_COND,           /* 129 Conditional group */
1471    
1472    /* These five must follow the previous five, in the same order. There's a    /* These five must follow the previous five, in the same order. There's a
1473    check for >= SBRA to distinguish the two sets. */    check for >= SBRA to distinguish the two sets. */
1474    
1475    OP_SBRA,           /* 129 Start of non-capturing bracket, check empty  */    OP_SBRA,           /* 130 Start of non-capturing bracket, check empty  */
1476    OP_SBRAPOS,        /* 130 Ditto, with unlimited, possessive repeat */    OP_SBRAPOS,        /* 131 Ditto, with unlimited, possessive repeat */
1477    OP_SCBRA,          /* 131 Start of capturing bracket, check empty */    OP_SCBRA,          /* 132 Start of capturing bracket, check empty */
1478    OP_SCBRAPOS,       /* 132 Ditto, with unlimited, possessive repeat */    OP_SCBRAPOS,       /* 133 Ditto, with unlimited, possessive repeat */
1479    OP_SCOND,          /* 133 Conditional group, check empty */    OP_SCOND,          /* 134 Conditional group, check empty */
1480    
1481    /* The next two pairs must (respectively) be kept together. */    /* The next two pairs must (respectively) be kept together. */
1482    
1483    OP_CREF,           /* 134 Used to hold a capture number as condition */    OP_CREF,           /* 135 Used to hold a capture number as condition */
1484    OP_NCREF,          /* 135 Same, but generated by a name reference*/    OP_NCREF,          /* 136 Same, but generated by a name reference*/
1485    OP_RREF,           /* 136 Used to hold a recursion number as condition */    OP_RREF,           /* 137 Used to hold a recursion number as condition */
1486    OP_NRREF,          /* 137 Same, but generated by a name reference*/    OP_NRREF,          /* 138 Same, but generated by a name reference*/
1487    OP_DEF,            /* 138 The DEFINE condition */    OP_DEF,            /* 139 The DEFINE condition */
1488    
1489    OP_BRAZERO,        /* 139 These two must remain together and in this */    OP_BRAZERO,        /* 140 These two must remain together and in this */
1490    OP_BRAMINZERO,     /* 140 order. */    OP_BRAMINZERO,     /* 141 order. */
1491    OP_BRAPOSZERO,     /* 141 */    OP_BRAPOSZERO,     /* 142 */
1492    
1493    /* These are backtracking control verbs */    /* These are backtracking control verbs */
1494    
1495    OP_MARK,           /* 142 always has an argument */    OP_MARK,           /* 143 always has an argument */
1496    OP_PRUNE,          /* 143 */    OP_PRUNE,          /* 144 */
1497    OP_PRUNE_ARG,      /* 144 same, but with argument */    OP_PRUNE_ARG,      /* 145 same, but with argument */
1498    OP_SKIP,           /* 145 */    OP_SKIP,           /* 146 */
1499    OP_SKIP_ARG,       /* 146 same, but with argument */    OP_SKIP_ARG,       /* 147 same, but with argument */
1500    OP_THEN,           /* 147 */    OP_THEN,           /* 148 */
1501    OP_THEN_ARG,       /* 148 same, but with argument */    OP_THEN_ARG,       /* 149 same, but with argument */
1502    OP_COMMIT,         /* 149 */    OP_COMMIT,         /* 150 */
1503    
1504    /* These are forced failure and success verbs */    /* These are forced failure and success verbs */
1505    
1506    OP_FAIL,           /* 150 */    OP_FAIL,           /* 151 */
1507    OP_ACCEPT,         /* 151 */    OP_ACCEPT,         /* 152 */
1508    OP_ASSERT_ACCEPT,  /* 152 Used inside assertions */    OP_ASSERT_ACCEPT,  /* 153 Used inside assertions */
1509    OP_CLOSE,          /* 153 Used before OP_ACCEPT to close open captures */    OP_CLOSE,          /* 154 Used before OP_ACCEPT to close open captures */
1510    
1511    /* This is used to skip a subpattern with a {0} quantifier */    /* This is used to skip a subpattern with a {0} quantifier */
1512    
1513    OP_SKIPZERO,       /* 154 */    OP_SKIPZERO,       /* 155 */
1514    
1515    /* This is not an opcode, but is used to check that tables indexed by opcode    /* This is not an opcode, but is used to check that tables indexed by opcode
1516    are the correct length, in order to catch updating errors - there have been    are the correct length, in order to catch updating errors - there have been
# Line 1550  some cases doesn't actually use these na Line 1553  some cases doesn't actually use these na
1553    "class", "nclass", "xclass", "Ref", "Refi",                     \    "class", "nclass", "xclass", "Ref", "Refi",                     \
1554    "Recurse", "Callout",                                           \    "Recurse", "Callout",                                           \
1555    "Alt", "Ket", "KetRmax", "KetRmin", "KetRpos",                  \    "Alt", "Ket", "KetRmax", "KetRmin", "KetRpos",                  \
1556    "Assert", "Assert not", "AssertB", "AssertB not", "Reverse",    \    "Reverse", "Assert", "Assert not", "AssertB", "AssertB not",    \
1557    "Once",                                                         \    "Once", "Once_NC",                                              \
1558    "Bra", "BraPos", "CBra", "CBraPos",                             \    "Bra", "BraPos", "CBra", "CBraPos",                             \
1559    "Cond",                                                         \    "Cond",                                                         \
1560    "SBra", "SBraPos", "SCBra", "SCBraPos",                         \    "SBra", "SBraPos", "SCBra", "SCBraPos",                         \
# Line 1619  in UTF-8 mode. The code that uses this t Line 1622  in UTF-8 mode. The code that uses this t
1622    1+LINK_SIZE,                   /* KetRmax                                */ \    1+LINK_SIZE,                   /* KetRmax                                */ \
1623    1+LINK_SIZE,                   /* KetRmin                                */ \    1+LINK_SIZE,                   /* KetRmin                                */ \
1624    1+LINK_SIZE,                   /* KetRpos                                */ \    1+LINK_SIZE,                   /* KetRpos                                */ \
1625      1+LINK_SIZE,                   /* Reverse                                */ \
1626    1+LINK_SIZE,                   /* Assert                                 */ \    1+LINK_SIZE,                   /* Assert                                 */ \
1627    1+LINK_SIZE,                   /* Assert not                             */ \    1+LINK_SIZE,                   /* Assert not                             */ \
1628    1+LINK_SIZE,                   /* Assert behind                          */ \    1+LINK_SIZE,                   /* Assert behind                          */ \
1629    1+LINK_SIZE,                   /* Assert behind not                      */ \    1+LINK_SIZE,                   /* Assert behind not                      */ \
   1+LINK_SIZE,                   /* Reverse                                */ \  
1630    1+LINK_SIZE,                   /* ONCE                                   */ \    1+LINK_SIZE,                   /* ONCE                                   */ \
1631      1+LINK_SIZE,                   /* ONCE_NC                                */ \
1632    1+LINK_SIZE,                   /* BRA                                    */ \    1+LINK_SIZE,                   /* BRA                                    */ \
1633    1+LINK_SIZE,                   /* BRAPOS                                 */ \    1+LINK_SIZE,                   /* BRAPOS                                 */ \
1634    3+LINK_SIZE,                   /* CBRA                                   */ \    3+LINK_SIZE,                   /* CBRA                                   */ \
# Line 1641  in UTF-8 mode. The code that uses this t Line 1645  in UTF-8 mode. The code that uses this t
1645    1, 1, 1,                       /* BRAZERO, BRAMINZERO, BRAPOSZERO        */ \    1, 1, 1,                       /* BRAZERO, BRAMINZERO, BRAPOSZERO        */ \
1646    3, 1, 3,                       /* MARK, PRUNE, PRUNE_ARG                 */ \    3, 1, 3,                       /* MARK, PRUNE, PRUNE_ARG                 */ \
1647    1, 3,                          /* SKIP, SKIP_ARG                         */ \    1, 3,                          /* SKIP, SKIP_ARG                         */ \
1648    1+LINK_SIZE, 3+LINK_SIZE,      /* THEN, THEN_ARG                         */ \    1, 3,                          /* THEN, THEN_ARG                         */ \
1649    1, 1, 1, 1,                    /* COMMIT, FAIL, ACCEPT, ASSERT_ACCEPT    */ \    1, 1, 1, 1,                    /* COMMIT, FAIL, ACCEPT, ASSERT_ACCEPT    */ \
1650    3, 1                           /* CLOSE, SKIPZERO  */    3, 1                           /* CLOSE, SKIPZERO  */
1651    
# Line 1660  enum { ERR0,  ERR1,  ERR2,  ERR3,  ERR4, Line 1664  enum { ERR0,  ERR1,  ERR2,  ERR3,  ERR4,
1664         ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39,         ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39,
1665         ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49,         ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49,
1666         ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59,         ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59,
1667         ERR60, ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERR68,         ERR60, ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERR68, ERR69,
1668         ERRCOUNT };         ERRCOUNT };
1669    
1670  /* The real format of the start of the pcre block; the index of names and the  /* The real format of the start of the pcre block; the index of names and the
# Line 1741  typedef struct compile_data { Line 1745  typedef struct compile_data {
1745    int  final_bracount;          /* Saved value after first pass */    int  final_bracount;          /* Saved value after first pass */
1746    int  top_backref;             /* Maximum back reference */    int  top_backref;             /* Maximum back reference */
1747    unsigned int backref_map;     /* Bitmap of low back refs */    unsigned int backref_map;     /* Bitmap of low back refs */
1748    int  assert_depth;            /* Depth of nested assertions */    int  assert_depth;            /* Depth of nested assertions */
1749    int  external_options;        /* External (initial) options */    int  external_options;        /* External (initial) options */
1750    int  external_flags;          /* External flag bits to be set */    int  external_flags;          /* External flag bits to be set */
1751    int  req_varyopt;             /* "After variable item" flag for reqbyte */    int  req_varyopt;             /* "After variable item" flag for reqbyte */
# Line 1753  typedef struct compile_data { Line 1757  typedef struct compile_data {
1757  } compile_data;  } compile_data;
1758    
1759  /* Structure for maintaining a chain of pointers to the currently incomplete  /* Structure for maintaining a chain of pointers to the currently incomplete
1760  branches, for testing for left recursion. */  branches, for testing for left recursion while compiling. */
1761    
1762  typedef struct branch_chain {  typedef struct branch_chain {
1763    struct branch_chain *outer;    struct branch_chain *outer;
# Line 1761  typedef struct branch_chain { Line 1765  typedef struct branch_chain {
1765  } branch_chain;  } branch_chain;
1766    
1767  /* Structure for items in a linked list that represents an explicit recursive  /* Structure for items in a linked list that represents an explicit recursive
1768  call within the pattern. */  call within the pattern; used by pcre_exec(). */
1769    
1770  typedef struct recursion_info {  typedef struct recursion_info {
1771    struct recursion_info *prevrec; /* Previous recursion record (or NULL) */    struct recursion_info *prevrec; /* Previous recursion record (or NULL) */
1772    int group_num;                /* Number of group that was called */    int group_num;                  /* Number of group that was called */
1773    const uschar *after_call;     /* "Return value": points after the call in the expr */    int *offset_save;               /* Pointer to start of saved offsets */
1774    int *offset_save;             /* Pointer to start of saved offsets */    int saved_max;                  /* Number of saved offsets */
1775    int saved_max;                /* Number of saved offsets */    USPTR subject_position;         /* Position at start of recursion */
   int save_offset_top;          /* Current value of offset_top */  
1776  } recursion_info;  } recursion_info;
1777    
1778    /* A similar structure for pcre_dfa_exec(). */
1779    
1780    typedef struct dfa_recursion_info {
1781      struct dfa_recursion_info *prevrec;
1782      int group_num;
1783      USPTR subject_position;
1784    } dfa_recursion_info;
1785    
1786  /* Structure for building a chain of data for holding the values of the subject  /* Structure for building a chain of data for holding the values of the subject
1787  pointer at the start of each subpattern, so as to detect when an empty string  pointer at the start of each subpattern, so as to detect when an empty string
1788  has been matched by a subpattern - to break infinite loops. */  has been matched by a subpattern - to break infinite loops; used by
1789    pcre_exec(). */
1790    
1791  typedef struct eptrblock {  typedef struct eptrblock {
1792    struct eptrblock *epb_prev;    struct eptrblock *epb_prev;
# Line 1811  typedef struct match_data { Line 1823  typedef struct match_data {
1823    BOOL   notempty_atstart;      /* Empty string match at start not wanted */    BOOL   notempty_atstart;      /* Empty string match at start not wanted */
1824    BOOL   hitend;                /* Hit the end of the subject at some point */    BOOL   hitend;                /* Hit the end of the subject at some point */
1825    BOOL   bsr_anycrlf;           /* \R is just any CRLF, not full Unicode */    BOOL   bsr_anycrlf;           /* \R is just any CRLF, not full Unicode */
1826      BOOL   hasthen;               /* Pattern contains (*THEN) */
1827    const  uschar *start_code;    /* For use when recursing */    const  uschar *start_code;    /* For use when recursing */
1828    USPTR  start_subject;         /* Start of the subject string */    USPTR  start_subject;         /* Start of the subject string */
1829    USPTR  end_subject;           /* End of the subject string */    USPTR  end_subject;           /* End of the subject string */
# Line 1827  typedef struct match_data { Line 1840  typedef struct match_data {
1840    recursion_info *recursive;    /* Linked list of recursion data */    recursion_info *recursive;    /* Linked list of recursion data */
1841    void  *callout_data;          /* To pass back to callouts */    void  *callout_data;          /* To pass back to callouts */
1842    const  uschar *mark;          /* Mark pointer to pass back */    const  uschar *mark;          /* Mark pointer to pass back */
1843      const  uschar *once_target;   /* Where to back up to for atomic groups */
1844  } match_data;  } match_data;
1845    
1846  /* A similar structure is used for the same purpose by the DFA matching  /* A similar structure is used for the same purpose by the DFA matching
1847  functions. */  functions. */
1848    
1849  typedef struct dfa_match_data {  typedef struct dfa_match_data {
1850    const uschar *start_code;     /* Start of the compiled pattern */    const uschar *start_code;      /* Start of the compiled pattern */
1851    const uschar *start_subject;  /* Start of the subject string */    const uschar *start_subject;   /* Start of the subject string */
1852    const uschar *end_subject;    /* End of subject string */    const uschar *end_subject;     /* End of subject string */
1853    const uschar *start_used_ptr; /* Earliest consulted character */    const uschar *start_used_ptr;  /* Earliest consulted character */
1854    const uschar *tables;         /* Character tables */    const uschar *tables;          /* Character tables */
1855    int   start_offset;           /* The start offset value */    int   start_offset;            /* The start offset value */
1856    int   moptions;               /* Match options */    int   moptions;                /* Match options */
1857    int   poptions;               /* Pattern options */    int   poptions;                /* Pattern options */
1858    int    nltype;                /* Newline type */    int    nltype;                 /* Newline type */
1859    int    nllen;                 /* Newline string length */    int    nllen;                  /* Newline string length */
1860    uschar nl[4];                 /* Newline string when fixed */    uschar nl[4];                  /* Newline string when fixed */
1861    void  *callout_data;          /* To pass back to callouts */    void  *callout_data;           /* To pass back to callouts */
1862      dfa_recursion_info *recursive; /* Linked list of recursion data */
1863  } dfa_match_data;  } dfa_match_data;
1864    
1865  /* Bit definitions for entries in the pcre_ctypes table. */  /* Bit definitions for entries in the pcre_ctypes table. */
# Line 1902  extern const int    _pcre_utf8_table2[]; Line 1917  extern const int    _pcre_utf8_table2[];
1917  extern const int    _pcre_utf8_table3[];  extern const int    _pcre_utf8_table3[];
1918  extern const uschar _pcre_utf8_table4[];  extern const uschar _pcre_utf8_table4[];
1919    
1920    #ifdef SUPPORT_JIT
1921    extern const uschar _pcre_utf8_char_sizes[];
1922    #endif
1923    
1924  extern const int    _pcre_utf8_table1_size;  extern const int    _pcre_utf8_table1_size;
1925    
1926  extern const char   _pcre_utt_names[];  extern const char   _pcre_utt_names[];
# Line 1926  extern int           _pcre_valid_utf8(US Line 1945  extern int           _pcre_valid_utf8(US
1945  extern BOOL          _pcre_was_newline(USPTR, int, USPTR, int *, BOOL);  extern BOOL          _pcre_was_newline(USPTR, int, USPTR, int *, BOOL);
1946  extern BOOL          _pcre_xclass(int, const uschar *);  extern BOOL          _pcre_xclass(int, const uschar *);
1947    
1948    #ifdef SUPPORT_JIT
1949    extern void          _pcre_jit_compile(const real_pcre *, pcre_extra *);
1950    extern int           _pcre_jit_exec(const real_pcre *, void *, PCRE_SPTR,
1951                            int, int, int, int, int *, int);
1952    extern void          _pcre_jit_free(void *);
1953    #endif
1954    
1955  /* Unicode character database (UCD) */  /* Unicode character database (UCD) */
1956    
# Line 1939  extern const ucd_record  _pcre_ucd_recor Line 1964  extern const ucd_record  _pcre_ucd_recor
1964  extern const uschar      _pcre_ucd_stage1[];  extern const uschar      _pcre_ucd_stage1[];
1965  extern const pcre_uint16 _pcre_ucd_stage2[];  extern const pcre_uint16 _pcre_ucd_stage2[];
1966  extern const int         _pcre_ucp_gentype[];  extern const int         _pcre_ucp_gentype[];
1967    #ifdef SUPPORT_JIT
1968    extern const int         _pcre_ucp_typerange[];
1969    #endif
1970    
1971  /* UCD access macros */  /* UCD access macros */
1972    

Legend:
Removed from v.613  
changed lines
  Added in v.723

  ViewVC Help
Powered by ViewVC 1.1.5