Change 11577 by jhi@alpha on 2001/08/04 18:09:38

        Continuation of #11575: SANY_SEEN completely deprecated,
        plus more tests that unearthed a bug in @a = ($utf8 =~ /\C/g),
        plus a fix for the bug.

Affected files ...

... //depot/perl/pp_hot.c#247 edit
... //depot/perl/regcomp.c#223 edit
... //depot/perl/regcomp.h#54 edit
... //depot/perl/regexec.c#179 edit
... //depot/perl/regexp.h#26 edit
... //depot/perl/t/op/pat.t#109 edit

Differences ...

==== //depot/perl/pp_hot.c#247 (text) ====
Index: perl/pp_hot.c
--- perl/pp_hot.c.~1~   Sat Aug  4 12:15:05 2001
+++ perl/pp_hot.c       Sat Aug  4 12:15:05 2001
@@ -1328,7 +1328,7 @@
                len = rx->endp[i] - rx->startp[i];
                s = rx->startp[i] + truebase;
                sv_setpvn(*SP, s, len);
-               if (DO_UTF8(TARG))
+               if (DO_UTF8(TARG) && is_utf8_string((U8*)s, len))
                    SvUTF8_on(*SP);
            }
        }

==== //depot/perl/regcomp.c#223 (text) ====
Index: perl/regcomp.c
--- perl/regcomp.c.~1~  Sat Aug  4 12:15:05 2001
+++ perl/regcomp.c      Sat Aug  4 12:15:05 2001
@@ -2013,8 +2013,6 @@
        r->reganch |= ROPT_LOOKBEHIND_SEEN;
     if (RExC_seen & REG_SEEN_EVAL)
        r->reganch |= ROPT_EVAL_SEEN;
-    if (RExC_seen & REG_SEEN_SANY)
-       r->reganch |= ROPT_SANY_SEEN;
     if (RExC_seen & REG_SEEN_CANY)
        r->reganch |= ROPT_CANY_SEEN;
     Newz(1002, r->startp, RExC_npar, I32);
@@ -2719,10 +2717,8 @@
        break;
     case '.':
        nextchar(pRExC_state);
-       if (RExC_flags16 & PMf_SINGLELINE) {
+       if (RExC_flags16 & PMf_SINGLELINE)
            ret = reg_node(pRExC_state, SANY);
-           RExC_seen |= REG_SEEN_SANY;
-       }
        else
            ret = reg_node(pRExC_state, REG_ANY);
        *flagp |= HASWIDTH|SIMPLE;

==== //depot/perl/regcomp.h#54 (text) ====
Index: perl/regcomp.h
--- perl/regcomp.h.~1~  Sat Aug  4 12:15:05 2001
+++ perl/regcomp.h      Sat Aug  4 12:15:05 2001
@@ -309,8 +309,8 @@
 #define REG_SEEN_LOOKBEHIND     2
 #define REG_SEEN_GPOS           4
 #define REG_SEEN_EVAL           8
-#define REG_SEEN_SANY          16
-#define REG_SEEN_CANY          32
+#define REG_SEEN_CANY          16
+#define REG_SEEN_SANY          REG_SEEN_CANY /* src bckwrd cmpt */
 
 START_EXTERN_C
 

==== //depot/perl/regexec.c#179 (text) ====
Index: perl/regexec.c
--- perl/regexec.c.~1~  Sat Aug  4 12:15:05 2001
+++ perl/regexec.c      Sat Aug  4 12:15:05 2001
@@ -414,7 +414,7 @@
              goto fail;
          }
          if (prog->check_offset_min == prog->check_offset_max &&
-             !(prog->reganch & ROPT_SANY_SEEN)) {
+             !(prog->reganch & ROPT_CANY_SEEN)) {
            /* Substring at constant offset from beg-of-str... */
            I32 slen;
 

==== //depot/perl/regexp.h#26 (text) ====
Index: perl/regexp.h
--- perl/regexp.h.~1~   Sat Aug  4 12:15:05 2001
+++ perl/regexp.h       Sat Aug  4 12:15:05 2001
@@ -56,8 +56,8 @@
 #define ROPT_CHECK_ALL         0x00100
 #define ROPT_LOOKBEHIND_SEEN   0x00200
 #define ROPT_EVAL_SEEN         0x00400
-#define ROPT_SANY_SEEN         0x00800
-#define ROPT_CANY_SEEN         0x01000
+#define ROPT_CANY_SEEN         0x00800
+#define ROPT_SANY_SEEN         ROPT_CANY_SEEN /* src bckwrd cmpt */
 
 /* 0xf800 of reganch is used by PMf_COMPILETIME */
 

==== //depot/perl/t/op/pat.t#109 (xtext) ====
Index: perl/t/op/pat.t
--- perl/t/op/pat.t.~1~ Sat Aug  4 12:15:05 2001
+++ perl/t/op/pat.t     Sat Aug  4 12:15:05 2001
@@ -6,7 +6,7 @@
 
 $| = 1;
 
-print "1..675\n";
+print "1..683\n";
 
 BEGIN {
     chdir 't' if -d 't';
@@ -1952,3 +1952,30 @@
     print "not " unless $#a == 12;
     print "ok 675\n";
 }
+
+@a = ("foo\nbar" =~ /./g);
+print "ok 676\n" if @a == 6 && "@a" eq "f o o b a r";
+
+@a = ("foo\nbar" =~ /./gs);
+print "ok 677\n" if @a == 7 && "@a" eq "f o o \n b a r";
+
+@a = ("foo\nbar" =~ /\C/g);
+print "ok 678\n" if @a == 7 && "@a" eq "f o o \n b a r";
+
+@a = ("foo\nbar" =~ /\C/gs);
+print "ok 679\n" if @a == 7 && "@a" eq "f o o \n b a r";
+
+@a = ("foo\n\x{100}bar" =~ /./g);
+print "ok 680\n" if @a == 7 && "@a" eq "f o o \x{100} b a r";
+
+@a = ("foo\n\x{100}bar" =~ /./gs);
+print "ok 681\n" if @a == 8 && "@a" eq "f o o \n \x{100} b a r";
+
+($a, $b) = map { chr } ord('A') == 65 ? (0xc4, 0x80) : (0x8c, 0x41);
+
+@a = ("foo\n\x{100}bar" =~ /\C/g);
+print "ok 682\n" if @a == 9 && "@a" eq "f o o \n $a $b b a r";
+
+@a = ("foo\n\x{100}bar" =~ /\C/gs);
+print "ok 683\n" if @a == 9 && "@a" eq "f o o \n $a $b b a r";
+
End of Patch.

Reply via email to