diff options
author | Karl Williamson <khw@cpan.org> | 2014-11-18 17:03:03 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2014-11-20 21:45:18 -0700 |
commit | 3e669301f0a6fa34269f0e1eaf1fbbd72cae498a (patch) | |
tree | beee9d02aa7b2dd05cdc5ecf701a7b0f392aba55 /gv.c | |
parent | ad2de1b2b22db677f46346aac18927b2032d7a68 (diff) | |
download | perl-3e669301f0a6fa34269f0e1eaf1fbbd72cae498a.tar.gz |
Make encoding pragma lexical in scope
The encoding pragma is deprecated, but in the meantime it causes spooky
action at a distance with other modules that it may be combined with.
In these modules, operations such as chr(), ord(), and utf8::upgrade()
will suddenly start doing the wrong thing.
The documentation for 'encoding' has said to call it after loading other
modules, but this may be impractical. This is especially bad with
anything that auto-loads at first use, like \N{} does now for charnames.
There is an issue with combining this with setting the variable
${^ENCODING} directly. The potential for conflicts has always been
there, and remains. This commit introduces a shadow hidden variable,
subservient to ${^ENCODING} (to preserve backwards compatibility) that
has lexical scope validity.
The pod for 'encoding' has been revamped to be more concise, clear, use
more idiomatic English, and to speak from a modern perspective.
Diffstat (limited to 'gv.c')
-rw-r--r-- | gv.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -1846,7 +1846,7 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, } else #endif { - const char * const name2 = name + 1; + const char * name2 = name + 1; switch (*name) { case 'A': if (strEQ(name2, "RGV")) { @@ -1905,6 +1905,9 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, goto magicalize; break; case '\005': /* $^ENCODING */ + if (*name2 == '_') { + name2++; + } if (strEQ(name2, "NCODING")) goto magicalize; break; |