Hello community,
here is the log from the commit of package perl-Scalar-List-Utils for
openSUSE:Factory checked in at 2016-03-26 15:27:34
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Scalar-List-Utils (Old)
and /work/SRC/openSUSE:Factory/.perl-Scalar-List-Utils.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Scalar-List-Utils"
Changes:
--------
---
/work/SRC/openSUSE:Factory/perl-Scalar-List-Utils/perl-Scalar-List-Utils.changes
2016-02-17 12:20:31.000000000 +0100
+++
/work/SRC/openSUSE:Factory/.perl-Scalar-List-Utils.new/perl-Scalar-List-Utils.changes
2016-03-26 15:27:37.000000000 +0100
@@ -1,0 +2,12 @@
+Wed Mar 23 11:05:28 UTC 2016 - [email protected]
+
+- updated to 1.44
+ see /usr/share/doc/packages/perl-Scalar-List-Utils/Changes
+
+ 1.44 -- 2016/03/17 23:08:46
+ [CHANGES]
+ * Added List::Util::uniq() and uniqnum()
+ (with thanks to randir and ilmari for assistance writing code and
+ tests)
+
+-------------------------------------------------------------------
Old:
----
Scalar-List-Utils-1.43.tar.gz
New:
----
Scalar-List-Utils-1.44.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Scalar-List-Utils.spec ++++++
--- /var/tmp/diff_new_pack.ksiBI5/_old 2016-03-26 15:27:38.000000000 +0100
+++ /var/tmp/diff_new_pack.ksiBI5/_new 2016-03-26 15:27:38.000000000 +0100
@@ -17,7 +17,7 @@
Name: perl-Scalar-List-Utils
-Version: 1.43
+Version: 1.44
Release: 0
%define cpan_name Scalar-List-Utils
Summary: Common Scalar and List utility subroutines
++++++ Scalar-List-Utils-1.43.tar.gz -> Scalar-List-Utils-1.44.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Scalar-List-Utils-1.43/Changes
new/Scalar-List-Utils-1.44/Changes
--- old/Scalar-List-Utils-1.43/Changes 2016-02-08 16:05:37.000000000 +0100
+++ new/Scalar-List-Utils-1.44/Changes 2016-03-18 00:09:46.000000000 +0100
@@ -1,3 +1,9 @@
+1.44 -- 2016/03/17 23:08:46
+ [CHANGES]
+ * Added List::Util::uniq() and uniqnum()
+ (with thanks to randir and ilmari for assistance writing code and
+ tests)
+
1.43 -- 2016/02/08 15:05:23
[CHANGES]
* Updated documentation
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Scalar-List-Utils-1.43/ListUtil.xs
new/Scalar-List-Utils-1.44/ListUtil.xs
--- old/Scalar-List-Utils-1.43/ListUtil.xs 2016-02-03 01:56:58.000000000
+0100
+++ new/Scalar-List-Utils-1.44/ListUtil.xs 2016-03-18 00:07:44.000000000
+0100
@@ -14,6 +14,12 @@
# include "multicall.h"
#endif
+#if PERL_BCDVERSION < 0x5023008
+# define UNUSED_VAR_newsp PERL_UNUSED_VAR(newsp)
+#else
+# define UNUSED_VAR_newsp NOOP
+#endif
+
#ifndef CvISXSUB
# define CvISXSUB(cv) CvXSUB(cv)
#endif
@@ -66,6 +72,10 @@
# define croak_no_modify() croak("%s", PL_no_modify)
#endif
+#ifndef SvNV_nomg
+# define SvNV_nomg SvNV
+#endif
+
enum slu_accum {
ACC_IV,
ACC_NV,
@@ -383,7 +393,7 @@
dMULTICALL;
I32 gimme = G_SCALAR;
- PERL_UNUSED_VAR(newsp);
+ UNUSED_VAR_newsp;
PUSH_MULTICALL(cv);
for(index = 2 ; index < items ; index++) {
GvSV(bgv) = args[index];
@@ -438,7 +448,7 @@
dMULTICALL;
I32 gimme = G_SCALAR;
- PERL_UNUSED_VAR(newsp);
+ UNUSED_VAR_newsp;
PUSH_MULTICALL(cv);
for(index = 1 ; index < items ; index++) {
@@ -510,7 +520,7 @@
I32 gimme = G_SCALAR;
int index;
- PERL_UNUSED_VAR(newsp);
+ UNUSED_VAR_newsp;
PUSH_MULTICALL(cv);
for(index = 1; index < items; index++) {
SV *def_sv = GvSV(PL_defgv) = args[index];
@@ -694,7 +704,7 @@
dMULTICALL;
I32 gimme = G_SCALAR;
- PERL_UNUSED_VAR(newsp);
+ UNUSED_VAR_newsp;
PUSH_MULTICALL(cv);
for(; argi < items; argi += 2) {
SV *a = GvSV(agv) = stack[argi];
@@ -779,7 +789,7 @@
dMULTICALL;
I32 gimme = G_SCALAR;
- PERL_UNUSED_VAR(newsp);
+ UNUSED_VAR_newsp;
PUSH_MULTICALL(cv);
for(; argi < items; argi += 2) {
SV *a = GvSV(agv) = stack[argi];
@@ -870,7 +880,7 @@
dMULTICALL;
I32 gimme = G_ARRAY;
- PERL_UNUSED_VAR(newsp);
+ UNUSED_VAR_newsp;
PUSH_MULTICALL(cv);
for(; argi < items; argi += 2) {
int count;
@@ -997,6 +1007,86 @@
}
+void
+uniq(...)
+PROTOTYPE: @
+ALIAS:
+ uniq = 0
+ uniqnum = 1
+CODE:
+{
+ int retcount = 0;
+ int index;
+ SV **args = &PL_stack_base[ax];
+ HV *seen;
+
+ if(items < 2) {
+ retcount = items;
+ goto finish;
+ }
+
+ sv_2mortal((SV *)(seen = newHV()));
+
+ if(ix) {
+ /* A temporary buffer for number stringification */
+ SV *keysv = sv_newmortal();
+
+ for(index = 0 ; index < items ; index++) {
+ SV *arg = args[index];
+
+ SvGETMAGIC(arg);
+
+ if(SvUOK(arg))
+ sv_setpvf(keysv, "%"UVuf, SvUV_nomg(arg));
+ else if(SvIOK(arg))
+ sv_setpvf(keysv, "%"IVdf, SvIV_nomg(arg));
+ else
+ sv_setpvf(keysv, "%"NVgf, SvNV_nomg(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))
+ continue;
+
+ HeVAL(he) = &PL_sv_undef;
+#else
+ if(hv_exists(seen, SvPVX(keysv), SvCUR(keysv)))
+ continue;
+
+ hv_store(seen, SvPVX(keysv), SvCUR(keysv), &PL_sv_undef, 0);
+#endif
+
+ if(GIMME_V == G_ARRAY)
+ ST(retcount) = arg;
+ retcount++;
+ }
+ }
+ else
+ for(index = 0 ; index < items ; index++) {
+#ifdef HV_FETCH_EMPTY_HE
+ HE* he = hv_common(seen, args[index], NULL, 0, 0, HV_FETCH_LVALUE
| HV_FETCH_EMPTY_HE, NULL, 0);
+ if (HeVAL(he))
+ continue;
+
+ HeVAL(he) = &PL_sv_undef;
+#else
+ if (hv_exists_ent(seen, args[index], 0))
+ continue;
+
+ hv_store_ent(seen, args[index], &PL_sv_undef, 0);
+#endif
+
+ if(GIMME_V == G_ARRAY)
+ ST(retcount) = args[index];
+ retcount++;
+ }
+
+ finish:
+ if(GIMME_V == G_ARRAY)
+ XSRETURN(retcount);
+ else
+ ST(0) = sv_2mortal(newSViv(retcount));
+}
+
MODULE=List::Util PACKAGE=Scalar::Util
void
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Scalar-List-Utils-1.43/MANIFEST
new/Scalar-List-Utils-1.44/MANIFEST
--- old/Scalar-List-Utils-1.43/MANIFEST 2016-02-08 16:07:27.000000000 +0100
+++ new/Scalar-List-Utils-1.44/MANIFEST 2016-03-18 00:10:20.000000000 +0100
@@ -37,6 +37,7 @@
t/sum.t
t/sum0.t
t/tainted.t
+t/uniq.t
t/weak.t
META.yml Module YAML meta-data (added by
MakeMaker)
META.json Module JSON meta-data (added by
MakeMaker)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Scalar-List-Utils-1.43/META.json
new/Scalar-List-Utils-1.44/META.json
--- old/Scalar-List-Utils-1.43/META.json 2016-02-08 16:07:26.000000000
+0100
+++ new/Scalar-List-Utils-1.44/META.json 2016-03-18 00:10:20.000000000
+0100
@@ -49,6 +49,6 @@
"web" : "https://github.com/Scalar-List-Utils/Scalar-List-Utils"
}
},
- "version" : "1.43",
+ "version" : "1.44",
"x_serialization_backend" : "JSON::PP version 2.27300"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Scalar-List-Utils-1.43/META.yml
new/Scalar-List-Utils-1.44/META.yml
--- old/Scalar-List-Utils-1.43/META.yml 2016-02-08 16:07:26.000000000 +0100
+++ new/Scalar-List-Utils-1.44/META.yml 2016-03-18 00:10:20.000000000 +0100
@@ -23,5 +23,5 @@
resources:
bugtracker:
https://rt.cpan.org/Public/Dist/Display.html?Name=Scalar-List-Utils
repository: https://github.com/Scalar-List-Utils/Scalar-List-Utils.git
-version: '1.43'
+version: '1.44'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Scalar-List-Utils-1.43/lib/List/Util/XS.pm
new/Scalar-List-Utils-1.44/lib/List/Util/XS.pm
--- old/Scalar-List-Utils-1.43/lib/List/Util/XS.pm 2016-02-08
16:05:07.000000000 +0100
+++ new/Scalar-List-Utils-1.44/lib/List/Util/XS.pm 2016-03-18
00:09:51.000000000 +0100
@@ -3,7 +3,7 @@
use warnings;
use List::Util;
-our $VERSION = "1.43"; # FIXUP
+our $VERSION = "1.44"; # FIXUP
$VERSION = eval $VERSION; # FIXUP
1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Scalar-List-Utils-1.43/lib/List/Util.pm
new/Scalar-List-Utils-1.44/lib/List/Util.pm
--- old/Scalar-List-Utils-1.43/lib/List/Util.pm 2016-02-08 16:05:07.000000000
+0100
+++ new/Scalar-List-Utils-1.44/lib/List/Util.pm 2016-03-18 00:09:51.000000000
+0100
@@ -12,10 +12,10 @@
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(
- all any first min max minstr maxstr none notall product reduce sum sum0
shuffle
+ all any first min max minstr maxstr none notall product reduce sum sum0
shuffle uniq uniqnum
pairs unpairs pairkeys pairvalues pairmap pairgrep pairfirst
);
-our $VERSION = "1.43";
+our $VERSION = "1.44";
our $XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
@@ -39,10 +39,6 @@
sub List::Util::_Pair::key { shift->[0] }
sub List::Util::_Pair::value { shift->[1] }
-1;
-
-__END__
-
=head1 NAME
List::Util - A selection of general-utility list subroutines
@@ -466,6 +462,35 @@
@cards = shuffle 0..51 # 0..51 in a random order
+=head2 uniq
+
+ my @subset = uniq @values
+
+Filters a list of values to remove subsequent duplicates, as judged by a
+string equality test. Preserves the order of unique elements, and retains the
+first value of any duplicate set.
+
+ my $count = uniq @values
+
+In scalar context, returns the number of elements that would have been
+returned as a list.
+
+Note that C<undef> is not handled specially; it is treated the same as most
+other perl operations that work on strings. That is, C<undef> behaves
+identically to the empty string, but in addition a warning is produced.
+
+=head2 uniqnum
+
+ my @subset = uniqnum @values
+
+Filters a list of values similarly to L</uniq>, but judges duplicates
+numerically instead.
+
+ my $count = uniqnum @values
+
+In scalar context, returns the number of elements that would have been
+returned as a list.
+
=cut
=head1 KNOWN BUGS
@@ -513,6 +538,29 @@
block's execution will take their individual values for each invocation, as
normal.
+=head2 uniqnum() on oversized bignums
+
+Due to the way that C<uniqnum()> compares numbers, it cannot distinguish
+differences between bignums (especially bigints) that are too large to fit in
+the native platform types. For example,
+
+ my $x = Math::BigInt->new( "1" x 100 );
+ my $y = $x + 1;
+
+ say for uniqnum( $x, $y );
+
+Will print just the value of C<$x>, believing that C<$y> is a numerically-
+equivalent value. This bug does not affect C<uniq()>, which will correctly
+observe that the two values stringify to different strings.
+
+=head2 uniqnum() invokes GET magic multiple times before perl 5.14
+
+Perl versions before 5.14 lack the C<SvNV_nomg()> and related macros. On these
+older versions, C<uniqnum()> will invoke GET magic twice on each argument
+passed in. This ought not cause any major problems other than a slight
+performance penalty, because well-designed GET magic should be idempotent.
+This does not affect C<uniq()>, nor builds for perl 5.14 or later.
+
=head1 SUGGESTED ADDITIONS
The following are additions that have been requested, but I have been reluctant
@@ -540,3 +588,5 @@
Paul Evans, <[email protected]>.
=cut
+
+1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Scalar-List-Utils-1.43/lib/Scalar/Util.pm
new/Scalar-List-Utils-1.44/lib/Scalar/Util.pm
--- old/Scalar-List-Utils-1.43/lib/Scalar/Util.pm 2016-02-08
16:05:07.000000000 +0100
+++ new/Scalar-List-Utils-1.44/lib/Scalar/Util.pm 2016-03-18
00:09:51.000000000 +0100
@@ -17,7 +17,7 @@
dualvar isdual isvstring looks_like_number openhandle readonly set_prototype
tainted
);
-our $VERSION = "1.43";
+our $VERSION = "1.44";
$VERSION = eval $VERSION;
require List::Util; # List::Util loads the XS
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Scalar-List-Utils-1.43/lib/Sub/Util.pm
new/Scalar-List-Utils-1.44/lib/Sub/Util.pm
--- old/Scalar-List-Utils-1.43/lib/Sub/Util.pm 2016-02-08 16:05:07.000000000
+0100
+++ new/Scalar-List-Utils-1.44/lib/Sub/Util.pm 2016-03-18 00:09:51.000000000
+0100
@@ -15,7 +15,7 @@
subname set_subname
);
-our $VERSION = "1.43";
+our $VERSION = "1.44";
$VERSION = eval $VERSION;
require List::Util; # as it has the XS
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Scalar-List-Utils-1.43/t/uniq.t
new/Scalar-List-Utils-1.44/t/uniq.t
--- old/Scalar-List-Utils-1.43/t/uniq.t 1970-01-01 01:00:00.000000000 +0100
+++ new/Scalar-List-Utils-1.44/t/uniq.t 2016-03-18 00:09:51.000000000 +0100
@@ -0,0 +1,146 @@
+#!./perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 19;
+use List::Util qw( uniq uniqnum );
+
+is_deeply( [ uniq ],
+ [],
+ 'uniq of empty list' );
+
+is_deeply( [ uniq qw( abc ) ],
+ [qw( abc )],
+ 'uniq of singleton list' );
+
+is_deeply( [ uniq qw( x x x ) ],
+ [qw( x )],
+ 'uniq of repeated-element list' );
+
+is_deeply( [ uniq qw( a b a c ) ],
+ [qw( a b c )],
+ 'uniq removes subsequent duplicates' );
+
+is_deeply( [ uniq qw( 1 1.0 1E0 ) ],
+ [qw( 1 1.0 1E0 )],
+ 'uniq compares strings' );
+
+{
+ my $warnings = "";
+ local $SIG{__WARN__} = sub { $warnings .= join "", @_ };
+
+ my $cafe = "cafe\x{301}";
+
+ is_deeply( [ uniq $cafe ],
+ [ $cafe ],
+ 'uniq is happy with Unicode strings' );
+
+ utf8::encode( my $cafebytes = $cafe );
+
+ is_deeply( [ uniq $cafe, $cafebytes ],
+ [ $cafe, $cafebytes ],
+ 'uniq does not squash bytewise-equal but differently-encoded
strings' );
+
+ is( $warnings, "", 'No warnings are printed when handling Unicode strings'
);
+}
+
+is_deeply( [ uniqnum qw( 1 1.0 1E0 2 3 ) ],
+ [ 1, 2, 3 ],
+ 'uniqnum compares numbers' );
+
+is_deeply( [ uniqnum qw( 1 1.1 1.2 1.3 ) ],
+ [ 1, 1.1, 1.2, 1.3 ],
+ 'uniqnum distinguishes floats' );
+
+# Hard to know for sure what an Inf is going to be. Lets make one
+my $Inf = 0 + 1E1000;
+my $NaN;
+$Inf **= 1000 while ( $NaN = $Inf - $Inf ) == $NaN;
+
+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' );
+
+{
+ my $maxint = ~0;
+
+ is_deeply( [ uniqnum $maxint, $maxint-1, -1 ],
+ [ $maxint, $maxint-1, -1 ],
+ 'uniqnum preserves uniqness of full integer range' );
+}
+
+is( scalar( uniq qw( a b c d a b e ) ), 5, 'uniq() in scalar context' );
+
+{
+ package Stringify;
+
+ use overload '""' => sub { return $_[0]->{str} };
+
+ sub new { bless { str => $_[1] }, $_[0] }
+
+ package main;
+
+ my @strs = map { Stringify->new( $_ ) } qw( foo foo bar );
+
+ is_deeply( [ uniq @strs ],
+ [ $strs[0], $strs[2] ],
+ 'uniq respects stringify overload' );
+}
+
+{
+ package Numify;
+
+ use overload '0+' => sub { return $_[0]->{num} };
+
+ sub new { bless { num => $_[1] }, $_[0] }
+
+ package main;
+ use Scalar::Util qw( refaddr );
+
+ my @nums = map { Numify->new( $_ ) } qw( 2 2 5 );
+
+ # is_deeply wants to use eq overloading
+ my @ret = uniqnum @nums;
+ ok( scalar @ret == 2 &&
+ refaddr $ret[0] == refaddr $nums[0] &&
+ refaddr $ret[1] == refaddr $nums[2],
+ 'uniqnum respects numify overload' );
+}
+
+{
+ package DestroyNotifier;
+
+ use overload '""' => sub { "SAME" };
+
+ sub new { bless { var => $_[1] }, $_[0] }
+
+ sub DESTROY { ${ $_[0]->{var} }++ }
+
+ package main;
+
+ my @destroyed = (0) x 3;
+ my @notifiers = map { DestroyNotifier->new( \$destroyed[$_] ) } 0 .. 2;
+
+ my @uniq = uniq @notifiers;
+ undef @notifiers;
+
+ is_deeply( \@destroyed, [ 0, 1, 1 ],
+ 'values filtered by uniq() are destroyed' );
+
+ undef @uniq;
+ is_deeply( \@destroyed, [ 1, 1, 1 ],
+ 'all values destroyed' );
+}
+
+{
+ "a a b" =~ m/(.) (.) (.)/;
+ is_deeply( [ uniq $1, $2, $3 ],
+ [qw( a b )],
+ 'uniq handles magic' );
+
+ "1 1 2" =~ m/(.) (.) (.)/;
+ is_deeply( [ uniqnum $1, $2, $3 ],
+ [ 1, 2 ],
+ 'uniqnum handles magic' );
+}