develooper Front page | perl.perl5.changes | Postings from September 2019

[perl.git] branch blead updated. v5.31.3-142-g2ad8e1fad0

From:
Max Maischein
Date:
September 13, 2019 17:18
Subject:
[perl.git] branch blead updated. v5.31.3-142-g2ad8e1fad0
Message ID:
E1i8pDB-0007oT-H5@git.dc.perl.space
In perl.git, the branch blead has been updated

<https://perl5.git.perl.org/perl.git/commitdiff/2ad8e1fad075936d51f7dd243c81e417a5a6fc00?hp=c7fb625702e97df5bc916d4cbf32b73977676beb>

- Log -----------------------------------------------------------------
commit 2ad8e1fad075936d51f7dd243c81e417a5a6fc00
Author: Max Maischein <corion@corion.net>
Date:   Fri Sep 13 09:21:35 2019 +0200

    Update Scalar-List-Utils from 1.50 to 1.52
    
    This updates the following modules from 1.50 to 1.52:
    
    List::Util
    List::Util::XS
    Scalar::Util
    Sub::Util

-----------------------------------------------------------------------

Summary of changes:
 Porting/Maintainers.pl                     |  2 +-
 cpan/Scalar-List-Utils/ListUtil.xs         | 33 ++++++++++++++++++++++--------
 cpan/Scalar-List-Utils/lib/List/Util.pm    | 12 +++++++++--
 cpan/Scalar-List-Utils/lib/List/Util/XS.pm |  4 ++--
 cpan/Scalar-List-Utils/lib/Scalar/Util.pm  |  8 ++++----
 cpan/Scalar-List-Utils/lib/Sub/Util.pm     | 10 +++++----
 cpan/Scalar-List-Utils/t/pair.t            |  7 ++++++-
 cpan/Scalar-List-Utils/t/subname.t         | 17 ++++++++++++++-
 cpan/Scalar-List-Utils/t/uniq.t            | 25 ++++++++++++++++++++--
 9 files changed, 93 insertions(+), 25 deletions(-)

diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl
index 64cee017cf..80274c29d9 100755
--- a/Porting/Maintainers.pl
+++ b/Porting/Maintainers.pl
@@ -949,7 +949,7 @@ use File::Glob qw(:case);
     },
 
     'Scalar::Util' => {
-        'DISTRIBUTION' => 'PEVANS/Scalar-List-Utils-1.50.tar.gz',
+        'DISTRIBUTION' => 'PEVANS/Scalar-List-Utils-1.52.tar.gz',
         'FILES'        => q[cpan/Scalar-List-Utils],
     },
 
diff --git a/cpan/Scalar-List-Utils/ListUtil.xs b/cpan/Scalar-List-Utils/ListUtil.xs
index 12f98cde19..5998fe6e4e 100644
--- a/cpan/Scalar-List-Utils/ListUtil.xs
+++ b/cpan/Scalar-List-Utils/ListUtil.xs
@@ -1177,12 +1177,20 @@ CODE:
                 /* clone the value so we don't invoke magic again */
                 arg = sv_mortalcopy(arg);
 
-            if(SvUOK(arg))
+            if(SvOK(arg) && !(SvUOK(arg) || SvIOK(arg) || SvNOK(arg))) {
+#if PERL_VERSION >= 8
+                SvIV(arg); /* sets SVf_IOK/SVf_IsUV if it's an integer */
+#else
+                SvNV(arg); /* SvIV() sets SVf_IOK even on floats on 5.6 */
+#endif
+            }
+
+            if(!SvOK(arg) || SvUOK(arg))
                 sv_setpvf(keysv, "%" UVuf, SvUV(arg));
             else if(SvIOK(arg))
                 sv_setpvf(keysv, "%" IVdf, SvIV(arg));
             else
-                sv_setpvf(keysv, "%" NVgf, SvNV(arg));
+                sv_setpvf(keysv, "%.15" NVgf, SvNV(arg));
 #ifdef HV_FETCH_EMPTY_HE
             he = (HE*) hv_common(seen, NULL, SvPVX(keysv), SvCUR(keysv), 0, HV_FETCH_LVALUE | HV_FETCH_EMPTY_HE, NULL, 0);
             if (HeVAL(he))
