5 * Definitions etc. for regexp(3) routines.
7 * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof],
8 * not the System V one.
18 typedef struct regnode regnode;
20 struct reg_substr_data;
24 typedef struct regexp {
28 struct reg_substr_data *substrs;
29 char *precomp; /* pre-compilation regular expression */
30 struct reg_data *data; /* Additional data. */
31 char *subbeg; /* saved or original string
32 so \digit works forever. */
33 U32 *offsets; /* offset annotations 20001228 MJD */
34 I32 sublen; /* Length of string pointed by subbeg */
36 I32 minlen; /* mininum possible length of $& */
37 I32 prelen; /* length of precomp */
38 U32 nparens; /* number of parentheses */
39 U32 lastparen; /* last paren matched */
40 U32 lastcloseparen; /* last paren matched */
41 U32 reganch; /* Internal use only +
42 Tainted information used by regexec? */
43 regnode program[1]; /* Unwarranted chumminess with compiler. */
46 #define ROPT_ANCH (ROPT_ANCH_BOL|ROPT_ANCH_MBOL|ROPT_ANCH_GPOS|ROPT_ANCH_SBOL)
47 #define ROPT_ANCH_SINGLE (ROPT_ANCH_SBOL|ROPT_ANCH_GPOS)
48 #define ROPT_ANCH_BOL 0x00001
49 #define ROPT_ANCH_MBOL 0x00002
50 #define ROPT_ANCH_SBOL 0x00004
51 #define ROPT_ANCH_GPOS 0x00008
52 #define ROPT_SKIP 0x00010
53 #define ROPT_IMPLICIT 0x00020 /* Converted .* to ^.* */
54 #define ROPT_NOSCAN 0x00040 /* Check-string always at start. */
55 #define ROPT_GPOS_SEEN 0x00080
56 #define ROPT_CHECK_ALL 0x00100
57 #define ROPT_LOOKBEHIND_SEEN 0x00200
58 #define ROPT_EVAL_SEEN 0x00400
59 #define ROPT_CANY_SEEN 0x00800
60 #define ROPT_SANY_SEEN ROPT_CANY_SEEN /* src bckwrd cmpt */
62 /* 0xf800 of reganch is used by PMf_COMPILETIME */
64 #define ROPT_UTF8 0x10000
65 #define ROPT_NAUGHTY 0x20000 /* how exponential is this pattern? */
66 #define ROPT_COPY_DONE 0x40000 /* subbeg is a copy of the string */
67 #define ROPT_TAINTED_SEEN 0x80000
69 #define RE_USE_INTUIT_NOML 0x0100000 /* Best to intuit before matching */
70 #define RE_USE_INTUIT_ML 0x0200000
71 #define REINT_AUTORITATIVE_NOML 0x0400000 /* Can trust a positive answer */
72 #define REINT_AUTORITATIVE_ML 0x0800000
73 #define REINT_ONCE_NOML 0x1000000 /* Intuit can succed once only. */
74 #define REINT_ONCE_ML 0x2000000
75 #define RE_INTUIT_ONECHAR 0x4000000
76 #define RE_INTUIT_TAIL 0x8000000
78 #define RE_USE_INTUIT (RE_USE_INTUIT_NOML|RE_USE_INTUIT_ML)
79 #define REINT_AUTORITATIVE (REINT_AUTORITATIVE_NOML|REINT_AUTORITATIVE_ML)
80 #define REINT_ONCE (REINT_ONCE_NOML|REINT_ONCE_ML)
82 #define RX_MATCH_TAINTED(prog) ((prog)->reganch & ROPT_TAINTED_SEEN)
83 #define RX_MATCH_TAINTED_on(prog) ((prog)->reganch |= ROPT_TAINTED_SEEN)
84 #define RX_MATCH_TAINTED_off(prog) ((prog)->reganch &= ~ROPT_TAINTED_SEEN)
85 #define RX_MATCH_TAINTED_set(prog, t) ((t) \
86 ? RX_MATCH_TAINTED_on(prog) \
87 : RX_MATCH_TAINTED_off(prog))
89 #define RX_MATCH_COPIED(prog) ((prog)->reganch & ROPT_COPY_DONE)
90 #define RX_MATCH_COPIED_on(prog) ((prog)->reganch |= ROPT_COPY_DONE)
91 #define RX_MATCH_COPIED_off(prog) ((prog)->reganch &= ~ROPT_COPY_DONE)
92 #define RX_MATCH_COPIED_set(prog,t) ((t) \
93 ? RX_MATCH_COPIED_on(prog) \
94 : RX_MATCH_COPIED_off(prog))
96 #define REXEC_COPY_STR 0x01 /* Need to copy the string. */
97 #define REXEC_CHECKED 0x02 /* check_substr already checked. */
98 #define REXEC_SCREAM 0x04 /* use scream table. */
99 #define REXEC_IGNOREPOS 0x08 /* \G matches at start. */
100 #define REXEC_NOT_FIRST 0x10 /* This is another iteration of //g. */
101 #define REXEC_ML 0x20 /* $* was set. */
103 #define ReREFCNT_inc(re) ((void)(re && re->refcnt++), re)
104 #define ReREFCNT_dec(re) CALLREGFREE(aTHX_ re)
106 #define FBMcf_TAIL_DOLLAR 1
107 #define FBMcf_TAIL_DOLLARM 2
108 #define FBMcf_TAIL_Z 4
109 #define FBMcf_TAIL_z 8
110 #define FBMcf_TAIL (FBMcf_TAIL_DOLLAR|FBMcf_TAIL_DOLLARM|FBMcf_TAIL_Z|FBMcf_TAIL_z)
112 #define FBMrf_MULTILINE 1
114 struct re_scream_pos_data_s;