From: Steve Peters Date: Fri, 6 Jan 2006 21:59:00 +0000 (+0000) Subject: Upgrade to version-0.52 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=34ba6322b644154d55680c95808981776852ae24;p=p5sagit%2Fp5-mst-13.2.git Upgrade to version-0.52 p4raw-id: //depot/perl@26685 --- diff --git a/lib/version.pm b/lib/version.pm index 9443a6a..dafbae6 100644 --- a/lib/version.pm +++ b/lib/version.pm @@ -11,7 +11,7 @@ use vars qw(@ISA $VERSION $CLASS @EXPORT); @EXPORT = qw(qv); -$VERSION = 0.50; +$VERSION = 0.52; $CLASS = 'version'; diff --git a/lib/version.pod b/lib/version.pod index 509089c..a874203 100644 --- a/lib/version.pod +++ b/lib/version.pod @@ -55,13 +55,24 @@ and to not rely on hidden behavior of the parser. =item * Be careful If you are using Module::Build or ExtUtils::MakeMaker, so that you can -release your module to CPAN, you have to recognize that none of those -programs currently handles version objects natively (yet). That also -goes for the CPAN indexer (PAUSE). Although there are modules on CPAN -that employ the version module internally, the support for assigning a -module $VERSION scalar is still lacking. Both Module::Build and the -PAUSE indexer will [hopefully soon] include support for version -objects. +release your module to CPAN, you have to recognize that neither of those +programs completely handles version objects natively (yet). If you use +version objects with Module::Build, you should add an explicit dependency +to the release of version.pm in your Build.PL: + + my $builder = Module::Build->new( + ... + requires => { + ... , + 'version' => 0.50, + ..., + }, + ... + ); + +and it should Just Work(TM). Module::Build will [hopefully soon] +include full support for version objects; there are no current plans +to patch ExtUtils::MakeMaker to support version objects. =head2 What IS a version diff --git a/lib/version.t b/lib/version.t index 8a8c209..16f306c 100644 --- a/lib/version.t +++ b/lib/version.t @@ -4,7 +4,7 @@ ######################### -use Test::More tests => 202; +use Test::More qw(no_plan); diag "Tests with base class" unless $ENV{PERL_CORE}; @@ -94,6 +94,10 @@ sub BaseTests { like($@, qr/underscores before decimal/, "Invalid version format (underscores before decimal)"); + eval {my $version = $CLASS->new("1_2")}; + like($@, qr/alpha without decimal/, + "Invalid version format (alpha without decimal)"); + $version = $CLASS->new("99 and 44/100 pure"); ok ("$version" eq "99.000", '$version eq "99.000"'); ok ($version->numify == 99.0, '$version->numify == 99.0'); diff --git a/sv.c b/sv.c index d0234cd..8800ddf 100644 --- a/sv.c +++ b/sv.c @@ -8166,6 +8166,11 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV */ if (sv_derived_from(vecsv, "version")) { char *version = savesvpv(vecsv); + if ( hv_exists((HV*)SvRV(vecsv), "alpha", 5 ) ) { + Perl_warner(aTHX_ packWARN(WARN_INTERNAL), + "vector argument not supported with alpha versions"); + goto unknown; + } vecsv = sv_newmortal(); /* scan_vstring is expected to be called during * tokenization, so we need to fake up the end diff --git a/t/op/sprintf.t b/t/op/sprintf.t index 79953ef..b0f8c02 100755 --- a/t/op/sprintf.t +++ b/t/op/sprintf.t @@ -11,6 +11,7 @@ BEGIN { @INC = '../lib'; } use warnings; +use version; use Config; use strict; @@ -243,14 +244,11 @@ __END__ >%vd< >"\01\02\03"< >1.2.3< >%vd< >v1.2.3< >1.2.3< >%vd< >[version::qv("1.2.3")]< >1.2.3< ->%vd< >[version::qv("1.2")]< >1.2.0< ->%vd< >[version::qv("1.02")]< >1.2.0< ->%vd< >[version::qv("1.002")]< >1.2.0< ->%vd< >[version::qv("1.02_03")]< >1.23< ->%vd< >[version::qv("1048576.5")]< >1048576.5.0< ->%vd< >[version::qv("50")]< >50.0.0< ->%vd< >[version::qv("50_20")]< >50.200< ->%vd< >[version::qv("5.005_03")]< >5.53< +>%vd< >[version->new("1.2")]< >1.200< +>%vd< >[version->new("1.02")]< >1.20< +>%vd< >[version->new("1.002")]< >1.2< +>%vd< >[version->new("1048576.5")]< >1048576.500< +>%vd< >[version->new("50")]< >50.0< >%v.3d< >"\01\02\03"< >001.002.003< >%0v3d< >"\01\02\03"< >001.002.003< >%v.3d< >[version::qv("1.2.3")]< >001.002.003< diff --git a/util.c b/util.c index 881287b..48cc63a 100644 --- a/util.c +++ b/util.c @@ -4031,6 +4031,9 @@ Perl_scan_version(pTHX_ const char *s, SV *rv, bool qv) pos++; } + if ( alpha && !saw_period ) + Perl_croak(aTHX_ "Invalid version format (alpha without decimal)"); + if ( saw_period > 1 ) qv = 1; /* force quoted version processing */