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;
26 struct reg_substr_datum {
32 struct reg_substr_data {
33 struct reg_substr_datum data[3]; /* Actual array */
36 typedef struct regexp {
41 SV *anchored_substr; /* Substring at fixed position wrt start. */
42 I32 anchored_offset; /* Position of it. */
43 SV *float_substr; /* Substring at variable position wrt start. */
44 I32 float_min_offset; /* Minimal position of it. */
45 I32 float_max_offset; /* Maximal position of it. */
46 SV *check_substr; /* Substring to check before matching. */
47 I32 check_offset_min; /* Offset of the above. */
48 I32 check_offset_max; /* Offset of the above. */
50 struct reg_substr_data *substrs;
52 char *precomp; /* pre-compilation regular expression */
53 struct reg_data *data; /* Additional data. */
54 char *subbeg; /* saved or original string
55 so \digit works forever. */
56 I32 sublen; /* Length of string pointed by subbeg */
58 I32 minlen; /* mininum possible length of $& */
59 I32 prelen; /* length of precomp */
60 U32 nparens; /* number of parentheses */
61 U32 lastparen; /* last paren matched */
62 U32 reganch; /* Internal use only +
63 Tainted information used by regexec? */
64 regnode program[1]; /* Unwarranted chumminess with compiler. */
67 #define anchored_substr substrs->data[0].substr
68 #define anchored_offset substrs->data[0].min_offset
69 #define float_substr substrs->data[1].substr
70 #define float_min_offset substrs->data[1].min_offset
71 #define float_max_offset substrs->data[1].max_offset
72 #define check_substr substrs->data[2].substr
73 #define check_offset_min substrs->data[2].min_offset
74 #define check_offset_max substrs->data[2].max_offset
76 #define ROPT_ANCH (ROPT_ANCH_BOL|ROPT_ANCH_MBOL|ROPT_ANCH_GPOS)
77 #define ROPT_ANCH_SINGLE (ROPT_ANCH_BOL|ROPT_ANCH_GPOS)
78 #define ROPT_ANCH_BOL 0x00001
79 #define ROPT_ANCH_MBOL 0x00002
80 #define ROPT_ANCH_GPOS 0x00004
81 #define ROPT_SKIP 0x00008
82 #define ROPT_IMPLICIT 0x00010 /* Converted .* to ^.* */
83 #define ROPT_NOSCAN 0x00020 /* Check-string always at start. */
84 #define ROPT_GPOS_SEEN 0x00040
85 #define ROPT_CHECK_ALL 0x00080
86 #define ROPT_LOOKBEHIND_SEEN 0x00100
87 #define ROPT_EVAL_SEEN 0x00200
88 #define ROPT_TAINTED_SEEN 0x00400
89 #define ROPT_ANCH_SBOL 0x00800
91 /* 0xf800 of reganch is used by PMf_COMPILETIME */
93 #define ROPT_UTF8 0x10000
94 #define ROPT_NAUGHTY 0x20000 /* how exponential is this pattern? */
95 #define ROPT_COPY_DONE 0x40000 /* subbeg is a copy of the string */
97 #define RX_MATCH_TAINTED(prog) ((prog)->reganch & ROPT_TAINTED_SEEN)
98 #define RX_MATCH_TAINTED_on(prog) ((prog)->reganch |= ROPT_TAINTED_SEEN)
99 #define RX_MATCH_TAINTED_off(prog) ((prog)->reganch &= ~ROPT_TAINTED_SEEN)
100 #define RX_MATCH_TAINTED_set(prog, t) ((t) \
101 ? RX_MATCH_TAINTED_on(prog) \
102 : RX_MATCH_TAINTED_off(prog))
104 #define RX_MATCH_COPIED(prog) ((prog)->reganch & ROPT_COPY_DONE)
105 #define RX_MATCH_COPIED_on(prog) ((prog)->reganch |= ROPT_COPY_DONE)
106 #define RX_MATCH_COPIED_off(prog) ((prog)->reganch &= ~ROPT_COPY_DONE)
107 #define RX_MATCH_COPIED_set(prog,t) ((t) \
108 ? RX_MATCH_COPIED_on(prog) \
109 : RX_MATCH_COPIED_off(prog))
111 #define REXEC_COPY_STR 1 /* Need to copy the string. */
112 #define REXEC_CHECKED 2 /* check_substr already checked. */
113 #define REXEC_SCREAM 4 /* use scream table. */
114 #define REXEC_IGNOREPOS 8 /* \G matches at start. */
115 #define REXEC_NOT_FIRST 0x10 /* This is another iteration of //g. */
117 #define ReREFCNT_inc(re) ((re && re->refcnt++), re)
118 #define ReREFCNT_dec(re) pregfree(re)
120 #define FBMcf_TAIL_DOLLAR 1
121 #define FBMcf_TAIL_Z 2
122 #define FBMcf_TAIL_z 4
123 #define FBMcf_TAIL (FBMcf_TAIL_DOLLAR|FBMcf_TAIL_Z|FBMcf_TAIL_z)
125 #define FBMrf_MULTILINE 1