In perl.git, the branch maint-5.12 has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/55ce261c3611453a51e365b59ff693fc330f4c5d?hp=e01378a33e10271b58f7345318c9241af28c64f8>

- Log -----------------------------------------------------------------
commit 55ce261c3611453a51e365b59ff693fc330f4c5d
Author: Rafael Garcia-Suarez <[email protected]>
Date:   Fri Apr 9 12:25:54 2010 +0200

    when(scalar) without argument should be a syntax error [perl #74114]

M       op.c

commit 6daa92fd3bab897011f098c559e29da4d873978a
Author: Nicholas Clark <[email protected]>
Date:   Sat Apr 17 20:11:49 2010 +0100

    Fix RT #74290 - regression for labels immediately before string evals.
    
    Fix location identified by Father Chrysostomos, who also offered a patch, 
but
    this patch is more efficient, as it avoids any allocation. Test code based 
on
    his test example.

M       hv.c
M       pp_ctl.c
M       t/op/goto.t

commit 379b40dc8dcedf4e3d5b0883fd2734423b2a076d
Author: Karl Williamson <k...@khw-desktop.(none)>
Date:   Tue Apr 13 21:25:36 2010 -0600

    PATCH: [perl #72998] regex looping
    
    If a character folds to multiple ones in case-insensitive matching,
    it should not match just one of those, or the regular expression can
    loop.  For example, \N{LATIN SMALL LIGATURE FF} folds to 'ff', and so
        "\N{LATIN SMALL LIGATURE FF}" =~ /f+/i
    should match.  Prior to this patch, this function returned that there is
    a match, but left the matching string  pointer at the beginning of the
    "\N{LATIN SMALL LIGATURE FF}" because it doesn't make sense to match
    just half a character, and at this level it doesn't know about the '+'.
    This leaves things in an inconsistent state, with the reporting of a
    match, but the input pointer unchanged, the result of which is a loop.
    
    I don't know how to fix this so that it correctly matches, and there are
    semantic issues with doing so.  For example, if
        "\N{LATIN SMALL LIGATURE FF}" =~ /ff/i
    matches, then one would think that so should
        "\N{LATIN SMALL LIGATURE FF}" =~ /(f)(f)/i
    But $1 and $2 don't really make sense here, since they both refer to the
    half of the same character.
    
    So this patch just returns failure if only a partial character is
    matched.  That leaves things consistent, and solves the problem of
    looping, so that Perl doesn't hang on such a construct, but leaves the
    ultimate solution for another day.

M       t/re/re.t
M       utf8.c
-----------------------------------------------------------------------

Summary of changes:
 hv.c        |    2 ++
 op.c        |    5 +----
 pp_ctl.c    |   13 ++++++++++++-
 t/op/goto.t |   11 ++++++++++-
 t/re/re.t   |   10 +++++++++-
 utf8.c      |    3 ++-
 6 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/hv.c b/hv.c
index 477b11e..89c6456 100644
--- a/hv.c
+++ b/hv.c
@@ -2972,6 +2972,8 @@ Perl_refcounted_he_free(pTHX_ struct refcounted_he *he) {
     }
 }
 
+/* pp_entereval is aware that labels are stored with a key ':' at the top of
+   the linked list.  */
 const char *
 Perl_fetch_cop_label(pTHX_ struct refcounted_he *const chain, STRLEN *len,
                     U32 *flags) {
diff --git a/op.c b/op.c
index 9c94cc8..76eb16f 100644
--- a/op.c
+++ b/op.c
@@ -5282,14 +5282,11 @@ S_looks_like_bool(pTHX_ const OP *o)
             && looks_like_bool(cLOGOPo->op_first->op_sibling));
 
        case OP_NULL:
+       case OP_SCALAR:
            return (
                o->op_flags & OPf_KIDS
            && looks_like_bool(cUNOPo->op_first));
 
-        case OP_SCALAR:
-            return looks_like_bool(cUNOPo->op_first);
-
-
        case OP_ENTERSUB:
 
        case OP_NOT:    case OP_XOR:
diff --git a/pp_ctl.c b/pp_ctl.c
index de34879..72fe93d 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3758,7 +3758,18 @@ PP(pp_entereval)
     if (PL_compiling.cop_hints_hash) {
        Perl_refcounted_he_free(aTHX_ PL_compiling.cop_hints_hash);
     }
-    PL_compiling.cop_hints_hash = PL_curcop->cop_hints_hash;
+    if (Perl_fetch_cop_label(aTHX_ PL_curcop->cop_hints_hash, NULL, NULL)) {
+       /* The label, if present, is the first entry on the chain. So rather
+          than writing a blank label in front of it (which involves an
+          allocation), just use the next entry in the chain.  */
+       PL_compiling.cop_hints_hash
+           = PL_curcop->cop_hints_hash->refcounted_he_next;
+       /* Check the assumption that this removed the label.  */
+       assert(Perl_fetch_cop_label(aTHX_ PL_compiling.cop_hints_hash, NULL,
+                                   NULL) == NULL);
+    }
+    else
+       PL_compiling.cop_hints_hash = PL_curcop->cop_hints_hash;
     if (PL_compiling.cop_hints_hash) {
        HINTS_REFCNT_LOCK;
        PL_compiling.cop_hints_hash->refcounted_he_refcnt++;
diff --git a/t/op/goto.t b/t/op/goto.t
index 5aaf630..0a8aeee 100644
--- a/t/op/goto.t
+++ b/t/op/goto.t
@@ -10,7 +10,7 @@ BEGIN {
 
 use warnings;
 use strict;
-plan tests => 66;
+plan tests => 67;
 our $TODO;
 
 my $deprecated = 0;
@@ -474,3 +474,12 @@ TODO: {
 }
 
 is($deprecated, 0);
+
+#74290
+{
+    my $x;
+    my $y;
+    F1:++$x and eval 'return if ++$y == 10; goto F1;';
+    is($x, 10,
+       'labels outside evals can be distinguished from the start of the eval');
+}
diff --git a/t/re/re.t b/t/re/re.t
index 87965f2..249c6dd 100644
--- a/t/re/re.t
+++ b/t/re/re.t
@@ -51,6 +51,14 @@ if ('1234'=~/(?:(?<A>\d)|(?<C>!))(?<B>\d)(?<A>\d)(?<B>\d)/){
     }
     is(regnames_count(),3);
 }
+
+    { # Keep this test last, as whole script will be interrupted if times out
+        # Bug #72998; this can loop 
+        watchdog(2);
+        eval '"\x{100}\x{FB00}" =~ /\x{100}\N{U+66}+/i';
+        pass("Didn't loop");
+    }
+
 # New tests above this line, don't forget to update the test count below!
-BEGIN { plan tests => 18 }
+BEGIN { plan tests => 19 }
 # No tests here!
diff --git a/utf8.c b/utf8.c
index 9ed0663..1a6077c 100644
--- a/utf8.c
+++ b/utf8.c
@@ -2609,7 +2609,8 @@ Perl_ibcmp_utf8(pTHX_ const char *s1, char **pe1, 
register UV l1, bool u1, const
 
      /* A match is defined by all the scans that specified
       * an explicit length reaching their final goals. */
-     match = (f1 == 0 || p1 == f1) && (f2 == 0 || p2 == f2);
+     match = (n1 == 0 && n2 == 0    /* Must not match partial char; Bug #72998 
*/
+            && (f1 == 0 || p1 == f1) && (f2 == 0 || p2 == f2));
 
      if (match) {
          if (pe1)

--
Perl5 Master Repository

Reply via email to