Skip to content

Commit

Permalink
allow vstrings to be handled without B
Browse files Browse the repository at this point in the history
Change the vstring handling to use a fallback when B is not available,
so that vstrings will work under miniperl.
  • Loading branch information
haarg committed Jun 18, 2024
1 parent df35b2c commit bb9d041
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions lib/CPAN/Meta/Requirements/Range.pm
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,26 @@ BEGIN {
# from version::vpp
sub _find_magic_vstring {
my $value = shift;
my $tvalue = '';
require B;
my $sv = B::svref_2object(\$value);
my $magic = ref($sv) eq 'B::PVMG' ? $sv->MAGIC : undef;
while ( $magic ) {
if ( $magic->TYPE eq 'V' ) {
$tvalue = $magic->PTR;
$tvalue =~ s/^v?(.+)$/v$1/;
last;
}
else {
$magic = $magic->MOREMAGIC;
# B may not be available, such as under miniperl
if (eval { require B }) {
my $sv = B::svref_2object(\$value);
my $magic = ref($sv) eq 'B::PVMG' ? $sv->MAGIC : undef;
while ( $magic ) {
if ( $magic->TYPE eq 'V' ) {
my $tvalue = $magic->PTR;
$tvalue =~ s/^v?(.+)$/v$1/;
return $tvalue;
last;
}
else {
$magic = $magic->MOREMAGIC;
}
}
}
return $tvalue;
elsif ((ref \$value) eq 'VSTRING') {
return sprintf 'v%vd', $value;
}
return '';
}

# Perl 5.10.0 didn't have "is_qv" in version.pm
Expand Down

0 comments on commit bb9d041

Please sign in to comment.