summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>2012-03-10 12:27:50 +0000
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>2012-03-10 13:48:08 +0000
commit317dedd9d02066b0e24343ba3522d45dfb3c177f (patch)
tree0bfb4d515a7f6e2baa78e1491accb5f2bb88923f
parentacdbe25bd91bf897e0cf373b91ab0814e21c4860 (diff)
downloadperl-smoke-me/list-util.tar.gz
Update List-Util to CPAN version 1.23_04smoke-me/list-util
[DELTA] 1.23_04 -- Sat Mar 10 00:16:16 UTC 2012 * RT#72700 Fix off-by-two on string literal length 1.23_03 -- Tue Sep 14 10:09:59 CDT 2010 * Min perl version supported for build is not 5.008 * Dropped the pure-Perl implementation of both Scalar::- and List::Util. * RT#61118 Fix assumption in sum() that once magic, always magic 1.23_02 -- Tue Mar 30 11:09:15 CDT 2010 * Fix first() and reduce() to check the callback first; &first(1) is now illigal. [gfx] * Fix reduce() to allow XSUB callbacks [gfx] * Fix first() to allow XSUB callbacks [gfx] * Resolve RT #55763: tainted() doesn't do SvGETMAGIC(sv) [gfx] * define CvISXSUB so older perl versions will still compile 1.23_01 -- Mon Mar 22 08:24:11 CDT 2010 * Add failing tests; SVt_RV is not directly SvROK [gfx] * Implement openhandle() in XS (with extra tests) [gfx] * Modernize *.pm [gfx] * Modernize ListUtil.xs [gfx] * Add ppport.h [gfx] * Fix an overloading issue on sum(), and add tests for overloading [gfx] * Small tweaks for minstr()/maxstr() [gfx] * Optimize dualvar() [gfx] * Use sv_copypv() instead of SvPV() and sv_setpv() [gfx] * avoid non-portable warnings
-rw-r--r--MANIFEST21
-rwxr-xr-xPorting/Maintainers.pl2
-rw-r--r--cpan/List-Util/Changes31
-rw-r--r--cpan/List-Util/ListUtil.xs344
-rw-r--r--cpan/List-Util/Makefile.PL42
-rw-r--r--cpan/List-Util/XS.pp45
-rw-r--r--cpan/List-Util/lib/List/Util.pm31
-rw-r--r--cpan/List-Util/lib/List/Util/PP.pm83
-rw-r--r--cpan/List-Util/lib/List/Util/XS.pm14
-rw-r--r--cpan/List-Util/lib/Scalar/Util.pm52
-rw-r--r--cpan/List-Util/lib/Scalar/Util/PP.pm108
-rw-r--r--cpan/List-Util/t/expfail.t29
-rw-r--r--cpan/List-Util/t/first.t11
-rw-r--r--cpan/List-Util/t/getmagic-once.t47
-rw-r--r--cpan/List-Util/t/max.t24
-rw-r--r--cpan/List-Util/t/min.t23
-rw-r--r--cpan/List-Util/t/openhan.t26
-rw-r--r--cpan/List-Util/t/p_00version.t26
-rw-r--r--cpan/List-Util/t/p_blessed.t7
-rw-r--r--cpan/List-Util/t/p_first.t8
-rw-r--r--cpan/List-Util/t/p_lln.t7
-rw-r--r--cpan/List-Util/t/p_max.t7
-rw-r--r--cpan/List-Util/t/p_maxstr.t7
-rw-r--r--cpan/List-Util/t/p_min.t7
-rw-r--r--cpan/List-Util/t/p_minstr.t7
-rw-r--r--cpan/List-Util/t/p_openhan.t7
-rw-r--r--cpan/List-Util/t/p_readonly.t7
-rw-r--r--cpan/List-Util/t/p_reduce.t8
-rw-r--r--cpan/List-Util/t/p_refaddr.t7
-rw-r--r--cpan/List-Util/t/p_reftype.t7
-rw-r--r--cpan/List-Util/t/p_shuffle.t7
-rw-r--r--cpan/List-Util/t/p_sum.t7
-rw-r--r--cpan/List-Util/t/p_tainted.t12
-rw-r--r--cpan/List-Util/t/reduce.t9
-rw-r--r--cpan/List-Util/t/reftype.t6
-rw-r--r--cpan/List-Util/t/sum.t44
-rw-r--r--cpan/List-Util/t/tainted.t11
-rw-r--r--mkppport.lst1
38 files changed, 395 insertions, 747 deletions
diff --git a/MANIFEST b/MANIFEST
index 92efe61391..317ff2cf38 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1485,10 +1485,8 @@ cpan/libnet/t/smtp.t libnet
cpan/libnet/t/time.t libnet
cpan/List-Util/Changes Util extension
cpan/List-Util/lib/List/Util.pm List::Util
-cpan/List-Util/lib/List/Util/PP.pm List::Util
cpan/List-Util/lib/List/Util/XS.pm List::Util
cpan/List-Util/lib/Scalar/Util.pm Scalar::Util
-cpan/List-Util/lib/Scalar/Util/PP.pm Scalar::Util
cpan/List-Util/ListUtil.xs Util extension
cpan/List-Util/Makefile.PL Util extension
cpan/List-Util/multicall.h Util extension
@@ -1496,8 +1494,8 @@ cpan/List-Util/README Util extension
cpan/List-Util/t/00version.t Scalar::Util
cpan/List-Util/t/blessed.t Scalar::Util
cpan/List-Util/t/dualvar.t Scalar::Util
-cpan/List-Util/t/expfail.t List::Util
cpan/List-Util/t/first.t List::Util
+cpan/List-Util/t/getmagic-once.t List::Util
cpan/List-Util/t/isvstring.t Scalar::Util
cpan/List-Util/t/lln.t Scalar::Util
cpan/List-Util/t/maxstr.t List::Util
@@ -1505,23 +1503,7 @@ cpan/List-Util/t/max.t List::Util
cpan/List-Util/t/minstr.t List::Util
cpan/List-Util/t/min.t List::Util
cpan/List-Util/t/openhan.t Scalar::Util
-cpan/List-Util/t/p_00version.t Scalar::Util
-cpan/List-Util/t/p_blessed.t Scalar::Util
-cpan/List-Util/t/p_first.t List::Util
-cpan/List-Util/t/p_lln.t Scalar::Util
-cpan/List-Util/t/p_maxstr.t List::Util
-cpan/List-Util/t/p_max.t List::Util
-cpan/List-Util/t/p_minstr.t List::Util
-cpan/List-Util/t/p_min.t List::Util
-cpan/List-Util/t/p_openhan.t Scalar::Util
-cpan/List-Util/t/p_readonly.t Scalar::Util
-cpan/List-Util/t/p_reduce.t List::Util
-cpan/List-Util/t/p_refaddr.t Scalar::Util
-cpan/List-Util/t/p_reftype.t Scalar::Util
cpan/List-Util/t/proto.t Scalar::Util
-cpan/List-Util/t/p_shuffle.t List::Util
-cpan/List-Util/t/p_sum.t List::Util
-cpan/List-Util/t/p_tainted.t Scalar::Util
cpan/List-Util/t/readonly.t Scalar::Util
cpan/List-Util/t/reduce.t List::Util
cpan/List-Util/t/refaddr.t Scalar::Util
@@ -1531,7 +1513,6 @@ cpan/List-Util/t/stack-corruption.t List::Util
cpan/List-Util/t/sum.t List::Util
cpan/List-Util/t/tainted.t Scalar::Util
cpan/List-Util/t/weak.t Scalar::Util
-cpan/List-Util/XS.pp List::Util
cpan/Locale-Codes/ChangeLog Locale::Codes
cpan/Locale-Codes/lib/Locale/Codes/API.pod Locale::Codes documentation
cpan/Locale-Codes/lib/Locale/Codes/Changes.pod Locale::Codes documentation
diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl
index 444967732b..10ff81d3a2 100755
--- a/Porting/Maintainers.pl
+++ b/Porting/Maintainers.pl
@@ -1579,7 +1579,7 @@ use File::Glob qw(:case);
'Scalar-List-Utils' => {
'MAINTAINER' => 'gbarr',
- 'DISTRIBUTION' => 'GBARR/Scalar-List-Utils-1.23.tar.gz',
+ 'DISTRIBUTION' => 'PEVANS/Scalar-List-Utils-1.23_04.tar.gz',
# Note that perl uses its own version of Makefile.PL
'FILES' => q[cpan/List-Util],
diff --git a/cpan/List-Util/Changes b/cpan/List-Util/Changes
index 552a95a13c..63ab10bda7 100644
--- a/cpan/List-Util/Changes
+++ b/cpan/List-Util/Changes
@@ -1,3 +1,34 @@
+1.23_04 -- Sat Mar 10 00:16:16 UTC 2012
+
+ * RT#72700 Fix off-by-two on string literal length
+
+1.23_03 -- Tue Sep 14 10:09:59 CDT 2010
+
+ * Min perl version supported for build is not 5.008
+ * Dropped the pure-Perl implementation of both Scalar::- and List::Util.
+ * RT#61118 Fix assumption in sum() that once magic, always magic
+
+1.23_02 -- Tue Mar 30 11:09:15 CDT 2010
+
+ * Fix first() and reduce() to check the callback first; &first(1) is now illigal. [gfx]
+ * Fix reduce() to allow XSUB callbacks [gfx]
+ * Fix first() to allow XSUB callbacks [gfx]
+ * Resolve RT #55763: tainted() doesn't do SvGETMAGIC(sv) [gfx]
+ * define CvISXSUB so older perl versions will still compile
+
+1.23_01 -- Mon Mar 22 08:24:11 CDT 2010
+
+ * Add failing tests; SVt_RV is not directly SvROK [gfx]
+ * Implement openhandle() in XS (with extra tests) [gfx]
+ * Modernize *.pm [gfx]
+ * Modernize ListUtil.xs [gfx]
+ * Add ppport.h [gfx]
+ * Fix an overloading issue on sum(), and add tests for overloading [gfx]
+ * Small tweaks for minstr()/maxstr() [gfx]
+ * Optimize dualvar() [gfx]
+ * Use sv_copypv() instead of SvPV() and sv_setpv() [gfx]
+ * avoid non-portable warnings
+
1.23 -- Wed Mar 10 20:50:00 CST 2010
* Add a test file to ensure 'GETMAGIC' called once [gfx]
diff --git a/cpan/List-Util/ListUtil.xs b/cpan/List-Util/ListUtil.xs
index 7da9b959d1..aef5c4051c 100644
--- a/cpan/List-Util/ListUtil.xs
+++ b/cpan/List-Util/ListUtil.xs
@@ -7,31 +7,22 @@
#include <perl.h>
#include <XSUB.h>
-#ifndef PERL_VERSION
-# include <patchlevel.h>
-# if !(defined(PERL_VERSION) || (SUBVERSION > 0 && defined(PATCHLEVEL)))
-# include <could_not_find_Perl_patchlevel.h>
-# endif
-# define PERL_REVISION 5
-# define PERL_VERSION PATCHLEVEL
-# define PERL_SUBVERSION SUBVERSION
-#endif
+#include "ppport.h"
-#if PERL_VERSION >= 6
+#if PERL_BCDVERSION >= 0x5006000
# include "multicall.h"
#endif
-#ifndef aTHX
-# define aTHX
-# define pTHX
+#ifndef CvISXSUB
+# define CvISXSUB(cv) CvXSUB(cv)
#endif
+
/* Some platforms have strict exports. And before 5.7.3 cxinc (or Perl_cxinc)
was not exported. Therefore platforms like win32, VMS etc have problems
so we redefine it here -- GMB
*/
-#if PERL_VERSION < 7
+#if PERL_BCDVERSION < 0x5007000
/* Not in 5.6.1. */
-# define SvUOK(sv) SvIOK_UV(sv)
# ifdef cxinc
# undef cxinc
# endif
@@ -40,13 +31,24 @@ static I32
my_cxinc(pTHX)
{
cxstack_max = cxstack_max * 3 / 2;
- Renew(cxstack, cxstack_max + 1, struct context); /* XXX should fix CXINC macro */
+ Renew(cxstack, cxstack_max + 1, struct context); /* fencepost bug in older CXINC macros requires +1 here */
return cxstack_ix + 1;
}
#endif
-#if PERL_VERSION < 6
-# define NV double
+#ifndef sv_copypv
+#define sv_copypv(a, b) my_sv_copypv(aTHX_ a, b)
+static void
+my_sv_copypv(pTHX_ SV *const dsv, SV *const ssv)
+{
+ STRLEN len;
+ const char * const s = SvPV_const(ssv,len);
+ sv_setpvn(dsv,s,len);
+ if (SvUTF8(ssv))
+ SvUTF8_on(dsv);
+ else
+ SvUTF8_off(dsv);
+}
#endif
#ifdef SVf_IVisUV
@@ -55,81 +57,6 @@ my_cxinc(pTHX)
# define slu_sv_value(sv) (SvIOK(sv)) ? (NV)(SvIVX(sv)) : (SvNV(sv))
#endif
-#ifndef Drand01
-# define Drand01() ((rand() & 0x7FFF) / (double) ((unsigned long)1 << 15))
-#endif
-
-#if PERL_VERSION < 5
-# ifndef gv_stashpvn
-# define gv_stashpvn(n,l,c) gv_stashpv(n,c)
-# endif
-# ifndef SvTAINTED
-
-static bool
-sv_tainted(pTHX_ SV *sv)
-{
- if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv)) {
- MAGIC *mg = mg_find(sv, 't');
- if (mg && ((mg->mg_len & 1) || (mg->mg_len & 2) && mg->mg_obj == sv))
- return TRUE;
- }
- return FALSE;
-}
-
-# define SvTAINTED_on(sv) sv_magic((sv), Nullsv, 't', Nullch, 0)
-# define SvTAINTED(sv) (SvMAGICAL(sv) && sv_tainted(aTHX_ sv))
-# endif
-# define PL_defgv defgv
-# define PL_op op
-# define PL_curpad curpad
-# define CALLRUNOPS runops
-# define PL_curpm curpm
-# define PL_sv_undef sv_undef
-# define PERL_CONTEXT struct context
-#endif
-#if (PERL_VERSION < 5) || (PERL_VERSION == 5 && PERL_SUBVERSION <50)
-# ifndef PL_tainting
-# define PL_tainting tainting
-# endif
-# ifndef PL_stack_base
-# define PL_stack_base stack_base
-# endif
-# ifndef PL_stack_sp
-# define PL_stack_sp stack_sp
-# endif
-# ifndef PL_ppaddr
-# define PL_ppaddr ppaddr
-# endif
-#endif
-
-#ifndef PTR2UV
-# define PTR2UV(ptr) (UV)(ptr)
-#endif
-
-#ifndef SvUV_set
-# define SvUV_set(sv, val) (((XPVUV*)SvANY(sv))->xuv_uv = (val))
-#endif
-
-#ifndef PERL_UNUSED_DECL
-# ifdef HASATTRIBUTE
-# if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER)
-# define PERL_UNUSED_DECL
-# else
-# define PERL_UNUSED_DECL __attribute__((unused))
-# endif
-# else
-# define PERL_UNUSED_DECL
-# endif
-#endif
-
-#ifndef dNOOP
-#define dNOOP extern int Perl___notused PERL_UNUSED_DECL
-#endif
-
-#ifndef GvSVn
-# define GvSVn GvSV
-#endif
-
MODULE=List::Util PACKAGE=List::Util
void
@@ -187,51 +114,71 @@ sum(...)
PROTOTYPE: @
CODE:
{
+ dXSTARG;
SV *sv;
SV *retsv = NULL;
int index;
NV retval = 0;
+ int magic;
if(!items) {
XSRETURN_UNDEF;
}
- sv = ST(0);
- if (SvAMAGIC(sv)) {
- retsv = sv_newmortal();
+ sv = ST(0);
+ magic = SvAMAGIC(sv);
+ if (magic) {
+ retsv = TARG;
sv_setsv(retsv, sv);
}
else {
retval = slu_sv_value(sv);
}
for(index = 1 ; index < items ; index++) {
- sv = ST(index);
- if (retsv || SvAMAGIC(sv)) {
- if (!retsv) {
- retsv = sv_newmortal();
- sv_setnv(retsv,retval);
+ sv = ST(index);
+ if(!magic && SvAMAGIC(sv)){
+ magic = TRUE;
+ if (!retsv)
+ retsv = TARG;
+ sv_setnv(retsv,retval);
+ }
+ if (magic) {
+ SV* const tmpsv = amagic_call(retsv, sv, add_amg, SvAMAGIC(retsv) ? AMGf_assign : 0);
+ if(tmpsv) {
+ magic = SvAMAGIC(tmpsv);
+ if (!magic) {
+ retval = slu_sv_value(tmpsv);
+ }
+ else {
+ retsv = tmpsv;
+ }
}
- if (!amagic_call(retsv, sv, add_amg, AMGf_assign)) {
- sv_setnv(retsv, SvNV(retsv) + SvNV(sv));
+ else {
+ /* fall back to default */
+ magic = FALSE;
+ retval = SvNV(retsv) + SvNV(sv);
}
}
else {
retval += slu_sv_value(sv);
}
}
- if (!retsv) {
- retsv = sv_newmortal();
+ if (!magic) {
+ if (!retsv)
+ retsv = TARG;
sv_setnv(retsv,retval);
}
ST(0) = retsv;
XSRETURN(1);
}
+#define SLU_CMP_LARGER 1
+#define SLU_CMP_SMALLER -1
void
minstr(...)
PROTOTYPE: @
ALIAS:
- minstr = 2
- maxstr = 0
+ minstr = SLU_CMP_LARGER
+ maxstr = SLU_CMP_SMALLER
CODE:
{
SV *left;
@@ -239,12 +186,6 @@ CODE:
if(!items) {
XSRETURN_UNDEF;
}
- /*
- sv_cmp & sv_cmp_locale return 1,0,-1 for gt,eq,lt
- so we set ix to the value we are looking for
- xsubpp does not allow -ve values, so we start with 0,2 and subtract 1
- */
- ix -= 1;
left = ST(0);
#ifdef OPpLOCALE
if(MAXARG & OPpLOCALE) {
@@ -278,35 +219,52 @@ reduce(block,...)
PROTOTYPE: &@
CODE:
{
- dMULTICALL;
SV *ret = sv_newmortal();
int index;
GV *agv,*bgv,*gv;
HV *stash;
- I32 gimme = G_SCALAR;
SV **args = &PL_stack_base[ax];
- CV *cv;
+ CV* cv = sv_2cv(block, &stash, &gv, 0);
- if(items <= 1) {
- XSRETURN_UNDEF;
- }
- cv = sv_2cv(block, &stash, &gv, 0);
if (cv == Nullcv) {
croak("Not a subroutine reference");
}
- PUSH_MULTICALL(cv);
- agv = gv_fetchpv("a", TRUE, SVt_PV);
- bgv = gv_fetchpv("b", TRUE, SVt_PV);
+
+ if(items <= 1) {
+ XSRETURN_UNDEF;
+ }
+
+ agv = gv_fetchpv("a", GV_ADD, SVt_PV);
+ bgv = gv_fetchpv("b", GV_ADD, SVt_PV);
SAVESPTR(GvSV(agv));
SAVESPTR(GvSV(bgv));
GvSV(agv) = ret;
SvSetSV(ret, args[1]);
- for(index = 2 ; index < items ; index++) {
- GvSV(bgv) = args[index];
- MULTICALL;
- SvSetSV(ret, *PL_stack_sp);
+
+ if(!CvISXSUB(cv)) {
+ dMULTICALL;
+ I32 gimme = G_SCALAR;
+
+ PUSH_MULTICALL(cv);
+ for(index = 2 ; index < items ; index++) {
+ GvSV(bgv) = args[index];
+ MULTICALL;
+ SvSetSV(ret, *PL_stack_sp);
+ }
+ POP_MULTICALL;
}
- POP_MULTICALL;
+ else {
+ for(index = 2 ; index < items ; index++) {
+ dSP;
+ GvSV(bgv) = args[index];
+
+ PUSHMARK(SP);
+ call_sv((SV*)cv, G_SCALAR);
+
+ SvSetSV(ret, *PL_stack_sp);
+ }
+ }
+
ST(0) = ret;
XSRETURN(1);
}
@@ -317,34 +275,50 @@ first(block,...)
PROTOTYPE: &@
CODE:
{
- dMULTICALL;
int index;
GV *gv;
HV *stash;
- I32 gimme = G_SCALAR;
SV **args = &PL_stack_base[ax];
- CV *cv;
+ CV *cv = sv_2cv(block, &stash, &gv, 0);
+ if (cv == Nullcv) {
+ croak("Not a subroutine reference");
+ }
if(items <= 1) {
XSRETURN_UNDEF;
}
- cv = sv_2cv(block, &stash, &gv, 0);
- if (cv == Nullcv) {
- croak("Not a subroutine reference");
- }
- PUSH_MULTICALL(cv);
+
SAVESPTR(GvSV(PL_defgv));
- for(index = 1 ; index < items ; index++) {
- GvSV(PL_defgv) = args[index];
- MULTICALL;
- if (SvTRUE(*PL_stack_sp)) {
- POP_MULTICALL;
- ST(0) = ST(index);
- XSRETURN(1);
- }
+ if(!CvISXSUB(cv)) {
+ dMULTICALL;
+ I32 gimme = G_SCALAR;
+ PUSH_MULTICALL(cv);
+
+ for(index = 1 ; index < items ; index++) {
+ GvSV(PL_defgv) = args[index];
+ MULTICALL;
+ if (SvTRUEx(*PL_stack_sp)) {
+ POP_MULTICALL;
+ ST(0) = ST(index);
+ XSRETURN(1);
+ }
+ }
+ POP_MULTICALL;
+ }
+ else {
+ for(index = 1 ; index < items ; index++) {
+ dSP;
+ GvSV(PL_defgv) = args[index];
+
+ PUSHMARK(SP);
+ call_sv((SV*)cv, G_SCALAR);
+ if (SvTRUEx(*PL_stack_sp)) {
+ ST(0) = ST(index);
+ XSRETURN(1);
+ }
+ }
}
- POP_MULTICALL;
XSRETURN_UNDEF;
}
@@ -398,30 +372,27 @@ dualvar(num,str)
PROTOTYPE: $$
CODE:
{
- STRLEN len;
- char *ptr = SvPV(str,len);
- ST(0) = sv_newmortal();
- (void)SvUPGRADE(ST(0),SVt_PVNV);
- sv_setpvn(ST(0),ptr,len);
- if (SvUTF8(str))
- SvUTF8_on(ST(0));
+ dXSTARG;
+ (void)SvUPGRADE(TARG, SVt_PVNV);
+ sv_copypv(TARG,str);
if(SvNOK(num) || SvPOK(num) || SvMAGICAL(num)) {
- SvNV_set(ST(0), SvNV(num));
- SvNOK_on(ST(0));
+ SvNV_set(TARG, SvNV(num));
+ SvNOK_on(TARG);
}
#ifdef SVf_IVisUV
else if (SvUOK(num)) {
- SvUV_set(ST(0), SvUV(num));
- SvIOK_on(ST(0));
- SvIsUV_on(ST(0));
+ SvUV_set(TARG, SvUV(num));
+ SvIOK_on(TARG);
+ SvIsUV_on(TARG);
}
#endif
else {
- SvIV_set(ST(0), SvIV(num));
- SvIOK_on(ST(0));
+ SvIV_set(TARG, SvIV(num));
+ SvIOK_on(TARG);
}
if(PL_tainting && (SvTAINTED(num) || SvTAINTED(str)))
- SvTAINTED_on(ST(0));
+ SvTAINTED_on(TARG);
+ ST(0) = TARG;
XSRETURN(1);
}
@@ -431,8 +402,7 @@ blessed(sv)
PROTOTYPE: $
CODE:
{
- if (SvMAGICAL(sv))
- mg_get(sv);
+ SvGETMAGIC(sv);
if(!(SvROK(sv) && SvOBJECT(SvRV(sv)))) {
XSRETURN_UNDEF;
}
@@ -447,8 +417,7 @@ reftype(sv)
PROTOTYPE: $
CODE:
{
- if (SvMAGICAL(sv))
- mg_get(sv);
+ SvGETMAGIC(sv);
if(!SvROK(sv)) {
XSRETURN_UNDEF;
}
@@ -463,8 +432,7 @@ refaddr(sv)
PROTOTYPE: $
CODE:
{
- if (SvMAGICAL(sv))
- mg_get(sv);
+ SvGETMAGIC(sv);
if(!SvROK(sv)) {
XSRETURN_UNDEF;
}
@@ -501,6 +469,7 @@ readonly(sv)
SV *sv
PROTOTYPE: $
CODE:
+ SvGETMAGIC(sv);
RETVAL = SvREADONLY(sv);
OUTPUT:
RETVAL
@@ -510,6 +479,7 @@ tainted(sv)
SV *sv
PROTOTYPE: $
CODE:
+ SvGETMAGIC(sv);
RETVAL = SvTAINTED(sv);
OUTPUT:
RETVAL
@@ -520,6 +490,7 @@ isvstring(sv)
PROTOTYPE: $
CODE:
#ifdef SvVOK
+ SvGETMAGIC(sv);
ST(0) = boolSV(SvVOK(sv));
XSRETURN(1);
#else
@@ -532,13 +503,11 @@ looks_like_number(sv)
PROTOTYPE: $
CODE:
SV *tempsv;
+ SvGETMAGIC(sv);
if (SvAMAGIC(sv) && (tempsv = AMG_CALLun(sv, numer))) {
sv = tempsv;
}
- else if (SvMAGICAL(sv)) {
- SvGETMAGIC(sv);
- }
-#if (PERL_VERSION < 8) || (PERL_VERSION == 8 && PERL_SUBVERSION <5)
+#if PERL_BCDVERSION < 0x5008005
if (SvPOK(sv) || SvPOKp(sv)) {
RETVAL = looks_like_number(sv);
}
@@ -566,9 +535,7 @@ CODE:
}
if (SvPOK(proto)) {
/* set the prototype */
- STRLEN len;
- char *ptr = SvPV(proto, len);
- sv_setpvn(sv, ptr, len);
+ sv_copypv(sv, proto);
}
else {
/* delete the prototype */
@@ -581,6 +548,35 @@ CODE:
XSRETURN(1);
}
+void
+openhandle(SV* sv)
+PROTOTYPE: $
+CODE:
+{
+ IO* io = NULL;
+ SvGETMAGIC(sv);
+ if(SvROK(sv)){
+ /* deref first */
+ sv = SvRV(sv);
+ }
+
+ /* must be GLOB or IO */
+ if(isGV(sv)){
+ io = GvIO((GV*)sv);
+ }
+ else if(SvTYPE(sv) == SVt_PVIO){
+ io = (IO*)sv;
+ }
+
+ if(io){
+ /* real or tied filehandle? */
+ if(IoIFP(io) || SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar)){
+ XSRETURN(1);
+ }
+ }
+ XSRETURN_UNDEF;
+}
+
BOOT:
{
HV *lu_stash = gv_stashpvn("List::Util", 10, TRUE);
@@ -595,7 +591,7 @@ BOOT:
varav = GvAVn(vargv);
#endif
if (SvTYPE(rmcgv) != SVt_PVGV)
- gv_init(rmcgv, lu_stash, "List::Util", 12, TRUE);
+ gv_init(rmcgv, lu_stash, "List::Util", 10, TRUE);
rmcsv = GvSVn(rmcgv);
#ifndef SvWEAKREF
av_push(varav, newSVpv("weaken",6));
diff --git a/cpan/List-Util/Makefile.PL b/cpan/List-Util/Makefile.PL
index 1cba5abdaa..33f9c30d1f 100644
--- a/cpan/List-Util/Makefile.PL
+++ b/cpan/List-Util/Makefile.PL
@@ -1,5 +1,5 @@
# -*- perl -*-
-BEGIN { require 5.006; } # allow CPAN testers to get the point
+BEGIN { require 5.008; } # allow CPAN testers to get the point
use strict;
use warnings;
use Config;
@@ -7,13 +7,6 @@ use File::Spec;
use ExtUtils::MakeMaker;
my $PERL_CORE = grep { $_ eq 'PERL_CORE=1' } @ARGV;
-my $do_xs = $PERL_CORE || can_cc();
-
-for (@ARGV) {
- /^-pm/ and $do_xs = 0;
- /^-xs/ and $do_xs = 1;
-}
-
WriteMakefile(
NAME => q[List::Util],
ABSTRACT => q[Common Scalar and List utility subroutines],
@@ -38,7 +31,6 @@ WriteMakefile(
INSTALLDIRS => q[perl],
PREREQ_PM => {'Test::More' => 0,},
(eval { ExtUtils::MakeMaker->VERSION(6.31) } ? (LICENSE => 'perl') : ()),
- ($do_xs ? () : (XS => {}, C => [], OBJECT => '')),
( eval { ExtUtils::MakeMaker->VERSION(6.46) } ? (
META_MERGE => {
resources => { ##
@@ -52,35 +44,3 @@ WriteMakefile(
),
);
-
-sub can_cc {
-
- foreach my $cmd (split(/ /, $Config::Config{cc})) {
- my $_cmd = $cmd;
- return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
-
- for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
- my $abs = File::Spec->catfile($dir, $_[1]);
- return $abs if (-x $abs or $abs = MM->maybe_command($abs));
- }
- }
-
- return;
-}
-
-package MY;
-
-sub init_PM {
- my $self = shift;
-
- $self->SUPER::init_PM(@_);
-
- return if $do_xs;
-
- my $pm = $self->{PM};
- my $pm_file = File::Spec->catfile(qw(lib List Util XS.pm));
-
- # When installing pure perl, install XS.pp as XS.pm
- $self->{PM}{'XS.pp'} = delete $self->{PM}{$pm_file};
-}
-
diff --git a/cpan/List-Util/XS.pp b/cpan/List-Util/XS.pp
deleted file mode 100644
index 6521f632cd..0000000000
--- a/cpan/List-Util/XS.pp
+++ /dev/null
@@ -1,45 +0,0 @@
-package List::Util::XS;
-use strict;
-use vars qw($VERSION);
-
-$VERSION = undef;
-
-sub VERSION {
- require Carp;
- Carp::croak("You need to install Scalar-List-Utils with a C compiler to ensure the XS is compiled")
- if defined $_[1];
- $VERSION;
-}
-
-1;
-__END__
-
-=head1 NAME
-
-List::Util::XS - Indicate if List::Util was compiled with a C compiler
-
-=head1 SYNOPSIS
-
- use List::Util::XS 1.20;
-
-=head1 DESCRIPTION
-
-B<*** This instalation does not have XS installed ***>
-
-C<List::Util::XS> can be used as a dependency to ensure List::Util was
-installed using a C compiler and that the XS version is installed.
-
-During installation C<$List::Util::XS::VERSION> will be set to
-C<undef> if the XS was not compiled.
-
-=head1 SEE ALSO
-
-L<Scalar::Util>, L<List::Util>, L<List::MoreUtils>
-
-=head1 COPYRIGHT
-
-Copyright (c) 2008 Graham Barr <gbarr@pobox.com>. All rights reserved.
-This program is free software; you can redistribute it and/or
-modify it under the same terms as Perl itself.
-
-=cut
diff --git a/cpan/List-Util/lib/List/Util.pm b/cpan/List-Util/lib/List/Util.pm
index aced6b15b5..52e325db7a 100644
--- a/cpan/List-Util/lib/List/Util.pm
+++ b/cpan/List-Util/lib/List/Util.pm
@@ -9,35 +9,16 @@
package List::Util;
use strict;
-use vars qw(@ISA @EXPORT_OK $VERSION $XS_VERSION $TESTING_PERL_ONLY);
require Exporter;
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(first min max minstr maxstr reduce sum shuffle);
-$VERSION = "1.23";
-$XS_VERSION = $VERSION;
+our @ISA = qw(Exporter);
+our @EXPORT_OK = qw(first min max minstr maxstr reduce sum shuffle);
+our $VERSION = "1.23_04";
+our $XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
-eval {
- # PERL_DL_NONLAZY must be false, or any errors in loading will just
- # cause the perl code to be tested
- local $ENV{PERL_DL_NONLAZY} = 0 if $ENV{PERL_DL_NONLAZY};
- eval {
- require XSLoader;
- XSLoader::load('List::Util', $XS_VERSION);
- 1;
- } or do {
- require DynaLoader;
- local @ISA = qw(DynaLoader);
- bootstrap List::Util $XS_VERSION;
- };
-} unless $TESTING_PERL_ONLY;
-
-
-if (!defined &sum) {
- require List::Util::PP;
- List::Util::PP->import;
-}
+require XSLoader;
+XSLoader::load('List::Util', $XS_VERSION);
1;
diff --git a/cpan/List-Util/lib/List/Util/PP.pm b/cpan/List-Util/lib/List/Util/PP.pm
deleted file mode 100644
index 2771329b56..0000000000
--- a/cpan/List-Util/lib/List/Util/PP.pm
+++ /dev/null
@@ -1,83 +0,0 @@
-# List::Util::PP.pm
-#
-# Copyright (c) 1997-2009 Graham Barr <gbarr@pobox.com>. All rights reserved.
-# This program is free software; you can redistribute it and/or
-# modify it under the same terms as Perl itself.
-
-package List::Util::PP;
-
-use strict;
-use warnings;
-use vars qw(@ISA @EXPORT $VERSION $a $b);
-require Exporter;
-
-@ISA = qw(Exporter);
-@EXPORT = qw(first min max minstr maxstr reduce sum shuffle);
-$VERSION = "1.23";
-$VERSION = eval $VERSION;
-
-sub reduce (&@) {
- my $code = shift;
- require Scalar::Util;
- my $type = Scalar::Util::reftype($code);
- unless($type and $type eq 'CODE') {
- require Carp;
- Carp::croak("Not a subroutine reference");
- }
- no strict 'refs';
-
- return shift unless @_ > 1;
-
- use vars qw($a $b);
-
- my $caller = caller;
- local(*{$caller."::a"}) = \my $a;
- local(*{$caller."::b"}) = \my $b;
-
- $a = shift;
- foreach (@_) {
- $b = $_;
- $a = &{$code}();
- }
-
- $a;
-}
-
-sub first (&@) {
- my $code = shift;
- require Scalar::Util;
- my $type = Scalar::Util::reftype($code);
- unless($type and $type eq 'CODE') {
- require Carp;
- Carp::croak("Not a subroutine reference");
- }
-
- foreach (@_) {
- return $_ if &{$code}();
- }
-
- undef;
-}
-
-
-sub sum (@) { reduce { $a + $b } @_ }
-
-sub min (@) { reduce { $a < $b ? $a : $b } @_ }
-
-sub max (@) { reduce { $a > $b ? $a : $b } @_ }
-
-sub minstr (@) { reduce { $a lt $b ? $a : $b } @_ }
-
-sub maxstr (@) { reduce { $a gt $b ? $a : $b } @_ }
-
-sub shuffle (@) {
- my @a=\(@_);
- my $n;
- my $i=@_;
- map {
- $n = rand($i--);
- (${$a[$n]}, $a[$n] = $a[$i])[0];
- } @_;
-}
-
-1;
diff --git a/cpan/List-Util/lib/List/Util/XS.pm b/cpan/List-Util/lib/List/Util/XS.pm
index 2dcb03a28e..bc817d05dc 100644
--- a/cpan/List-Util/lib/List/Util/XS.pm
+++ b/cpan/List-Util/lib/List/Util/XS.pm
@@ -1,18 +1,10 @@
package List::Util::XS;
use strict;
-use vars qw($VERSION);
use List::Util;
-$VERSION = "1.23"; # FIXUP
+our $VERSION = "1.23_04"; # FIXUP
$VERSION = eval $VERSION; # FIXUP
-sub _VERSION { # FIXUP
- require Carp;
- Carp::croak("You need to install Scalar-List-Utils with a C compiler to ensure the XS is compiled")
- if defined $_[1];
- $VERSION;
-}
-
1;
__END__
@@ -32,6 +24,10 @@ installed using a C compiler and that the XS version is installed.
During installation C<$List::Util::XS::VERSION> will be set to
C<undef> if the XS was not compiled.
+Starting with release 1.23_03, Scalar-List-Util is B<always> using
+the XS implementation, but for backwards compatibility, we still
+ship the C<List::Util::XS> module which just loads C<List::Util>.
+
=head1 SEE ALSO
L<Scalar::Util>, L<List::Util>, L<List::MoreUtils>
diff --git a/cpan/List-Util/lib/Scalar/Util.pm b/cpan/List-Util/lib/Scalar/Util.pm
index 24138ca4d8..ecf301b28d 100644
--- a/cpan/List-Util/lib/Scalar/Util.pm
+++ b/cpan/List-Util/lib/Scalar/Util.pm
@@ -7,37 +7,33 @@
package Scalar::Util;
use strict;
-use vars qw(@ISA @EXPORT_OK $VERSION @EXPORT_FAIL);
require Exporter;
require List::Util; # List::Util loads the XS
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(blessed dualvar reftype weaken isweak tainted readonly openhandle refaddr isvstring looks_like_number set_prototype);
-$VERSION = "1.23";
+our @ISA = qw(Exporter);
+our @EXPORT_OK = qw(blessed dualvar reftype weaken isweak tainted readonly openhandle refaddr isvstring looks_like_number set_prototype);
+our $VERSION = "1.23_04";
$VERSION = eval $VERSION;
-unless (defined &dualvar) {
- # Load Pure Perl version if XS not loaded
- require Scalar::Util::PP;
- Scalar::Util::PP->import;
- push @EXPORT_FAIL, qw(weaken isweak dualvar isvstring set_prototype);
+our @EXPORT_FAIL;
+
+unless (defined &weaken) {
+ push @EXPORT_FAIL, qw(weaken);
+}
+unless (defined &isweak) {
+ push @EXPORT_FAIL, qw(isweak isvstring);
+}
+unless (defined &isvstring) {
+ push @EXPORT_FAIL, qw(isvstring);
}
sub export_fail {
- if (grep { /dualvar/ } @EXPORT_FAIL) { # no XS loaded
- my $pat = join("|", @EXPORT_FAIL);
- if (my ($err) = grep { /^($pat)$/ } @_ ) {
- require Carp;
- Carp::croak("$err is only available with the XS version of Scalar::Util");
- }
- }
-
- if (grep { /^(weaken|isweak)$/ } @_ ) {
+ if (grep { /^(?:weaken|isweak)$/ } @_ ) {
require Carp;
Carp::croak("Weak references are not implemented in the version of perl");
}
- if (grep { /^(isvstring)$/ } @_ ) {
+ if (grep { /^isvstring$/ } @_ ) {
require Carp;
Carp::croak("Vstrings are not implemented in the version of perl");
}
@@ -45,24 +41,6 @@ sub export_fail {
@_;
}
-sub openhandle ($) {
- my $fh = shift;
- my $rt = reftype($fh) || '';
-
- return defined(fileno($fh)) ? $fh : undef
- if $rt eq 'IO';
-
- if (reftype(\$fh) eq 'GLOB') { # handle openhandle(*DATA)
- $fh = \(my $tmp=$fh);
- }
- elsif ($rt ne 'GLOB') {
- return undef;
- }
-
- (tied(*$fh) or defined(fileno($fh)))
- ? $fh : undef;
-}
-
1;
__END__
diff --git a/cpan/List-Util/lib/Scalar/Util/PP.pm b/cpan/List-Util/lib/Scalar/Util/PP.pm
deleted file mode 100644
index 7850e1b812..0000000000
--- a/cpan/List-Util/lib/Scalar/Util/PP.pm
+++ /dev/null
@@ -1,108 +0,0 @@
-# Scalar::Util::PP.pm
-#
-# Copyright (c) 1997-2009 Graham Barr <gbarr@pobox.com>. All rights reserved.
-# This program is free software; you can redistribute it and/or
-# modify it under the same terms as Perl itself.
-#
-# This module is normally only loaded if the XS module is not available
-
-package Scalar::Util::PP;
-
-use strict;
-use warnings;
-use vars qw(@ISA @EXPORT $VERSION $recurse);
-require Exporter;
-use B qw(svref_2object);
-
-@ISA = qw(Exporter);
-@EXPORT = qw(blessed reftype tainted readonly refaddr looks_like_number);
-$VERSION = "1.23";
-$VERSION = eval $VERSION;
-
-sub blessed ($) {
- return undef unless length(ref($_[0]));
- my $b = svref_2object($_[0]);
- return undef unless $b->isa('B::PVMG');
- my $s = $b->SvSTASH;
- return $s->isa('B::HV') ? $s->NAME : undef;
-}
-
-sub refaddr($) {
- return undef unless length(ref($_[0]));
-
- my $addr;
- if(defined(my $pkg = blessed($_[0]))) {
- $addr .= bless $_[0], 'Scalar::Util::Fake';
- bless $_[0], $pkg;
- }
- else {
- $addr .= $_[0]
- }
-
- $addr =~ /0x(\w+)/;
- local $^W;
- no warnings 'portable';
- hex($1);
-}
-
-{
- my %tmap = qw(
- B::NULL SCALAR
-
- B::HV HASH
- B::AV ARRAY
- B::CV CODE
- B::IO IO
- B::GV GLOB
- B::REGEXP REGEXP
- );
-
- sub reftype ($) {
- my $r = shift;
-
- return undef unless length(ref($r));
-
- my $t = ref(svref_2object($r));
-
- return
- exists $tmap{$t} ? $tmap{$t}
- : length(ref($$r)) ? 'REF'
- : 'SCALAR';
- }
-}
-
-sub tainted {
- local($@, $SIG{__DIE__}, $SIG{__WARN__});
- local $^W = 0;
- no warnings;
- eval { kill 0 * $_[0] };
- $@ =~ /^Insecure/;
-}
-
-sub readonly {
- return 0 if tied($_[0]) || (ref(\($_[0])) ne "SCALAR");
-
- local($@, $SIG{__DIE__}, $SIG{__WARN__});
- my $tmp = $_[0];
-
- !eval { $_[0] = $tmp; 1 };
-}
-
-sub looks_like_number {
- local $_ = shift;
-
- # checks from perlfaq4
- return 0 if !defined($_);
- if (ref($_)) {
- require overload;
- return overload::Overloaded($_) ? defined(0 + $_) : 0;
- }
- return 1 if (/^[+-]?[0-9]+$/); # is a +/- integer
- return 1 if (/^([+-]?)(?=[0-9]|\.[0-9])[0-9]*(\.[0-9]*)?([Ee]([+-]?[0-9]+))?$/); # a C float
- return 1 if ($] >= 5.008 and /^(Inf(inity)?|NaN)$/i) or ($] >= 5.006001 and /^Inf$/i);
-
- 0;
-}
-
-
-1;
diff --git a/cpan/List-Util/t/expfail.t b/cpan/List-Util/t/expfail.t
deleted file mode 100644
index 02fc192f14..0000000000
--- a/cpan/List-Util/t/expfail.t
+++ /dev/null
@@ -1,29 +0,0 @@
-#!./perl
-
-BEGIN {
- unless (-d 'blib') {
- chdir 't' if -d 't';
- @INC = '../lib';
- require Config; import Config;
- keys %Config; # Silence warning
- if ($Config{extensions} !~ /\bList\/Util\b/) {
- print "1..0 # Skip: List::Util was not built\n";
- exit 0;
- }
- }
-}
-
-use Test::More tests => 3;
-use strict;
-
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-require Scalar::Util;
-
-for my $func (qw(dualvar set_prototype weaken)) {
- eval { Scalar::Util->import($func); };
- like(
- $@,
- qr/$func is only available with the XS/,
- "no pure perl $func: error raised",
- );
-}
diff --git a/cpan/List-Util/t/first.t b/cpan/List-Util/t/first.t
index 1378c39044..497cdd5188 100644
--- a/cpan/List-Util/t/first.t
+++ b/cpan/List-Util/t/first.t
@@ -15,7 +15,7 @@ BEGIN {
use List::Util qw(first);
use Test::More;
-plan tests => 19 + ($::PERL_ONLY ? 0 : 2);
+plan tests => 22 + ($::PERL_ONLY ? 0 : 2);
my $v;
ok(defined &first, 'defined');
@@ -114,6 +114,15 @@ if (!$::PERL_ONLY) { SKIP: {
} }
+use constant XSUBC_TRUE => 1;
+use constant XSUBC_FALSE => 0;
+
+is first(\&XSUBC_TRUE, 42, 1, 2, 3), 42, 'XSUB callbacks';
+is first(\&XSUBC_FALSE, 42, 1, 2, 3), undef, 'XSUB callbacks';
+
+
+eval { &first(1) };
+ok($@ =~ /^Not a subroutine reference/, 'check for code reference');
eval { &first(1,2) };
ok($@ =~ /^Not a subroutine reference/, 'check for code reference');
eval { &first(qw(a b)) };
diff --git a/cpan/List-Util/t/getmagic-once.t b/cpan/List-Util/t/getmagic-once.t
new file mode 100644
index 0000000000..00b3490783
--- /dev/null
+++ b/cpan/List-Util/t/getmagic-once.t
@@ -0,0 +1,47 @@
+#!./perl
+
+BEGIN {
+ unless (-d 'blib') {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require Config; import Config;
+ keys %Config; # Silence warning
+ if ($Config{extensions} !~ /\bList\/Util\b/) {
+ print "1..0 # Skip: List::Util was not built\n";
+ exit 0;
+ }
+ }
+}
+use strict;
+use Scalar::Util qw(blessed reftype refaddr);
+use Test::More tests => 6;
+
+my $getmagic_count;
+
+{
+ package T;
+ use Tie::Scalar;
+ use base qw(Tie::StdScalar);
+
+ sub FETCH {
+ $getmagic_count++;
+ my($self) = @_;
+ return $self->SUPER::FETCH;
+ }
+}
+
+tie my $var, 'T';
+
+$var = bless {};
+
+$getmagic_count = 0;
+ok blessed($var);
+is $getmagic_count, 1, 'blessed';
+
+$getmagic_count = 0;
+ok reftype($var);
+is $getmagic_count, 1, 'reftype';
+
+$getmagic_count = 0;
+ok refaddr($var);
+is $getmagic_count, 1, 'refaddr';
diff --git a/cpan/List-Util/t/max.t b/cpan/List-Util/t/max.t
index aff916658f..9607015d83 100644
--- a/cpan/List-Util/t/max.t
+++ b/cpan/List-Util/t/max.t
@@ -14,7 +14,7 @@ BEGIN {
}
use strict;
-use Test::More tests => 8;
+use Test::More tests => 10;
use List::Util qw(max);
my $v;
@@ -45,6 +45,7 @@ is($v, 3, 'overload');
$v = max($thr,$two,$one);
is($v, 3, 'overload');
+
{ package Foo;
use overload
@@ -59,12 +60,17 @@ use overload
}
}
-SKIP: {
- eval { require bignum; } or skip("Need bignum for testing overloading",1);
+use Math::BigInt;
+
+my $v1 = Math::BigInt->new(2) ** Math::BigInt->new(65);
+my $v2 = $v1 - 1;
+my $v3 = $v2 - 1;
+$v = max($v1,$v2,$v1,$v3,$v1);
+is($v, $v1, 'bigint');
+
+$v = max($v1, 1, 2, 3);
+is($v, $v1, 'bigint and normal int');
+
+$v = max(1, 2, $v1, 3);
+is($v, $v1, 'bigint and normal int');
- my $v1 = 2**65;
- my $v2 = $v1 - 1;
- my $v3 = $v2 - 1;
- $v = max($v1,$v2,$v1,$v3,$v1);
- is($v, $v1, 'bigint');
-}
diff --git a/cpan/List-Util/t/min.t b/cpan/List-Util/t/min.t
index 13d1116a6c..8d5be5e153 100644
--- a/cpan/List-Util/t/min.t
+++ b/cpan/List-Util/t/min.t
@@ -14,7 +14,7 @@ BEGIN {
}
use strict;
-use Test::More tests => 8;
+use Test::More tests => 10;
use List::Util qw(min);
my $v;
@@ -59,12 +59,17 @@ use overload
}
}
-SKIP: {
- eval { require bignum; } or skip("Need bignum for testing overloading",1);
+use Math::BigInt;
+
+my $v1 = Math::BigInt->new(2) ** Math::BigInt->new(65);
+my $v2 = $v1 - 1;
+my $v3 = $v2 - 1;
+$v = min($v1,$v2,$v1,$v3,$v1);
+is($v, $v3, 'bigint');
+
+$v = min($v1, 1, 2, 3);
+is($v, 1, 'bigint and normal int');
+
+$v = min(1, 2, $v1, 3);
+is($v, 1, 'bigint and normal int');
- my $v1 = 2**65;
- my $v2 = $v1 - 1;
- my $v3 = $v2 - 1;
- $v = min($v1,$v2,$v1,$v3,$v1);
- is($v, $v3, 'bigint');
-}
diff --git a/cpan/List-Util/t/openhan.t b/cpan/List-Util/t/openhan.t
index bf4e6c16f8..e0dffb6f53 100644
--- a/cpan/List-Util/t/openhan.t
+++ b/cpan/List-Util/t/openhan.t
@@ -15,7 +15,7 @@ BEGIN {
use strict;
-use Test::More tests => 14;
+use Test::More tests => 21;
use Scalar::Util qw(openhandle);
ok(defined &openhandle, 'defined');
@@ -36,16 +36,20 @@ SKIP: {
skip "3-arg open only on 5.6 or later", 1 if $]<5.006;
open my $fh, "<", $0;
- skip "could not open $0 for reading: $!", 1 unless $fh;
+ skip "could not open $0 for reading: $!", 2 unless $fh;
is(openhandle($fh), $fh, "works with indirect filehandles");
+ close($fh);
+ is(openhandle($fh), undef, "works with indirect filehandles");
}
SKIP: {
- skip "in-memory files only on 5.8 or later", 1 if $]<5.008;
+ skip "in-memory files only on 5.8 or later", 2 if $]<5.008;
open my $fh, "<", \"in-memory file";
- skip "could not open in-memory file: $!", 1 unless $fh;
+ skip "could not open in-memory file: $!", 2 unless $fh;
is(openhandle($fh), $fh, "works with in-memory files");
+ close($fh);
+ is(openhandle($fh), undef, "works with in-memory files");
}
ok(openhandle(\*DATA), "works for \*DATA");
@@ -55,7 +59,7 @@ ok(openhandle(*DATA{IO}), "works for *DATA{IO}");
{
require IO::Handle;
my $fh = IO::Handle->new_from_fd(fileno(*STDERR), 'w');
- skip "new_from_fd(fileno(*STDERR)) failed", 1 unless $fh;
+ skip "new_from_fd(fileno(*STDERR)) failed", 2 unless $fh;
ok(openhandle($fh), "works for IO::Handle objects");
ok(!openhandle(IO::Handle->new), "unopened IO::Handle");
@@ -65,14 +69,16 @@ ok(openhandle(*DATA{IO}), "works for *DATA{IO}");
require IO::File;
my $fh = IO::File->new;
$fh->open("< $0")
- or skip "could not open $0: $!", 1;
+ or skip "could not open $0: $!", 3;
ok(openhandle($fh), "works for IO::File objects");
+ close($fh);
+ ok(!openhandle($fh), "works for IO::File objects");
ok(!openhandle(IO::File->new), "unopened IO::File" );
}
SKIP: {
- skip( "Tied handles only on 5.8 or later", 1) if $]<5.008;
+ skip( "Tied handles only on 5.8 or later", 2) if $]<5.008;
use vars qw(*H);
@@ -84,6 +90,12 @@ SKIP: {
package main;
tie *H, 'My::Tie';
ok(openhandle(*H), "tied handles are always ok");
+ ok(openhandle(\*H), "tied handle refs are always ok");
}
+ok !openhandle(undef), "undef is not a filehandle";
+ok !openhandle("STDIN"), "strings are not filehandles";
+ok !openhandle(0), "integers are not filehandles";
+
+
__DATA__
diff --git a/cpan/List-Util/t/p_00version.t b/cpan/List-Util/t/p_00version.t
deleted file mode 100644
index 0b64f9eef3..0000000000
--- a/cpan/List-Util/t/p_00version.t
+++ /dev/null
@@ -1,26 +0,0 @@
-#!./perl
-
-BEGIN {
- unless (-d 'blib') {
- chdir 't' if -d 't';
- @INC = '../lib';
- require Config; import Config;
- keys %Config; # Silence warning
- if ($Config{extensions} !~ /\bList\/Util\b/) {
- print "1..0 # Skip: List::Util was not built\n";
- exit 0;
- }
- }
-}
-
-use Test::More tests => 2;
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-require Scalar::Util;
-require List::Util;
-
-is( $Scalar::Util::PP::VERSION, $List::Util::VERSION, "VERSION mismatch");
-is( $List::Util::PP::VERSION, $List::Util::VERSION, "VERSION mismatch");
-
diff --git a/cpan/List-Util/t/p_blessed.t b/cpan/List-Util/t/p_blessed.t
deleted file mode 100644
index 48e7ef7dcd..0000000000
--- a/cpan/List-Util/t/p_blessed.t
+++ /dev/null
@@ -1,7 +0,0 @@
-#!./perl
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-(my $f = __FILE__) =~ s/p_//;
-do $f; die $@ if $@;
diff --git a/cpan/List-Util/t/p_first.t b/cpan/List-Util/t/p_first.t
deleted file mode 100644
index cd39ec44be..0000000000
--- a/cpan/List-Util/t/p_first.t
+++ /dev/null
@@ -1,8 +0,0 @@
-#!./perl
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-(my $f = __FILE__) =~ s/p_//;
-$::PERL_ONLY = $::PERL_ONLY = 1; # Mustn't use it only once!
-do $f; die $@ if $@;
diff --git a/cpan/List-Util/t/p_lln.t b/cpan/List-Util/t/p_lln.t
deleted file mode 100644
index 48e7ef7dcd..0000000000
--- a/cpan/List-Util/t/p_lln.t
+++ /dev/null
@@ -1,7 +0,0 @@
-#!./perl
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-(my $f = __FILE__) =~ s/p_//;
-do $f; die $@ if $@;
diff --git a/cpan/List-Util/t/p_max.t b/cpan/List-Util/t/p_max.t
deleted file mode 100644
index 48e7ef7dcd..0000000000
--- a/cpan/List-Util/t/p_max.t
+++ /dev/null
@@ -1,7 +0,0 @@
-#!./perl
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-(my $f = __FILE__) =~ s/p_//;
-do $f; die $@ if $@;
diff --git a/cpan/List-Util/t/p_maxstr.t b/cpan/List-Util/t/p_maxstr.t
deleted file mode 100644
index 48e7ef7dcd..0000000000
--- a/cpan/List-Util/t/p_maxstr.t
+++ /dev/null
@@ -1,7 +0,0 @@
-#!./perl
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-(my $f = __FILE__) =~ s/p_//;
-do $f; die $@ if $@;
diff --git a/cpan/List-Util/t/p_min.t b/cpan/List-Util/t/p_min.t
deleted file mode 100644
index 48e7ef7dcd..0000000000
--- a/cpan/List-Util/t/p_min.t
+++ /dev/null
@@ -1,7 +0,0 @@
-#!./perl
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-(my $f = __FILE__) =~ s/p_//;
-do $f; die $@ if $@;
diff --git a/cpan/List-Util/t/p_minstr.t b/cpan/List-Util/t/p_minstr.t
deleted file mode 100644
index 48e7ef7dcd..0000000000
--- a/cpan/List-Util/t/p_minstr.t
+++ /dev/null
@@ -1,7 +0,0 @@
-#!./perl
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-(my $f = __FILE__) =~ s/p_//;
-do $f; die $@ if $@;
diff --git a/cpan/List-Util/t/p_openhan.t b/cpan/List-Util/t/p_openhan.t
deleted file mode 100644
index 48e7ef7dcd..0000000000
--- a/cpan/List-Util/t/p_openhan.t
+++ /dev/null
@@ -1,7 +0,0 @@
-#!./perl
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-(my $f = __FILE__) =~ s/p_//;
-do $f; die $@ if $@;
diff --git a/cpan/List-Util/t/p_readonly.t b/cpan/List-Util/t/p_readonly.t
deleted file mode 100644
index 48e7ef7dcd..0000000000
--- a/cpan/List-Util/t/p_readonly.t
+++ /dev/null
@@ -1,7 +0,0 @@
-#!./perl
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-(my $f = __FILE__) =~ s/p_//;
-do $f; die $@ if $@;
diff --git a/cpan/List-Util/t/p_reduce.t b/cpan/List-Util/t/p_reduce.t
deleted file mode 100644
index cd39ec44be..0000000000
--- a/cpan/List-Util/t/p_reduce.t
+++ /dev/null
@@ -1,8 +0,0 @@
-#!./perl
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-(my $f = __FILE__) =~ s/p_//;
-$::PERL_ONLY = $::PERL_ONLY = 1; # Mustn't use it only once!
-do $f; die $@ if $@;
diff --git a/cpan/List-Util/t/p_refaddr.t b/cpan/List-Util/t/p_refaddr.t
deleted file mode 100644
index 48e7ef7dcd..0000000000
--- a/cpan/List-Util/t/p_refaddr.t
+++ /dev/null
@@ -1,7 +0,0 @@
-#!./perl
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-(my $f = __FILE__) =~ s/p_//;
-do $f; die $@ if $@;
diff --git a/cpan/List-Util/t/p_reftype.t b/cpan/List-Util/t/p_reftype.t
deleted file mode 100644
index 48e7ef7dcd..0000000000
--- a/cpan/List-Util/t/p_reftype.t
+++ /dev/null
@@ -1,7 +0,0 @@
-#!./perl
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-(my $f = __FILE__) =~ s/p_//;
-do $f; die $@ if $@;
diff --git a/cpan/List-Util/t/p_shuffle.t b/cpan/List-Util/t/p_shuffle.t
deleted file mode 100644
index 48e7ef7dcd..0000000000
--- a/cpan/List-Util/t/p_shuffle.t
+++ /dev/null
@@ -1,7 +0,0 @@
-#!./perl
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-(my $f = __FILE__) =~ s/p_//;
-do $f; die $@ if $@;
diff --git a/cpan/List-Util/t/p_sum.t b/cpan/List-Util/t/p_sum.t
deleted file mode 100644
index 48e7ef7dcd..0000000000
--- a/cpan/List-Util/t/p_sum.t
+++ /dev/null
@@ -1,7 +0,0 @@
-#!./perl
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-(my $f = __FILE__) =~ s/p_//;
-do $f; die $@ if $@;
diff --git a/cpan/List-Util/t/p_tainted.t b/cpan/List-Util/t/p_tainted.t
deleted file mode 100644
index 6a4cd22242..0000000000
--- a/cpan/List-Util/t/p_tainted.t
+++ /dev/null
@@ -1,12 +0,0 @@
-#!./perl -T
-
-use File::Spec;
-
-# force perl-only version to be tested
-$List::Util::TESTING_PERL_ONLY = $List::Util::TESTING_PERL_ONLY = 1;
-
-(my $f = __FILE__) =~ s/p_//;
-my $filename = ($^O eq 'MSWin32' || $^O eq 'VMS')
- ? File::Spec->rel2abs(File::Spec->catfile(".", $f))
- : File::Spec->catfile(".", $f);
-do $filename; die $@ if $@;
diff --git a/cpan/List-Util/t/reduce.t b/cpan/List-Util/t/reduce.t
index 2e1257521c..4468ab8611 100644
--- a/cpan/List-Util/t/reduce.t
+++ b/cpan/List-Util/t/reduce.t
@@ -16,7 +16,7 @@ BEGIN {
use List::Util qw(reduce min);
use Test::More;
-plan tests => 27 + ($::PERL_ONLY ? 0 : 2);
+plan tests => 29 + ($::PERL_ONLY ? 0 : 2);
my $v = reduce {};
@@ -151,6 +151,13 @@ if (!$::PERL_ONLY) { SKIP: {
} }
+# XSUB callback
+use constant XSUBC => 42;
+
+is reduce(\&XSUBC, 1, 2, 3), 42, "xsub callbacks";
+
+eval { &reduce(1) };
+ok($@ =~ /^Not a subroutine reference/, 'check for code reference');
eval { &reduce(1,2) };
ok($@ =~ /^Not a subroutine reference/, 'check for code reference');
eval { &reduce(qw(a b)) };
diff --git a/cpan/List-Util/t/reftype.t b/cpan/List-Util/t/reftype.t
index a7adafb996..31a5d3b841 100644
--- a/cpan/List-Util/t/reftype.t
+++ b/cpan/List-Util/t/reftype.t
@@ -13,7 +13,7 @@ BEGIN {
}
}
-use Test::More tests => 29;
+use Test::More tests => 32;
use Scalar::Util qw(reftype);
use vars qw($t $y $x *F);
@@ -23,12 +23,16 @@ use Symbol qw(gensym);
tie *F, 'MyTie';
my $RE = $] < 5.011 ? 'SCALAR' : 'REGEXP';
+my $s = []; # SvTYPE($s) is SVt_RV, and SvROK($s) is true
+$s = undef; # SvTYPE($s) is SVt_RV, but SvROK($s) is false
+
@test = (
[ undef, 1, 'number' ],
[ undef, 'A', 'string' ],
[ HASH => {}, 'HASH ref' ],
[ ARRAY => [], 'ARRAY ref' ],
[ SCALAR => \$t, 'SCALAR ref' ],
+ [ SCALAR => \$s, 'SCALAR ref (but SVt_RV)' ],
[ REF => \(\$t), 'REF ref' ],
[ GLOB => \*F, 'tied GLOB ref' ],
[ GLOB => gensym, 'GLOB ref' ],
diff --git a/cpan/List-Util/t/sum.t b/cpan/List-Util/t/sum.t
index ef484f96c5..3615b4ab41 100644
--- a/cpan/List-Util/t/sum.t
+++ b/cpan/List-Util/t/sum.t
@@ -13,7 +13,7 @@ BEGIN {
}
}
-use Test::More tests => 8;
+use Test::More tests => 13;
use List::Util qw(sum);
@@ -58,12 +58,40 @@ use overload
}
}
-SKIP: {
- eval { require bignum; } or skip("Need bignum for testing overloading",1);
+use Math::BigInt;
+my $v1 = Math::BigInt->new(2) ** Math::BigInt->new(65);
+my $v2 = $v1 - 1;
+$v = sum($v1,$v2);
+is($v, $v1 + $v2, 'bigint');
- my $v1 = 2**65;
- my $v2 = 2**65;
- my $v3 = $v1 + $v2;
- $v = sum($v1,$v2);
- is($v, $v3, 'bignum');
+$v = sum(42, $v1);
+is($v, $v1 + 42, 'bigint + builtin int');
+
+$v = sum(42, $v1, 2);
+is($v, $v1 + 42 + 2, 'bigint + builtin int');
+
+{ package example;
+
+ use overload
+ '0+' => sub { $_[0][0] },
+ '""' => sub { my $r = "$_[0][0]"; $r = "+$r" unless $r =~ m/^\-/; $r .= " [$_[0][1]]"; $r },
+ fallback => 1;
+
+ sub new {
+ my $class = shift;
+
+ my $this = bless [@_], $class;
+
+ return $this;
+ }
+}
+
+{
+ my $e1 = example->new(7, "test");
+ $t = sum($e1, 7, 7);
+ is($t, 21, 'overload returning non-overload');
+ $t = sum(8, $e1, 8);
+ is($t, 23, 'overload returning non-overload');
+ $t = sum(9, 9, $e1);
+ is($t, 25, 'overload returning non-overload');
}
diff --git a/cpan/List-Util/t/tainted.t b/cpan/List-Util/t/tainted.t
index 09ad330684..ab40aa69fe 100644
--- a/cpan/List-Util/t/tainted.t
+++ b/cpan/List-Util/t/tainted.t
@@ -16,7 +16,7 @@ BEGIN {
}
}
-use Test::More tests => 4;
+use Test::More tests => 5;
use Scalar::Util qw(tainted);
@@ -32,3 +32,12 @@ ok( tainted($ENV{$key}), 'environment variable');
$var = $ENV{$key};
ok( tainted($var), 'copy of environment variable');
+
+{
+ package Tainted;
+ sub TIESCALAR { bless {} }
+ sub FETCH { $^X }
+}
+
+tie my $tiedvar, 'Tainted';
+ok( tainted($tiedvar), 'for magic variables');
diff --git a/mkppport.lst b/mkppport.lst
index 57b9b9e65e..3d5a88cbd8 100644
--- a/mkppport.lst
+++ b/mkppport.lst
@@ -7,6 +7,7 @@
cpan/DB_File
cpan/IPC-SysV
+cpan/List-Util
cpan/Time-HiRes
cpan/Win32API-File
dist/Cwd