In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/37bb7629a18d7cb6c4b7296491831c35197edbde?hp=47b13905e23c2a72acdde8bb4669e25e5eaefec4>
- Log ----------------------------------------------------------------- commit 37bb7629a18d7cb6c4b7296491831c35197edbde Author: Eric Brine <ikeg...@adaelis.com> Date: Sat Aug 21 22:17:26 2010 -0700 Avoid needless use of UTF8=1 format [RT#56336] Some literals (e.g. q'abc') don't set the UTF8 flag for pure ASCII literals. Others (e.g. -abc) do. This should be consistent. M lib/utf8.t M toke.c commit 96d9949f9ef2c5c9eb1346746102adfa7f3dfaeb Author: Eric Brine <ikeg...@adaelis.com> Date: Sat Aug 21 20:14:08 2010 -0700 TODO tests for avoid needless use of UTF8=1 format [RT#56336] Some literals (e.g. q'abc') don't set the UTF8 flag for pure ASCII literals. Others (e.g. -abc) do. This should be consistent. M lib/utf8.t ----------------------------------------------------------------------- Summary of changes: lib/utf8.t | 13 ++++++++++++- toke.c | 19 ++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/utf8.t b/lib/utf8.t index a5827f4..0bd06f9 100644 --- a/lib/utf8.t +++ b/lib/utf8.t @@ -37,7 +37,7 @@ no utf8; # Ironic, no? # # -plan tests => 150; +plan tests => 157; { # bug id 20001009.001 @@ -451,3 +451,14 @@ SKIP: { ok(utf8::valid(chr(0x270)), "0x270"); ok(utf8::valid(chr(0x280)), "0x280"); } + +{ + use utf8; + ok( !utf8::is_utf8( "asd" ), "Wasteful format - qq{}" ); + ok( !utf8::is_utf8( 'asd' ), "Wasteful format - q{}" ); + ok( !utf8::is_utf8( qw(asd) ), "Wasteful format - qw{}" ); + ok( !utf8::is_utf8( (asd => 1)[0] ), "Wasteful format - =>" ); + ok( !utf8::is_utf8( asd ), "Wasteful format - bareword" ); + ok( !utf8::is_utf8( -asd ), "Wasteful format - -word" ); + ok( !utf8::is_utf8( asd:: ), "Wasteful format - word::" ); +} diff --git a/toke.c b/toke.c index b8eb11a..42f0103 100644 --- a/toke.c +++ b/toke.c @@ -6290,16 +6290,15 @@ Perl_yylex(pTHX) /* if we saw a global override before, get the right name */ + sv = S_newSV_maybe_utf8(aTHX_ PL_tokenbuf, + len ? len : strlen(PL_tokenbuf)); if (gvp) { + SV * const tmp_sv = sv; sv = newSVpvs("CORE::GLOBAL::"); - sv_catpv(sv,PL_tokenbuf); - } - else { - /* If len is 0, newSVpv does strlen(), which is correct. - If len is non-zero, then it will be the true length, - and so the scalar will be created correctly. */ - sv = newSVpv(PL_tokenbuf,len); + sv_catsv(sv, tmp_sv); + SvREFCNT_dec(tmp_sv); } + #ifdef PERL_MAD if (PL_madskills && !PL_thistoken) { char *start = SvPVX(PL_linestr) + PL_realtokenstart; @@ -6309,17 +6308,11 @@ Perl_yylex(pTHX) #endif /* Presume this is going to be a bareword of some sort. */ - CLINE; pl_yylval.opval = (OP*)newSVOP(OP_CONST, 0, sv); pl_yylval.opval->op_private = OPpCONST_BARE; - /* UTF-8 package name? */ - if (UTF && !IN_BYTES && - is_utf8_string((U8*)SvPVX_const(sv), SvCUR(sv))) - SvUTF8_on(sv); /* And if "Foo::", then that's what it certainly is. */ - if (len) goto safe_bareword; -- Perl5 Master Repository