summaryrefslogtreecommitdiff
path: root/lib/B
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-12-30 14:09:40 -0700
committerKarl Williamson <khw@cpan.org>2014-12-30 21:18:48 -0700
commit74b899ae3030e8dddc4750668c41c5be0a84e832 (patch)
treed4155727979cb4475f08bede39454cc30b9ad71e /lib/B
parent93e453e286b6102e2a477a52fb042e665fcfecf7 (diff)
downloadperl-74b899ae3030e8dddc4750668c41c5be0a84e832.tar.gz
lib/B/Deparse.pm: Output WARNING_BITS in binary
This binary value was being output as just another string, which would cause the bit patterns that coincidentally coincided with letters to be output as those. This is not portable to EBCDIC, but outputting it as \xXX is, which this commit does. I chose to output in hex instead of octal, as I think that is the more modern thing to do, and it's easier for me to grok the larger values when they are in hex.
Diffstat (limited to 'lib/B')
-rw-r--r--lib/B/Deparse.pm4
-rw-r--r--lib/B/Deparse.t12
2 files changed, 9 insertions, 7 deletions
diff --git a/lib/B/Deparse.pm b/lib/B/Deparse.pm
index 7b4ae77a4d..90793b6634 100644
--- a/lib/B/Deparse.pm
+++ b/lib/B/Deparse.pm
@@ -2026,7 +2026,9 @@ sub declare_warnings {
elsif (($to & WARN_MASK) eq ("\0"x length($to) & WARN_MASK)) {
return $self->keyword("no") . " warnings;\n";
}
- return "BEGIN {\${^WARNING_BITS} = ".perlstring($to)."}\n\cK";
+ return "BEGIN {\${^WARNING_BITS} = \""
+ . join("", map { sprintf("\\x%02x", ord $_) } split "", $to)
+ . "\"}\n\cK";
}
sub declare_hints {
diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t
index 74f37a747e..d7b19c1773 100644
--- a/lib/B/Deparse.t
+++ b/lib/B/Deparse.t
@@ -1857,12 +1857,12 @@ my sub f {}
print f();
>>>>
use feature 'lexical_subs';
-BEGIN {${^WARNING_BITS} = "TUUUUUUUUUUUUTUT\005U\001"}
+BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x54\x05\x55\x01"}
my sub f {
- BEGIN {${^WARNING_BITS} = "TUUUUUUUUUUUUTUT\005\001"}
+ BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x54\x05\x01"}
}
-BEGIN {${^WARNING_BITS} = "TUUUUUUUUUUUUTUT\005\001"}
+BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x54\x05\x01"}
print f();
####
# SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
@@ -1873,13 +1873,13 @@ state sub f {}
print f();
>>>>
use feature 'lexical_subs';
-BEGIN {${^WARNING_BITS} = "TUUUUUUUUUUUUTUT\005U\001"}
+BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x54\x05\x55\x01"}
CORE::state sub f {
- BEGIN {${^WARNING_BITS} = "TUUUUUUUUUUUUTUT\005\001"}
+ BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x54\x05\x01"}
use feature 'state';
}
-BEGIN {${^WARNING_BITS} = "TUUUUUUUUUUUUTUT\005\001"}
+BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x54\x05\x01"}
use feature 'state';
print f();
####