Commit | Line | Data |
---|---|---|
1db310d0 YO |
1 | |
2 | #ifndef PERL_REGINLINE_H | |
3 | ||
4 | /* | |
5 | - regnext - dig the "next" pointer out of a node | |
6 | */ | |
7 | PERL_STATIC_INLINE | |
8 | regnode * | |
9 | Perl_regnext(pTHX_ const regnode *p) | |
10 | { | |
11 | I32 offset; | |
12 | ||
13 | if (!p) | |
14 | return(NULL); | |
15 | ||
16 | if (OP(p) > REGNODE_MAX) { /* regnode.type is unsigned */ | |
17 | Perl_croak(aTHX_ "Corrupted regexp opcode %d > %d", | |
18 | (int)OP(p), (int)REGNODE_MAX); | |
19 | } | |
20 | ||
1489b465 | 21 | offset = (REGNODE_OFF_BY_ARG(OP(p)) ? ARG(p) : NEXT_OFF(p)); |
1db310d0 YO |
22 | if (offset == 0) |
23 | return(NULL); | |
24 | ||
25 | return(regnode *)(p+offset); | |
26 | } | |
27 | ||
28 | /* | |
29 | - regnode_after - find the node physically following p in memory, | |
30 | taking into account the size of p as determined by OP(p), our | |
31 | sizing data, and possibly the STR_SZ() macro. | |
32 | */ | |
33 | PERL_STATIC_INLINE | |
34 | regnode * | |
35 | Perl_regnode_after(pTHX_ const regnode *p, const bool varies) | |
36 | { | |
37 | assert(p); | |
38 | const U8 op = OP(p); | |
39 | assert(op < REGNODE_MAX); | |
e28d2a35 | 40 | const regnode *ret = p + NODE_STEP_REGNODE + REGNODE_ARG_LEN(op); |
79a585d6 | 41 | if (varies || REGNODE_ARG_LEN_VARIES(op)) |
1db310d0 YO |
42 | ret += STR_SZ(STR_LEN(p)); |
43 | return (regnode *)ret; | |
44 | } | |
45 | ||
46 | /* validate that the passed in node and extra length would match that | |
47 | * returned by regnode_after() */ | |
48 | PERL_STATIC_INLINE | |
49 | bool | |
50 | Perl_check_regnode_after(pTHX_ const regnode *p, const STRLEN extra) | |
51 | { | |
52 | const regnode *nextoper = regnode_after((regnode *)p,FALSE); | |
53 | const regnode *other = REGNODE_AFTER_PLUS(p, extra); | |
54 | if (nextoper != other) { | |
55 | return FALSE; | |
56 | } | |
57 | return TRUE; | |
58 | } | |
59 | ||
60 | #define PERL_REGINLINE_H | |
61 | #endif | |
62 | /* | |
63 | * ex: set ts=8 sts=4 sw=4 et: | |
64 | */ |