summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorEric Brine <ikegami@adaelis.com>2010-08-21 22:17:26 -0700
committerRafael Garcia-Suarez <rgs@consttype.org>2010-08-31 00:19:35 +0200
commit37bb7629a18d7cb6c4b7296491831c35197edbde (patch)
tree5d1de89fcd2258e2a35a8fbf7111d84e45fa8b79 /toke.c
parent96d9949f9ef2c5c9eb1346746102adfa7f3dfaeb (diff)
downloadperl-37bb7629a18d7cb6c4b7296491831c35197edbde.tar.gz
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.
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/toke.c b/toke.c
index b8eb11a6ae..42f0103281 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;