First working TIEARRAY and other misc tie fixes
[p5sagit/p5-mst-13.2.git] / regexp.h
1 /*    regexp.h
2  */
3
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
11
12 struct regnode {
13     U8  flags;
14     U8  type;
15     U16 next_off;
16 };
17
18 typedef struct regnode regnode;
19
20 struct reg_data {
21     U32 count;
22     U8 *what;
23     void* data[1];
24 };
25
26 typedef struct regexp {
27         I32 refcnt;
28         char **startp;
29         char **endp;
30         regnode *regstclass;
31         I32 minlen;             /* mininum possible length of $& */
32         I32 prelen;             /* length of precomp */
33         U32 nparens;            /* number of parentheses */
34         U32 lastparen;          /* last paren matched */
35         char *precomp;          /* pre-compilation regular expression */
36         char *subbase;          /* saved string so \digit works forever */
37         char *subbeg;           /* same, but not responsible for allocation */
38         char *subend;           /* end of subbase */
39         U16 naughty;            /* how exponential is this pattern? */
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. */
52 } regexp;
53
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)