diff options
author | Yves Orton <demerphq@gmail.com> | 2023-01-09 20:49:12 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2023-01-11 14:28:33 +0100 |
commit | 3f11a2855248134af98ca8d71cf71a3fe736dbae (patch) | |
tree | 7938935c782a5aabed1b392f3b841906d91e167c /regcomp_debug.c | |
parent | 67244d99e1ad05ddedabc8d640ceaf1d5b8e259d (diff) | |
download | perl-3f11a2855248134af98ca8d71cf71a3fe736dbae.tar.gz |
regexec engine - wrap and replace RX_OFFS() with better abstractions
RX_OFFS() exposes a bit too much about how capture buffers are represented.
This adds RX_OFFS_START() and RX_OFFS_END() and RX_OFFS_VALID() to replace
most of the uses of the RX_OFFS() macro or direct access to the rx->off[]
array. (We add RX_OFFSp() for those rare cases that should have direct
access to the array.) This allows us to replace this logic with more
complicated macros in the future. Pretty much anything using RX_OFFS() is
going to be broken by future changes, so changing the define allows us to
track it down easily.
Not all use of the rx->offs[] array are converted; some uses are required
for the regex engine internals, but anything outside of the regex engine
should be using the replacement macros, and most things in the regex internals
should use it also.
Diffstat (limited to 'regcomp_debug.c')
-rw-r--r-- | regcomp_debug.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/regcomp_debug.c b/regcomp_debug.c index c7c42f6941..0b2cc06170 100644 --- a/regcomp_debug.c +++ b/regcomp_debug.c @@ -514,15 +514,15 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o, const regmatch_ } if ( k == REF && reginfo) { U32 n = ARG(o); /* which paren pair */ - I32 ln = prog->offs[n].start; - if (prog->lastparen < n || ln == -1 || prog->offs[n].end == -1) + I32 ln = RXp_OFFS_START(prog,n); + if (prog->lastparen < n || ln == -1 || RXp_OFFS_END(prog,n) == -1) Perl_sv_catpvf(aTHX_ sv, ": FAIL"); - else if (ln == prog->offs[n].end) + else if (ln == RXp_OFFS_END(prog,n)) Perl_sv_catpvf(aTHX_ sv, ": ACCEPT - EMPTY STRING"); else { const char *s = reginfo->strbeg + ln; Perl_sv_catpvf(aTHX_ sv, ": "); - Perl_pv_pretty( aTHX_ sv, s, prog->offs[n].end - prog->offs[n].start, 32, 0, 0, + Perl_pv_pretty( aTHX_ sv, s, RXp_OFFS_END(prog,n) - RXp_OFFS_START(prog,n), 32, 0, 0, PERL_PV_ESCAPE_UNI_DETECT|PERL_PV_PRETTY_NOCLEAR|PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_QUOTE ); } } |