develooper Front page | perl.perl5.porters | Postings from September 2011

[perl #92898] (*THEN) broken inside condition subpattern

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
September 24, 2011 06:41
Subject:
[perl #92898] (*THEN) broken inside condition subpattern
Message ID:
rt-3.6.HEAD-4041-1316871695-500.92898-15-0@perl.org
On Sun Sep 18 13:33:28 2011, sprout wrote:
> On Mon Sep 12 06:24:25 2011, ph10@hermes.cam.ac.uk wrote:
> > another oddity of (*THEN).
> > 
> > Pattern: /a+?(*THEN)c/
> > Subject: aaac
> > Result:  Perl 5.012003 matches "aaac" 
> 
> That’s strange. In 5.14 it doesn’t match. I don’t know which is worse.

The change occurred with this commit:

commit d1c771f5a95fddf225347623798f65884aa6eee7
Author: Bram <p5p@perl.wizbit.be>
Date:   Thu Aug 26 13:27:24 2010 +0200

    VERB nodes in the regex engine should NOT be marked as JUMPABLE.
    
    JUMPABLE nodes can be ignored during certain phases of regex execution,
    including ones where backtracking is affected. This change disables this
    behviour so that the VERBS can perform their desired results.
    
    Committer has taken the liberty of modifying the patch so that all
    VERBS are jumped, thus making the JUMPABLE expression a little simpler.
    I have left Bram's change to JUMPABLE intact, but inside of a comment
    for now.
    
    See discussion in thread for [perl #71942] *COMMIT bypasses optimisation
    for futher details.
    
    http://rt.perl.org/rt3/Ticket/Display.html?id=71942
    
    There appears to be room for futher optimisation here
    by moving the JUMPABLE logic to regex-compile time. Currently
    it is arguable that the "optimisation" this patch seeks to avoid
    is actually not an optimisation at all, as it happens OVER AND OVER
    during execution of a match, thus the extra effort might actually
    outweight the benefit, especially on large strings.

diff --git a/regexec.c b/regexec.c
index 35ef8d4..ec4c4b0 100644
--- a/regexec.c
+++ b/regexec.c
@@ -252,7 +252,8 @@
     OP(rn) == EVAL ||   \
     OP(rn) == SUSPEND || OP(rn) == IFMATCH || \
     OP(rn) == PLUS || OP(rn) == MINMOD || \
-    OP(rn) == KEEPS || (PL_regkind[OP(rn)] == VERB) || \
+    OP(rn) == KEEPS || \
+    /*(PL_regkind[OP(rn)] == VERB && OP(rn) != PRUNE && OP(rn) !=
COMMIT && OP(rn) != MARKPOINT && OP(rn) != SKIP && OP(rn) != CUTGROUP) 
|| */\
     (PL_regkind[OP(rn)] == CURLY && ARG1(rn) > 0) \
 )
 #define IS_EXACT(rn) (PL_regkind[OP(rn)] == EXACT)
diff --git a/t/re/pat_advanced.t b/t/re/pat_advanced.t
...snipped...


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About