Commit | Line | Data |
a0d0e21e |
1 | /* regexp.h |
2 | */ |
3 | |
378cc40b |
4 | /* |
5 | * Definitions etc. for regexp(3) routines. |
6 | * |
7 | * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], |
8 | * not the System V one. |
9 | */ |
10 | |
378cc40b |
11 | |
c277df42 |
12 | struct regnode { |
13 | U8 flags; |
14 | U8 type; |
15 | U16 next_off; |
16 | }; |
17 | |
18 | typedef struct regnode regnode; |
19 | |
378cc40b |
20 | typedef struct regexp { |
c277df42 |
21 | I32 refcnt; |
fe14fcc3 |
22 | char **startp; |
23 | char **endp; |
c277df42 |
24 | regnode *regstclass; |
79072805 |
25 | I32 minlen; /* mininum possible length of $& */ |
26 | I32 prelen; /* length of precomp */ |
a0d0e21e |
27 | U32 nparens; /* number of parentheses */ |
28 | U32 lastparen; /* last paren matched */ |
378cc40b |
29 | char *precomp; /* pre-compilation regular expression */ |
30 | char *subbase; /* saved string so \digit works forever */ |
9ef589d8 |
31 | char *subbeg; /* same, but not responsible for allocation */ |
00bf170e |
32 | char *subend; /* end of subbase */ |
a0d0e21e |
33 | U16 naughty; /* how exponential is this pattern? */ |
c277df42 |
34 | U16 reganch; /* Internal use only + |
35 | Tainted information used by regexec? */ |
36 | SV *anchored_substr; /* Substring at fixed position wrt start. */ |
37 | I32 anchored_offset; /* Position of it. */ |
38 | SV *float_substr; /* Substring at variable position wrt start. */ |
39 | I32 float_min_offset; /* Minimal position of it. */ |
40 | I32 float_max_offset; /* Maximal position of it. */ |
41 | SV *check_substr; /* Substring to check before matching. */ |
42 | I32 check_offset_min; /* Offset of the above. */ |
43 | I32 check_offset_max; /* Offset of the above. */ |
44 | struct reg_data *data; /* Additional data. */ |
45 | regnode program[1]; /* Unwarranted chumminess with compiler. */ |
378cc40b |
46 | } regexp; |
47 | |
c277df42 |
48 | #define ROPT_ANCH (ROPT_ANCH_BOL|ROPT_ANCH_MBOL|ROPT_ANCH_GPOS) |
49 | #define ROPT_ANCH_SINGLE (ROPT_ANCH_BOL|ROPT_ANCH_GPOS) |
50 | #define ROPT_ANCH_BOL 1 |
51 | #define ROPT_ANCH_MBOL 2 |
52 | #define ROPT_ANCH_GPOS 4 |
53 | #define ROPT_SKIP 8 |
54 | #define ROPT_IMPLICIT 0x10 /* Converted .* to ^.* */ |
55 | #define ROPT_NOSCAN 0x20 /* Check-string always at start. */ |
56 | #define ROPT_GPOS_SEEN 0x40 |
57 | #define ROPT_CHECK_ALL 0x80 |
58 | #define ROPT_LOOKBEHIND_SEEN 0x100 |
59 | |
60 | #define ROPT_TAINTED_SEEN 0x8000 |
61 | |
62 | #define RX_MATCH_TAINTED(prog) ((prog)->reganch & ROPT_TAINTED_SEEN) |
63 | #define RX_MATCH_TAINTED_SET(prog, t) ((t) \ |
64 | ? ((prog)->reganch |= ROPT_TAINTED_SEEN) \ |
65 | : ((prog)->reganch &= ~ROPT_TAINTED_SEEN)) |
66 | |
67 | #define REXEC_COPY_STR 1 /* Need to copy the string. */ |
68 | #define REXEC_CHECKED 2 /* check_substr already checked. */ |
69 | |
70 | #define ReREFCNT_inc(re) ((re && re->refcnt++), re) |
71 | #define ReREFCNT_dec(re) pregfree(re) |