@@ -1601,15 +1609,18 @@ PPCODE:
     /* under debugger, provide information about sub location */
     if (PL_DBsub && CvGV(cv)) {
         HV* DBsub = GvHV(PL_DBsub);
-        HE* old_data;
+        HE* old_data = NULL;
 
         GV* oldgv = CvGV(cv);
         HV* oldhv = GvSTASH(oldgv);
-        SV* old_full_name = sv_2mortal(newSVpvn_flags(HvNAME(oldhv), HvNAMELEN_get(oldhv), HvNAMEUTF8(oldhv) ? SVf_UTF8 : 0));
-        sv_catpvn(old_full_name, "::", 2);
-        sv_catpvn_flags(old_full_name, GvNAME(oldgv), GvNAMELEN(oldgv), GvNAMEUTF8(oldgv) ? SV_CATUTF8 : SV_CATBYTES);
 
-        old_data = hv_fetch_ent(DBsub, old_full_name, 0, 0);
+        if (oldhv) {
+            SV* old_full_name = sv_2mortal(newSVpvn_flags(HvNAME(oldhv), HvNAMELEN_get(oldhv), HvNAMEUTF8(oldhv) ? SVf_UTF8 : 0));
+            sv_catpvn(old_full_name, "::", 2);
+            sv_catpvn_flags(old_full_name, GvNAME(oldgv), GvNAMELEN(oldgv), GvNAMEUTF8(oldgv) ? SV_CATUTF8 : SV_CATBYTES);
+
+            old_data = hv_fetch_ent(DBsub, old_full_name, 0, 0);
+        }
 
         if (old_data && HeVAL(old_data)) {
             SV* new_full_name = sv_2mortal(newSVpvn_flags(HvNAME(stash), HvNAMELEN_get(stash), HvNAMEUTF8(stash) ? SVf_UTF8 : 0));
@@ -1660,6 +1671,7 @@ subname(code)
 PREINIT:
     CV *cv;
     GV *gv;
+    const char *stashname;
 PPCODE:
     if (!SvROK(code) && SvGMAGICAL(code))
         mg_get(code);
@@ -1670,7 +1682,12 @@ PPCODE:
     if(!(gv = CvGV(cv)))
         XSRETURN(0);
 
-    mPUSHs(newSVpvf("%s::%s", HvNAME(GvSTASH(gv)), GvNAME(gv)));
+    if(GvSTASH(gv))
+        stashname = HvNAME(GvSTASH(gv));
+    else
+        stashname = "__ANON__";
+
+    mPUSHs(newSVpvf("%s::%s", stashname, GvNAME(gv)));
     XSRETURN(1);
 
 BOOT:
diff --git a/cpan/Scalar-List-Utils/lib/List/Util.pm b/cpan/Scalar-List-Utils/lib/List/Util.pm
index b650d3585a..9d6f04f427 100644
--- a/cpan/Scalar-List-Utils/lib/List/Util.pm
+++ b/cpan/Scalar-List-Utils/lib/List/Util.pm
@@ -15,9 +15,9 @@ our @EXPORT_OK  = qw(
   all any first min max minstr maxstr none notall product reduce sum sum0 shuffle uniq uniqnum uniqstr
   head tail pairs unpairs pairkeys pairvalues pairmap pairgrep pairfirst
 );
-our $VERSION    = "1.50";
+our $VERSION    = "1.52";
 our $XS_VERSION = $VERSION;
-$VERSION    = eval $VERSION;
+$VERSION =~ tr/_//d;
 
 require XSLoader;
 XSLoader::load('List::Util', $XS_VERSION);
@@ -38,6 +38,7 @@ sub import
 # For objects returned by pairs()
 sub List::Util::_Pair::key   { shift->[0] }
 sub List::Util::_Pair::value { shift->[1] }
+sub List::Util::_Pair::TO_JSON { [ @{+shift} ] }
 
 =head1 NAME
 
@@ -341,6 +342,9 @@ equivalent:
        ...
     }
 
+Since version C<1.51> they also have a C<TO_JSON> method to ease
+serialisation.
+
 =head2 unpairs
 
     my @kvlist = unpairs @pairs
@@ -557,6 +561,8 @@ entire list of values returned by C<uniqstr> are well-behaved as strings.
 
     my @values = head $size, @list;
 
+I<Since version 1.50.>
+
 Returns the first C<$size> elements from C<@list>. If C<$size> is negative, returns
 all but the last C<$size> elements from C<@list>.
 
@@ -570,6 +576,8 @@ all but the last C<$size> elements from C<@list>.
 
     my @values = tail $size, @list;
 
+I<Since version 1.50.>
+
 Returns the last C<$size> elements from C<@list>. If C<$size> is negative, returns
 all but the first C<$size> elements from C<@list>.
 
diff --git a/cpan/Scalar-List-Utils/lib/List/Util/XS.pm b/cpan/Scalar-List-Utils/lib/List/Util/XS.pm
index c8c066f825..b3095547bb 100644
--- a/cpan/Scalar-List-Utils/lib/List/Util/XS.pm
+++ b/cpan/Scalar-List-Utils/lib/List/Util/XS.pm
@@ -3,8 +3,8 @@ use strict;
 use warnings;
 use List::Util;
 
-our $VERSION = "1.50";       # FIXUP
-$VERSION = eval $VERSION;    # FIXUP
+our $VERSION = "1.52";       # FIXUP
+$VERSION =~ tr/_//d;         # FIXUP
 
 1;
 __END__
diff --git a/cpan/Scalar-List-Utils/lib/Scalar/Util.pm b/cpan/Scalar-List-Utils/lib/Scalar/Util.pm
index 6982158705..c0952bc236 100644
--- a/cpan/Scalar-List-Utils/lib/Scalar/Util.pm
+++ b/cpan/Scalar-List-Utils/lib/Scalar/Util.pm
@@ -17,8 +17,8 @@ our @EXPORT_OK = qw(
   dualvar isdual isvstring looks_like_number openhandle readonly set_prototype
   tainted
 );
-our $VERSION    = "1.50";
-$VERSION   = eval $VERSION;
+our $VERSION    = "1.52";
+$VERSION =~ tr/_//d;
 
 require List::Util; # List::Util loads the XS
 List::Util->VERSION( $VERSION ); # Ensure we got the right XS version (RT#100863)
@@ -276,8 +276,8 @@ L<perlapi/looks_like_number>.
 
     my $fh = openhandle( $fh );
 
-Returns C<$fh> itself if C<$fh> may be used as a filehandle and is open, or is
-is a tied handle. Otherwise C<undef> is returned.
+Returns C<$fh> itself, if C<$fh> may be used as a filehandle and is open, or if
+it is a tied handle. Otherwise C<undef> is returned.
 
     $fh = openhandle(*STDIN);           # \*STDIN
     $fh = openhandle(\*STDIN);          # \*STDIN
diff --git a/cpan/Scalar-List-Utils/lib/Sub/Util.pm b/cpan/Scalar-List-Utils/lib/Sub/Util.pm
index edcc6544f6..d50cc8e555 100644
--- a/cpan/Scalar-List-Utils/lib/Sub/Util.pm
+++ b/cpan/Scalar-List-Utils/lib/Sub/Util.pm
@@ -15,8 +15,8 @@ our @EXPORT_OK = qw(
   subname set_subname
 );
 
-our $VERSION    = "1.50";
-$VERSION   = eval $VERSION;
+our $VERSION    = "1.52";
+$VERSION =~ tr/_//d;
 
 require List::Util; # as it has the XS
 List::Util->VERSION( $VERSION ); # Ensure we got the right XS version (RT#100863)
@@ -95,8 +95,10 @@ I<Since version 1.40.>
 Returns the name of the given C<$code> reference, if it has one. Normal named
 subs will give a fully-qualified name consisting of the package and the
 localname separated by C<::>. Anonymous code references will give C<__ANON__>
-as the localname. If a name has been set using L</set_subname>, this name will
-be returned instead.
+as the localname. If the package the code was compiled in has been deleted
+(e.g. using C<delete_package> from L<Symbol>), C<__ANON__> will be returned as
+the package name. If a name has been set using L</set_subname>, this name will be
+returned instead.
 
 This function was inspired by C<sub_fullname> from L<Sub::Identify>. The
 remaining functions that C<Sub::Identify> implements can easily be emulated
diff --git a/cpan/Scalar-List-Utils/t/pair.t b/cpan/Scalar-List-Utils/t/pair.t
index e65123cc2c..7d7a6a9bb5 100644
--- a/cpan/Scalar-List-Utils/t/pair.t
+++ b/cpan/Scalar-List-Utils/t/pair.t
@@ -3,8 +3,9 @@
 use strict;
 use warnings;
 
-use Test::More tests => 27;
+use Test::More tests => 29;
 use List::Util qw(pairgrep pairfirst pairmap pairs unpairs pairkeys pairvalues);
+use Scalar::Util qw(blessed);
 
 no warnings 'misc'; # avoid "Odd number of elements" warnings most of the time
 
@@ -104,6 +105,10 @@ is_deeply( [ pairs one => 1, two => ],
   my @p = pairs one => 1, two => 2;
   is( $p[0]->key,   "one", 'pairs ->key' );
   is( $p[0]->value, 1,     'pairs ->value' );
+  is_deeply( $p[0]->TO_JSON,
+             [ one => 1 ],
+             'pairs ->TO_JSON' );
+  ok( !blessed($p[0]->TO_JSON) , 'pairs ->TO_JSON is not blessed' );
 }
 
 is_deeply( [ unpairs [ four => 4 ], [ five => 5 ], [ six => 6 ] ],
diff --git a/cpan/Scalar-List-Utils/t/subname.t b/cpan/Scalar-List-Utils/t/subname.t
index 1bf8a9f698..c78a70043f 100644
--- a/cpan/Scalar-List-Utils/t/subname.t
+++ b/cpan/Scalar-List-Utils/t/subname.t
@@ -3,10 +3,11 @@ use warnings;
 
 BEGIN { $^P |= 0x210 }
 
-use Test::More tests => 18;
+use Test::More tests => 21;
 
 use B::Deparse;
 use Sub::Util qw( subname set_subname );
+use Symbol qw( delete_package ) ;
 
 {
   sub localfunc {}
@@ -78,4 +79,18 @@ is($x->(), "main::foo");
     'subname of set_subname');
 }
 
+# this used to segfault
+
+{
+    sub ToDelete::foo {}
+
+    my $foo = \&ToDelete::foo;
+
+    delete_package 'ToDelete';
+
+    is( subname($foo), "$]" >= 5.010 ? '__ANON__::foo' : 'ToDelete::foo', 'subname in deleted package' );
+    ok( set_subname('NewPackage::foo', $foo), 'rename from deleted package' );
+    is( subname($foo), 'NewPackage::foo', 'subname after rename' );
+}
+
 # vim: ft=perl
diff --git a/cpan/Scalar-List-Utils/t/uniq.t b/cpan/Scalar-List-Utils/t/uniq.t
index 8806b8e7d7..8e76f21b9b 100644
--- a/cpan/Scalar-List-Utils/t/uniq.t
+++ b/cpan/Scalar-List-Utils/t/uniq.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 30;
+use Test::More tests => 33;
 use List::Util qw( uniqnum uniqstr uniq );
 
 use Tie::Array;
@@ -75,6 +75,18 @@ is_deeply( [ uniqnum qw( 1 1.1 1.2 1.3 ) ],
            [ 1, 1.1, 1.2, 1.3 ],
            'uniqnum distinguishes floats' );
 
+{
+    my @nums = map $_+0.1, 1e7..1e7+5;
+    is_deeply( [ uniqnum @nums ],
+               [ @nums ],
+               'uniqnum distinguishes large floats' );
+
+    my @strings = map "$_", @nums;
+    is_deeply( [ uniqnum @strings ],
+               [ @strings ],
+               'uniqnum distinguishes large floats (stringified)' );
+}
+
 # Hard to know for sure what an Inf is going to be. Lets make one
 my $Inf = 0 + 1E1000;
 my $NaN;
@@ -84,7 +96,7 @@ is_deeply( [ uniqnum 0, 1, 12345, $Inf, -$Inf, $NaN, 0, $Inf, $NaN ],
            [ 0, 1, 12345, $Inf, -$Inf, $NaN ],
            'uniqnum preserves the special values of +-Inf and Nan' );
 
-{
+SKIP: {
     my $maxuint = ~0;
     my $maxint = ~0 >> 1;
     my $minint = -(~0 >> 1) - 1;
@@ -94,6 +106,15 @@ is_deeply( [ uniqnum 0, 1, 12345, $Inf, -$Inf, $NaN, 0, $Inf, $NaN ],
     is_deeply( [ uniqnum @nums, 1.0 ],
                [ @nums ],
                'uniqnum preserves uniqness of full integer range' );
+
+    my @strs = map "$_", @nums;
+
+    skip( "Perl $] doesn't stringify UV_MAX right ($maxuint)", 1 )
+        if $maxuint !~ /\A[0-9]+\z/;
+
+    is_deeply( [ uniqnum @strs, "1.0" ],
+               [ @strs ],
+               'uniqnum preserves uniqness of full integer range (stringified)' );
 }
 
 {

-- 
Perl5 Master Repository



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About