In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/c144baaa125e0fe9cca51c4563fd00c448c9b873?hp=79d51b8d94a1a8bcf282ea7b652906d0a4233bfc>

- Log -----------------------------------------------------------------
commit c144baaa125e0fe9cca51c4563fd00c448c9b873
Author: Karl Williamson <[email protected]>
Date:   Mon Sep 30 14:13:57 2013 -0600

    regcomp.c: Fix up confusing comment
    
    This was discussed as part of [perl #120041].

M       regcomp.c

commit 77ebeeba5f5d47be96b3cef485cb98b1c4980510
Author: Karl Williamson <[email protected]>
Date:   Mon Sep 30 14:06:23 2013 -0600

    PATCH: [perl #120041] regcomp.c missing parens and broken STCLASS
    
    This was caused by a problem in commit
    43a64b8b430604bd4d76fd256a5babdccaf0ab2b
    which was masked by problems in commit
    a0dd42312a1f26356d2fdf49656e45b77c2cefb5.
    
    The first commit deleted a line it shouldn't have.  I thought that a
    variable wasn't modified before reaching that line, but it turns out it
    was because another variable is set to point to its address, and was
    modified inside a subroutine call.  The other two lines deleted in the
    first commit are ok to have deleted.
    
    The second commit masked the problems of the first by omitting some
    necessary grouping parentheses, which caused things to not work as
    intended, and we didn't have a good test case in our suite to find this
    problem.  (Thanks to Lukas Mai for spotting the problem and submitting a
    test case.)

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

Summary of changes:
 regcomp.c     | 17 ++++++++++-------
 t/re/re_tests |  2 ++
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/regcomp.c b/regcomp.c
index 18897e5..0ec6a76 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -825,8 +825,10 @@ S_ssc_anything(pTHX_ regnode_ssc *ssc)
 STATIC int
 S_ssc_is_anything(pTHX_ const regnode_ssc *ssc)
 {
-    /* Returns TRUE if the SSC 'ssc' can match the empty string or any code
-     * point */
+    /* Returns TRUE if the SSC 'ssc' can match the empty string and any code
+     * point; FALSE otherwise.  Thus, this is used to see if using 'ssc' buys
+     * us anything: if the function returns TRUE, 'ssc' hasn't been restricted
+     * in any way, so there's no point in using it */
 
     UV start, end;
     bool ret;
@@ -835,7 +837,7 @@ S_ssc_is_anything(pTHX_ const regnode_ssc *ssc)
 
     assert(OP(ssc) == ANYOF_SYNTHETIC);
 
-    if (! ANYOF_FLAGS(ssc) & ANYOF_EMPTY_STRING) {
+    if (! (ANYOF_FLAGS(ssc) & ANYOF_EMPTY_STRING)) {
         return FALSE;
     }
 
@@ -4167,6 +4169,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode 
**scanp,
                        flags &= ~SCF_DO_STCLASS_AND;
                        StructCopy(&this_class, data->start_class, regnode_ssc);
                        flags |= SCF_DO_STCLASS_OR;
+                        ANYOF_FLAGS(data->start_class) |= ANYOF_EMPTY_STRING;
                    }
                } else {                /* Non-zero len */
                    if (flags & SCF_DO_STCLASS_OR) {
@@ -6613,7 +6616,7 @@ reStudy:
 
        if ((!(r->anchored_substr || r->anchored_utf8) || r->anchored_offset)
            && stclass_flag
-           && ! ANYOF_FLAGS(data.start_class) & ANYOF_EMPTY_STRING
+            && ! (ANYOF_FLAGS(data.start_class) & ANYOF_EMPTY_STRING)
            && !ssc_is_anything(data.start_class))
        {
            const U32 n = add_data(pRExC_state, STR_WITH_LEN("f"));
@@ -6687,9 +6690,9 @@ reStudy:
        r->check_substr = r->check_utf8 = r->anchored_substr = r->anchored_utf8
                = r->float_substr = r->float_utf8 = NULL;
 
-       if (! ANYOF_FLAGS(data.start_class) & ANYOF_EMPTY_STRING
-           && !ssc_is_anything(data.start_class))
-       {
+        if (! (ANYOF_FLAGS(data.start_class) & ANYOF_EMPTY_STRING)
+            && ! ssc_is_anything(data.start_class))
+        {
            const U32 n = add_data(pRExC_state, STR_WITH_LEN("f"));
 
             ssc_finalize(pRExC_state, data.start_class);
diff --git a/t/re/re_tests b/t/re/re_tests
index 3c031ff..cf3291d 100644
--- a/t/re/re_tests
+++ b/t/re/re_tests
@@ -1794,6 +1794,8 @@ A+(*PRUNE)BC(?{}) AAABC   y       $&      AAABC
 (?:(a(*SKIP)b)){0}(?:(?1)|ac)  x       n       -       -
 # RT #119073: PCRE regression test: {0} => NOTHING optimization
 (?1)(?:(b)){0} b       y       $&      b
+# RT #120041
+^A*\z          y       $&      
 
 # Keep these lines at the end of the file
 # vim: softtabstop=0 noexpandtab

--
Perl5 Master Repository

Reply via email to