diff options
author | Yves Orton <demerphq@gmail.com> | 2020-01-25 03:55:39 +0100 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2020-02-27 17:39:48 +0000 |
commit | 946d2344c2dc703f5c3e48038c544f40577512fd (patch) | |
tree | b627ca9abe02562d784a9528a4a62c825caa0363 | |
parent | 30107e92e6b907767cdd690d2c930a656d9fec60 (diff) | |
download | perl-946d2344c2dc703f5c3e48038c544f40577512fd.tar.gz |
regcomp.c: restore {} braces to DEBUG_PARSE_r multi-statements
In 15cab4d7052 the if (!SIZE_ONLY) logic was removed from regcomp.c,
but in a few places this was excessively zealous, as the braces were
removed from multiline constructs inside of DEBUG_PARSE_r macros.
EG:
DEBUG_PARSE_r(if (!SIZE_ONLY) {
stuff1;
stuff2;
stuff3;
});
was turned into
DEBUG_PARSE_r(
stuff1;
stuff2;
stuff3;
);
Which means that ONLY the first statement in the block was covered
by the DEBUG_PARSE_r() conditional logic. The conversion should have
been:
DEBUG_PARSE_r({
stuff1;
stuff2;
stuff3;
});
IOW, it was necessary to preserve the {} braces in the macro call.
This silences various forms of debugging that should not be visible
in a plain
use re 'debug';
and should only be visible with something like
use re Debug => 'ALL';
Eg in:
$ ./perl -Ilib -Mre=debug -le'/(foo|bar|baz)/'
Compiling REx "(foo|bar|baz)"
~ tying lastbr BRANCH (9) to ender CLOSE1 (12) offset 3
~ tying lastbr OPEN1 (1) to ender END (14) offset 13
Final program:
1: OPEN1 (3)
3: TRIE-EXACT[bf] (12)
<foo>
<bar>
<baz>
12: CLOSE1 (14)
14: END (0)
stclass AHOCORASICK-EXACT[bf] minlen 3
Freeing REx: "(foo|bar|baz)"
The "~ tying lastbr" lines are of interest pretty much only to
someone working on or maintaining the regex engine and should not
be visible to a casual user, not only because they are ugly but
also because the context to understand them is missing and they
do not help understanding how the regex operates.
(cherry picked from commit d8e1e69d20817fd4b9d94736c97ef585900451a4)
-rw-r--r-- | regcomp.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -12257,7 +12257,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp, U32 depth) } break; } - DEBUG_PARSE_r( + DEBUG_PARSE_r({ DEBUG_PARSE_MSG("lsbr"); regprop(RExC_rx, RExC_mysv1, REGNODE_p(lastbr), NULL, pRExC_state); regprop(RExC_rx, RExC_mysv2, REGNODE_p(ender), NULL, pRExC_state); @@ -12268,7 +12268,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp, U32 depth) (IV)ender, (IV)(ender - lastbr) ); - ); + }); if (! REGTAIL(pRExC_state, lastbr, ender)) { REQUIRE_BRANCHJ(flagp, 0); } @@ -12309,7 +12309,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp, U32 depth) br= PL_regkind[OP(ret_as_regnode)] != BRANCH ? regnext(ret_as_regnode) : ret_as_regnode; - DEBUG_PARSE_r( + DEBUG_PARSE_r({ DEBUG_PARSE_MSG("NADA"); regprop(RExC_rx, RExC_mysv1, ret_as_regnode, NULL, pRExC_state); @@ -12322,7 +12322,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp, U32 depth) (IV)ender, (IV)(ender - ret) ); - ); + }); OP(br)= NOTHING; if (OP(REGNODE_p(ender)) == TAIL) { NEXT_OFF(br)= 0; |