diff options
author | Kenichi Ishigaki <ishigaki@cpan.org> | 2014-12-04 17:50:30 +0900 |
---|---|---|
committer | Kenichi Ishigaki <ishigaki@cpan.org> | 2014-12-04 17:53:21 +0900 |
commit | a575668cb9f8816f55b57564110feb136aacfe31 (patch) | |
tree | c80030b720d12b6293defc1fdc67b017295a7990 /lib/Parse | |
parent | 378a455c32733c971720f99181cd6c947da73fa8 (diff) |
restore overloaded stuff of all the loaded version modules
- instead of the one used as version(.pm)
- RT-100696: Sharing *version:: into Safe compartment breaks version::vpp overloads (haarg++)
Diffstat (limited to 'lib/Parse')
-rw-r--r-- | lib/Parse/PMFile.pm | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/lib/Parse/PMFile.pm b/lib/Parse/PMFile.pm index e0d549b..8fe8739 100644 --- a/lib/Parse/PMFile.pm +++ b/lib/Parse/PMFile.pm @@ -272,24 +272,39 @@ sub _restore_overloaded_stuff { no warnings 'redefine'; # version XS in CPAN - if (version->isa('version::vxs')) { + my $restored; + if ($INC{'version/vxs.pm'}) { *{'version::(""'} = \&version::vxs::stringify; *{'version::(0+'} = \&version::vxs::numify; *{'version::(cmp'} = \&version::vxs::VCMP; *{'version::(<=>'} = \&version::vxs::VCMP; *{'version::(bool'} = \&version::vxs::boolean; + $restored = 1; + } # version PP in CPAN - } elsif (version->isa('version::vpp')) { + if ($INC{'version/vpp.pm'}) { { package # hide from PAUSE charstar; overload->import; } - *{'version::(""'} = \&version::vpp::stringify; - *{'version::(0+'} = \&version::vpp::numify; - *{'version::(cmp'} = \&version::vpp::vcmp; - *{'version::(<=>'} = \&version::vpp::vcmp; - *{'version::(bool'} = \&version::vpp::vbool; + { + package # hide from PAUSE + version::vpp; + overload->import; + } + unless ($restored) { + *{'version::(""'} = \&version::vpp::stringify; + *{'version::(0+'} = \&version::vpp::numify; + *{'version::(cmp'} = \&version::vpp::vcmp; + *{'version::(<=>'} = \&version::vpp::vcmp; + *{'version::(bool'} = \&version::vpp::vbool; + } + *{'version::vpp::(""'} = \&version::vpp::stringify; + *{'version::vpp::(0+'} = \&version::vpp::numify; + *{'version::vpp::(cmp'} = \&version::vpp::vcmp; + *{'version::vpp::(<=>'} = \&version::vpp::vcmp; + *{'version::vpp::(bool'} = \&version::vpp::vbool; *{'charstar::(""'} = \&charstar::thischar; *{'charstar::(0+'} = \&charstar::thischar; *{'charstar::(++'} = \&charstar::increment; @@ -301,8 +316,10 @@ sub _restore_overloaded_stuff { *{'charstar::(<=>'} = \&charstar::spaceship; *{'charstar::(bool'} = \&charstar::thischar; *{'charstar::(='} = \&charstar::clone; + $restored = 1; + } # version in core - } else { + if (!$restored) { *{'version::(""'} = \&version::stringify; *{'version::(0+'} = \&version::numify; *{'version::(cmp'} = \&version::vcmp; |