diff options
author | Norbert Preining <norbert@preining.info> | 2024-03-15 03:06:35 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2024-03-15 03:06:35 +0000 |
commit | 12679ab7d3c2a210f4123163671b532b8b55d5f9 (patch) | |
tree | 0060d13467186ad977f4e73488ee20dd6c0017ab /systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/reginline.h | |
parent | 62170822e034fdd3f81de7274835d0d3b0467100 (diff) |
CTAN sync 202403150306
Diffstat (limited to 'systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/reginline.h')
-rwxr-xr-x | systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/reginline.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/reginline.h b/systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/reginline.h new file mode 100755 index 0000000000..fd2a9d1e73 --- /dev/null +++ b/systems/texlive/tlnet/tlpkg/tlperl/lib/CORE/reginline.h @@ -0,0 +1,64 @@ + +#ifndef PERL_REGINLINE_H + +/* + - regnext - dig the "next" pointer out of a node + */ +PERL_STATIC_INLINE +regnode * +Perl_regnext(pTHX_ const regnode *p) +{ + I32 offset; + + if (!p) + return(NULL); + + if (OP(p) > REGNODE_MAX) { /* regnode.type is unsigned */ + Perl_croak(aTHX_ "Corrupted regexp opcode %d > %d", + (int)OP(p), (int)REGNODE_MAX); + } + + offset = (REGNODE_OFF_BY_ARG(OP(p)) ? ARG1u(p) : NEXT_OFF(p)); + if (offset == 0) + return(NULL); + + return(regnode *)(p+offset); +} + +/* + - regnode_after - find the node physically following p in memory, + taking into account the size of p as determined by OP(p), our + sizing data, and possibly the STR_SZ() macro. + */ +PERL_STATIC_INLINE +regnode * +Perl_regnode_after(pTHX_ const regnode *p, const bool varies) +{ + assert(p); + const U8 op = OP(p); + assert(op < REGNODE_MAX); + const regnode *ret = p + NODE_STEP_REGNODE + REGNODE_ARG_LEN(op); + if (varies || REGNODE_ARG_LEN_VARIES(op)) + ret += STR_SZ(STR_LEN(p)); + return (regnode *)ret; +} + +/* validate that the passed in node and extra length would match that + * returned by regnode_after() */ +PERL_STATIC_INLINE +bool +Perl_check_regnode_after(pTHX_ const regnode *p, const STRLEN extra) +{ + const regnode *nextoper = regnode_after((regnode *)p,FALSE); + const regnode *other = REGNODE_AFTER_PLUS(p, extra); + if (nextoper != other) { + return FALSE; + } + return TRUE; +} + +#define PERL_REGINLINE_H +#endif +/* + * ex: set ts=8 sts=4 sw=4 et: + */ |