summaryrefslogtreecommitdiff
path: root/lib/bigrat.pm
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2007-06-23 10:14:43 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2007-06-23 10:14:43 +0000
commit075d4edd61a9648945541c8a76d8c03d4588400b (patch)
tree016036781878bc1809fe9dc6af234d420d401767 /lib/bigrat.pm
parent60a1aa196c6751722bae1e1ee83a99d0d965146d (diff)
downloadperl-075d4edd61a9648945541c8a76d8c03d4588400b.tar.gz
Tels' patch to defer overloading of hex and oct,
to avoid magic leaking and smoke failures under utf-8 locales p4raw-id: //depot/perl@31450
Diffstat (limited to 'lib/bigrat.pm')
-rw-r--r--lib/bigrat.pm17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/bigrat.pm b/lib/bigrat.pm
index 884e9dab31..a4de1d68f5 100644
--- a/lib/bigrat.pm
+++ b/lib/bigrat.pm
@@ -95,12 +95,12 @@ sub import
$^H{bigrat} = 1; # we are in effect
+ my ($hex,$oct);
# for newer Perls always override hex() and oct() with a lexical version:
if ($] > 5.009004)
{
- no warnings 'redefine';
- *CORE::GLOBAL::oct = \&_oct;
- *CORE::GLOBAL::hex = \&_hex;
+ $oct = \&_oct;
+ $hex = \&_hex;
}
# some defaults
my $lib = ''; my $lib_kind = 'try'; my $upgrade = 'Math::BigFloat';
@@ -151,14 +151,12 @@ sub import
elsif ($_[$i] eq 'hex')
{
splice @a, $j, 1; $j --;
- no warnings 'redefine';
- *CORE::GLOBAL::hex = \&bigint::_hex_global;
+ $hex = \&bigint::_hex_global;
}
elsif ($_[$i] eq 'oct')
{
splice @a, $j, 1; $j --;
- no warnings 'redefine';
- *CORE::GLOBAL::oct = \&bigint::_oct_global;
+ $oct = \&bigint::_oct_global;
}
else
{
@@ -221,6 +219,11 @@ sub import
{
$self->export_to_level(1,$self,@a); # export inf and NaN
}
+ {
+ no warnings 'redefine';
+ *CORE::GLOBAL::oct = $oct if $oct;
+ *CORE::GLOBAL::hex = $hex if $hex;
+ }
}
1;