From: Graham Barr Date: Tue, 4 Feb 2003 14:42:51 +0000 (+0000) Subject: Sync with 1.10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9e7deb6ce02b084df6ef8f2d042e680bec44776d;p=p5sagit%2Fp5-mst-13.2.git Sync with 1.10 p4raw-id: //depot/perl@18654 --- diff --git a/ext/List/Util/ChangeLog b/ext/List/Util/ChangeLog index eef0491..e03b31c 100644 --- a/ext/List/Util/ChangeLog +++ b/ext/List/Util/ChangeLog @@ -1,3 +1,21 @@ +Change 763 on 2003/02/04 by (Graham Barr) + + Fix linking error for older perls + +Change 762 on 2003/02/04 by (Graham Barr) + + Make lln tests and perl implementation mimic changes to looks_like_number + in different perl versions + +Change 761 on 2003/02/04 by (Graham Barr) + + Add looks_like_number + +Change 760 on 2003/02/04 by (Graham Barr) + + Ensure PERL_DL_NONLAZY is false so we don't catch link errors during + bootstrap and then test the perl only version + Change 759 on 2002/12/12 by (Graham Barr) Release 1.09 @@ -18,7 +36,7 @@ Change 756 on 2002/11/03 by (Graham Barr) Change 751 on 2002/10/18 by (Graham Barr) Fix context so that sub for reduce/first is always in a scalar context - Fix sum/min/max so that they dont upgrade thier argumetns to NVs + Fix sum/min/max so that they dont upgrade thier arguments to NVs if they are IV or UV Change 750 on 2002/10/14 by (Graham Barr) diff --git a/ext/List/Util/Util.xs b/ext/List/Util/Util.xs index db9ce15..3212feb 100644 --- a/ext/List/Util/Util.xs +++ b/ext/List/Util/Util.xs @@ -8,10 +8,7 @@ #include #ifndef PERL_VERSION -# include -# ifndef PERL_VERSION -# include -# endif +# include "patchlevel.h" # define PERL_REVISION 5 # define PERL_VERSION PATCHLEVEL # define PERL_SUBVERSION SUBVERSION @@ -99,8 +96,8 @@ sv_tainted(SV *sv) # endif #endif -#ifndef PTR2IV -# define PTR2IV(ptr) (IV)(ptr) +#ifndef PTR2UV +# define PTR2UV(ptr) (UV)(ptr) #endif MODULE=List::Util PACKAGE=List::Util @@ -472,6 +469,15 @@ CODE: croak("vstrings are not implemented in this release of perl"); #endif +int +looks_like_number(sv) + SV *sv +PROTOTYPE: $ +CODE: + RETVAL = looks_like_number(sv); +OUTPUT: + RETVAL + BOOT: { diff --git a/ext/List/Util/lib/List/Util.pm b/ext/List/Util/lib/List/Util.pm index 87b7e6c..872bb2d 100644 --- a/ext/List/Util/lib/List/Util.pm +++ b/ext/List/Util/lib/List/Util.pm @@ -11,7 +11,7 @@ require DynaLoader; our @ISA = qw(Exporter DynaLoader); our @EXPORT_OK = qw(first min max minstr maxstr reduce sum shuffle); -our $VERSION = "1.09_00"; +our $VERSION = "1.10_00"; our $XS_VERSION = $VERSION; $VERSION = eval $VERSION; diff --git a/ext/List/Util/lib/Scalar/Util.pm b/ext/List/Util/lib/Scalar/Util.pm index fd881ad..4de463d 100644 --- a/ext/List/Util/lib/Scalar/Util.pm +++ b/ext/List/Util/lib/Scalar/Util.pm @@ -10,7 +10,7 @@ require Exporter; require List::Util; # List::Util loads the XS our @ISA = qw(Exporter); -our @EXPORT_OK = qw(blessed dualvar reftype weaken isweak tainted readonly openhandle refaddr isvstring); +our @EXPORT_OK = qw(blessed dualvar reftype weaken isweak tainted readonly openhandle refaddr isvstring looks_like_number); our $VERSION = $List::Util::VERSION; sub openhandle ($) { @@ -41,7 +41,7 @@ Scalar::Util - A selection of general-utility scalar subroutines =head1 SYNOPSIS - use Scalar::Util qw(blessed dualvar isweak readonly refaddr reftype tainted weaken); + use Scalar::Util qw(blessed dualvar isweak readonly refaddr reftype tainted weaken isvstring looks_like_number); =head1 DESCRIPTION @@ -95,6 +95,11 @@ If EXPR is a scalar which is a weak reference the result is true. weaken($ref); $weak = isweak($ref); # true +=item looks_like_number EXPR + +Returns true if perl thinks EXPR is a number. See +L. + =item openhandle FH Returns FH if FH may be used as a filehandle and is open, or FH is a tied diff --git a/ext/List/Util/t/lln.t b/ext/List/Util/t/lln.t new file mode 100644 index 0000000..fe3ba4c --- /dev/null +++ b/ext/List/Util/t/lln.t @@ -0,0 +1,47 @@ +#!/usr/bin/perl -w +# -*- perl -*- + + +# +# $Id: $ +# Author: Slaven Rezic +# + +use strict; +use vars qw(%Config); + +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 Scalar::Util qw(looks_like_number); + +my $i; +sub ok { print +(($_[0] eq $_[1]) ? "": "not "), "ok ",++$i,"\n" } + +print "1..12\n"; + +ok(!!looks_like_number("1"), 1); +ok(!!looks_like_number("-1"), 1); +ok(!!looks_like_number("+1"), 1); +ok(!!looks_like_number("1.0"), 1); +ok(!!looks_like_number("+1.0"), 1); +ok(!!looks_like_number("-1.0"), 1); +ok(!!looks_like_number("-1.0e-12"), 1); +ok(!!looks_like_number("Inf"), $] >= 5.006001); +ok(!!looks_like_number("Infinity"), $] >= 5.008); +ok(!!looks_like_number("NaN"), $] >= 5.008); +ok(!!looks_like_number("foo"), ''); +ok(!!looks_like_number(undef), 1); +# That's enough - we trust the perl core tests like t/base/num.t + +__END__