summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2010-09-05 22:03:53 +0200
committerFlorian Ragwitz <rafl@debian.org>2010-09-06 17:20:54 +0200
commit44428a460de2170e69440fb654a61fe89892ba53 (patch)
tree994c19d72e4f73b252d13699fa7e34c26909de71 /gv.c
parentfe642606b197643d481019a0cfe637837c580eff (diff)
downloadperl-44428a460de2170e69440fb654a61fe89892ba53.tar.gz
[perl #76138] perl inadvertently destroys signal handlers as of f746176000
Stop magic applied to $!, %SIG, et al. from applying to similarly- named variables in other packages.
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c71
1 files changed, 50 insertions, 21 deletions
diff --git a/gv.c b/gv.c
index 6f63f4bd8f..72016bf6d5 100644
--- a/gv.c
+++ b/gv.c
@@ -1204,33 +1204,19 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
GvMULTI_on(gv) ;
/* set up magic where warranted */
- if (len > 1) {
-#ifndef EBCDIC
- if (*name > 'V' ) {
- NOOP;
- /* Nothing else to do.
- The compiler will probably turn the switch statement into a
- branch table. Make sure we avoid even that small overhead for
- the common case of lower case variable names. */
- } else
-#endif
- {
+ if (stash != PL_defstash) { /* not the main stash */
+ /* We only have to check for four names here: EXPORT, ISA, OVERLOAD
+ and VERSION. All the others apply only to the main stash. */
+ if (len > 1) {
const char * const name2 = name + 1;
switch (*name) {
- case 'A':
- if (strEQ(name2, "RGV")) {
- IoFLAGS(GvIOn(gv)) |= IOf_ARGV|IOf_START;
- }
- else if (strEQ(name2, "RGVOUT")) {
- GvMULTI_on(gv);
- }
- break;
case 'E':
if (strnEQ(name2, "XPORT", 5))
GvMULTI_on(gv);
break;
case 'I':
- if (strEQ(name2, "SA")) {
+ if (strEQ(name2, "SA"))
+ magicalize_isa: {
AV* const av = GvAVn(gv);
GvMULTI_on(gv);
sv_magic(MUTABLE_SV(av), MUTABLE_SV(gv), PERL_MAGIC_isa,
@@ -1253,12 +1239,55 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
}
break;
case 'O':
- if (strEQ(name2, "VERLOAD")) {
+ if (strEQ(name2, "VERLOAD"))
+ magicalize_overload: {
HV* const hv = GvHVn(gv);
GvMULTI_on(gv);
hv_magic(hv, NULL, PERL_MAGIC_overload);
}
break;
+ case 'V':
+ if (strEQ(name2, "ERSION"))
+ GvMULTI_on(gv);
+ break;
+ }
+ }
+ }
+ else if (len > 1) {
+#ifndef EBCDIC
+ if (*name > 'V' ) {
+ NOOP;
+ /* Nothing else to do.
+ The compiler will probably turn the switch statement into a
+ branch table. Make sure we avoid even that small overhead for
+ the common case of lower case variable names. */
+ } else
+#endif
+ {
+ const char * const name2 = name + 1;
+ switch (*name) {
+ case 'A':
+ if (strEQ(name2, "RGV")) {
+ IoFLAGS(GvIOn(gv)) |= IOf_ARGV|IOf_START;
+ }
+ else if (strEQ(name2, "RGVOUT")) {
+ GvMULTI_on(gv);
+ }
+ break;
+ case 'E':
+ if (strnEQ(name2, "XPORT", 5))
+ GvMULTI_on(gv);
+ break;
+ case 'I':
+ if (strEQ(name2, "SA")) {
+ goto magicalize_isa;
+ }
+ break;
+ case 'O':
+ if (strEQ(name2, "VERLOAD")) {
+ goto magicalize_overload;
+ }
+ break;
case 'S':
if (strEQ(name2, "IG")) {
HV *hv;