From: Jarkko Hietaniemi Date: Sun, 9 Mar 2003 10:46:23 +0000 (+0000) Subject: From Inaba Hiroto: the UTF-8 length cache wasn't X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c517dc2b8939cf1b60644570194e6918e1629206;p=p5sagit%2Fp5-mst-13.2.git From Inaba Hiroto: the UTF-8 length cache wasn't updated when fbm_compile() appended a "\n". p4raw-id: //depot/perl@18857 --- diff --git a/t/op/pat.t b/t/op/pat.t index fdc4f9b..54f7d14 100755 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -6,7 +6,7 @@ $| = 1; -print "1..994\n"; +print "1..995\n"; BEGIN { chdir 't' if -d 't'; @@ -3145,5 +3145,8 @@ ok("bbbbac" =~ /$pattern/ && $1 eq 'a', "[perl #3547]"); "[perl #21411] (??{ .. }) corrupts split's stack") } -# last test 994 +{ + ok("\x{100}\n" =~ /\x{100}\n$/, "UTF8 length cache and fbm_compile"); +} +# last test 995 diff --git a/util.c b/util.c index b13a347..40abb48 100644 --- a/util.c +++ b/util.c @@ -357,8 +357,12 @@ Perl_fbm_compile(pTHX_ SV *sv, U32 flags) I32 rarest = 0; U32 frequency = 256; - if (flags & FBMcf_TAIL) + if (flags & FBMcf_TAIL) { + MAGIC *mg = SvUTF8(sv) && SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_utf8) : NULL; sv_catpvn(sv, "\n", 1); /* Taken into account in fbm_instr() */ + if (mg && mg->mg_len >= 0) + mg->mg_len++; + } s = (U8*)SvPV_force(sv, len); (void)SvUPGRADE(sv, SVt_PVBM); if (len == 0) /* TAIL might be on a zero-length string. */