summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-08-04 18:09:38 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-08-04 18:09:38 +0000
commitcce850e4f65d092b5704ab42116f11f5188dd74e (patch)
tree86420e16cde9c0ee15805f5242bff7029ae0921c
parent01485f8b60f6cb9da6ceaaafc3abd52c6f690081 (diff)
downloadperl-cce850e4f65d092b5704ab42116f11f5188dd74e.tar.gz
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. p4raw-id: //depot/perl@11577
-rw-r--r--pp_hot.c2
-rw-r--r--regcomp.c6
-rw-r--r--regcomp.h4
-rw-r--r--regexec.c2
-rw-r--r--regexp.h4
-rwxr-xr-xt/op/pat.t29
6 files changed, 35 insertions, 12 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 9d51b1e3e3..daa1aeed3a 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1328,7 +1328,7 @@ play_it_again:
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);
}
}
diff --git a/regcomp.c b/regcomp.c
index 9e5dcfd65b..2e37633e93 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -2013,8 +2013,6 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
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 @@ tryagain:
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;
diff --git a/regcomp.h b/regcomp.h
index b00edf03cf..bbe3a41399 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -309,8 +309,8 @@ struct regnode_charclass_class { /* has [[:blah:]] classes */
#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
diff --git a/regexec.c b/regexec.c
index 9ce5e6878a..0e690de42f 100644
--- a/regexec.c
+++ b/regexec.c
@@ -414,7 +414,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
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;
diff --git a/regexp.h b/regexp.h
index 6f4b10e878..6217aaabfb 100644
--- a/regexp.h
+++ b/regexp.h
@@ -56,8 +56,8 @@ typedef struct regexp {
#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 */
diff --git a/t/op/pat.t b/t/op/pat.t
index b4f7279691..270d65a2e9 100755
--- a/t/op/pat.t
+++ b/t/op/pat.t
@@ -6,7 +6,7 @@
$| = 1;
-print "1..675\n";
+print "1..683\n";
BEGIN {
chdir 't' if -d 't';
@@ -1952,3 +1952,30 @@ print "ok 674\n";
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";
+