summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-01-26 20:43:17 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-01-26 20:43:17 -0800
commit7e4f04509c6d4e8d2ed0e31eaf59004e5c930b39 (patch)
tree9a582799ceb6695192fb8324f9b7684a759767cc /mg.c
parentcc88c9aaa7ecb8334614c515caf0da2d5538403b (diff)
downloadperl-7e4f04509c6d4e8d2ed0e31eaf59004e5c930b39.tar.gz
Allow ${^WARNING_BITS} to turn off lexical warnings
Various magical modules copy hints from one scope to another. But copying ${^WARNING_BITS} doesn’t always copy the same hints. If lexi- cal warnings are not on at all, ${^WARNING_BITS} returns a different value depending on the current value of $^W. Setting ${^WARNING_BITS} to its own value when $^W is true will stop $^W from being able to control the warnings in the current compilation scope. Setting ${^WARNING_BITS} to its own value when $^W is false causes even default warnings to be suppressed. This commit makes undef a special value that represents the default state, in which $^W controls warnings.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/mg.c b/mg.c
index b72c74afbf..14e97052da 100644
--- a/mg.c
+++ b/mg.c
@@ -943,11 +943,8 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
sv_setpvn(sv, WARN_NONEstring, WARNsize) ;
}
else if (PL_compiling.cop_warnings == pWARN_STD) {
- sv_setpvn(
- sv,
- (PL_dowarn & G_WARN_ON) ? WARN_ALLstring : WARN_NONEstring,
- WARNsize
- );
+ sv_setsv(sv, &PL_sv_undef);
+ break;
}
else if (PL_compiling.cop_warnings == pWARN_ALL) {
/* Get the bit mask for $warnings::Bits{all}, because
@@ -2665,9 +2662,8 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
}
else if (strEQ(mg->mg_ptr+1, "ARNING_BITS")) {
if ( ! (PL_dowarn & G_WARN_ALL_MASK)) {
- if (!SvPOK(sv) && PL_localizing) {
- sv_setpvn(sv, WARN_NONEstring, WARNsize);
- PL_compiling.cop_warnings = pWARN_NONE;
+ if (!SvPOK(sv)) {
+ PL_compiling.cop_warnings = pWARN_STD;
break;
}
{