In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/abbca49b1b90bcf8e24c2ddb8423c503c144cbe2?hp=63f7ae8a68df6ebb07a1789dbeb05e7d8d011474>

- Log -----------------------------------------------------------------
commit abbca49b1b90bcf8e24c2ddb8423c503c144cbe2
Author: Yves Orton <[email protected]>
Date:   Sun Sep 10 11:25:18 2017 +0200

    reduce error surface of reginsert, set flags to 0 for inserted node
    
    this means that callers do not have to worry about resetting the flags,
    which reduces the chance of error in using reginsert.

M       regcomp.c

commit 4dc12118f61b997fbd030230665b46e7c40f32d6
Author: Yves Orton <[email protected]>
Date:   Sun Sep 10 10:59:05 2017 +0200

    fix #132017 - OPFAIL insert needs to set flags to 0
    
    why reginsert doesnt do this stuff I dont know.

M       regcomp.c
M       t/re/pat.t
-----------------------------------------------------------------------

Summary of changes:
 regcomp.c  | 11 ++++++-----
 t/re/pat.t |  5 ++++-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/regcomp.c b/regcomp.c
index 5a9e56b080..800b8cdc5e 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -11782,14 +11782,12 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 
*flagp, U32 depth)
            if ((flags&SIMPLE)) {
                 if (min == 0 && max == REG_INFTY) {
                     reginsert(pRExC_state, STAR, ret, depth+1);
-                    ret->flags = 0;
                     MARK_NAUGHTY(4);
                     RExC_seen |= REG_UNBOUNDED_QUANTIFIER_SEEN;
                     goto nest_check;
                 }
                 if (min == 1 && max == REG_INFTY) {
                     reginsert(pRExC_state, PLUS, ret, depth+1);
-                    ret->flags = 0;
                     MARK_NAUGHTY(3);
                     RExC_seen |= REG_UNBOUNDED_QUANTIFIER_SEEN;
                     goto nest_check;
@@ -11902,7 +11900,6 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, 
U32 depth)
         ender = reg_node(pRExC_state, SUCCEED);
         REGTAIL(pRExC_state, ret, ender);
         reginsert(pRExC_state, SUSPEND, ret, depth+1);
-        ret->flags = 0;
         ender = reg_node(pRExC_state, TAIL);
         REGTAIL(pRExC_state, ret, ender);
     }
@@ -18637,6 +18634,7 @@ S_reg2Lanode(pTHX_ RExC_state_t *pRExC_state, const U8 
op, const U32 arg1, const
 * if (PASS2)
 *     NEXT_OFF(orig_emit) = regarglen[OPFAIL] + NODE_STEP_REGNODE;
 *
+* ALSO NOTE - operand->flags will be set to 0 as well.
 */
 STATIC void
 S_reginsert(pTHX_ RExC_state_t *pRExC_state, U8 op, regnode *operand, U32 
depth)
@@ -18710,7 +18708,6 @@ S_reginsert(pTHX_ RExC_state_t *pRExC_state, U8 op, 
regnode *operand, U32 depth)
 #endif
     }
 
-
     place = operand;           /* Op node, where operand used to be. */
 #ifdef RE_TRACK_PATTERN_OFFSETS
     if (RExC_offsets) {         /* MJD */
@@ -18729,6 +18726,7 @@ S_reginsert(pTHX_ RExC_state_t *pRExC_state, U8 op, 
regnode *operand, U32 depth)
     }
 #endif
     src = NEXTOPER(place);
+    place->flags = 0;
     FILL_ADVANCE_NODE(place, op);
     Zero(src, offset, regnode);
 }
@@ -19440,8 +19438,11 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const 
regnode *o, const regmatch_
 
     /* add on the verb argument if there is one */
     if ( ( k == VERB || OP(o) == ACCEPT || OP(o) == OPFAIL ) && o->flags) {
-        Perl_sv_catpvf(aTHX_ sv, ":%" SVf,
+        if ( ARG(o) )
+            Perl_sv_catpvf(aTHX_ sv, ":%" SVf,
                        SVfARG((MUTABLE_SV(progi->data->data[ ARG( o ) ]))));
+        else
+            sv_catpvs(sv, ":NULL");
     }
 #else
     PERL_UNUSED_CONTEXT;
diff --git a/t/re/pat.t b/t/re/pat.t
index cf97ecdf07..ec02bc693a 100644
--- a/t/re/pat.t
+++ b/t/re/pat.t
@@ -23,7 +23,7 @@ BEGIN {
     skip_all('no re module') unless defined &DynaLoader::boot_DynaLoader;
     skip_all_without_unicode_tables();
 
-plan tests => 843;  # Update this when adding/deleting tests.
+plan tests => 844;  # Update this when adding/deleting tests.
 
 run_tests() unless caller;
 
@@ -1931,6 +1931,9 @@ EOP
         pos($text) = 3;
         ok(scalar($text !~ m{(~*=[a-z]=)}g), "RT #131575");
     }
+    {
+        fresh_perl_is('"AA" =~ m/AA{1,0}/','',{},"handle OPFAIL insert 
properly");
+    }
 
 } # End of sub run_tests
 

--
Perl5 Master Repository

Reply via email to