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