From: Jarkko Hietaniemi Date: Sat, 4 Aug 2001 18:09:38 +0000 (+0000) Subject: Continuation of #11575: SANY_SEEN completely deprecated, X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cce850e4f65d092b5704ab42116f11f5188dd74e;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/pp_hot.c b/pp_hot.c index 9d51b1e..daa1aee 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 9e5dcfd..2e37633 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 b00edf0..bbe3a41 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 9ce5e68..0e690de 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 6f4b10e..6217aaa 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 b4f7279..270d65a 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"; +