diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-09-29 18:23:27 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-10-06 13:01:14 -0700 |
commit | affc13fc37d571176c2495208a3a38d42f0052f7 (patch) | |
tree | 1069ee095637bd62e84bc23eaa4214f000f0a48b /toke.c | |
parent | abe837ceb750d111c7eb0b9a23922a2a49d70064 (diff) | |
download | perl-affc13fc37d571176c2495208a3a38d42f0052f7.tar.gz |
toke.c: Take utf8 into account when creating DATA handle
This is based on work from Brian Fraser, but differs from his original
in that it does not require an intermediate SV.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -6952,10 +6952,20 @@ Perl_yylex(pTHX) GV *gv; if (PL_rsfp && (!PL_in_eval || PL_tokenbuf[2] == 'D')) { const char *pname = "main"; + STRLEN plen = 4; + U32 putf8 = 0; if (PL_tokenbuf[2] == 'D') - pname = HvNAME_get(PL_curstash ? PL_curstash : PL_defstash); - gv = gv_fetchpv(Perl_form(aTHX_ "%s::DATA", pname), GV_ADD, - SVt_PVIO); + { + HV * const stash = + PL_curstash ? PL_curstash : PL_defstash; + pname = HvNAME_get(stash); + plen = HvNAMELEN (stash); + if(HvNAMEUTF8(stash)) putf8 = SVf_UTF8; + } + gv = gv_fetchpvn_flags( + Perl_form(aTHX_ "%*s::DATA", (int)plen, pname), + plen+6, GV_ADD|putf8, SVt_PVIO + ); GvMULTI_on(gv); if (!GvIO(gv)) GvIOp(gv) = newIO(); |