Patch to bring Module::Build in line with current version.pm

John Peacock <[email protected]> Thu, 26 Nov 2009 09:08:06 -0500
Newsgroups gmane.comp.lang.perl.modules.module-build
Message-ID <[email protected]>
This patch should be applied as soon as practical, as it improves the v-string
detection in Perl releases from 5.6.x through 5.8.0 (inclusive).  It is not
required for the 5.10.2 release (though I wouldn't cry if it were included
anyways, just to be consistent, since 5.10.2 should ship with version.pm 0.78).

I have an in-progress patch to deal with multiple underscores in version
initialization, so if that lands before this gets applied, I'll provide a new patch.

John

--- lib/Module/Build/Version.pm	(revision 2870)
+++ lib/Module/Build/Version.pm	(local)
@@ -121,8 +121,7 @@
 use POSIX qw/locale_h/;
 use locale;
 use vars qw ($VERSION @ISA @REGEXS);
-$VERSION = '0.77';
-$VERSION = eval $VERSION;
+$VERSION = 0.78;

 push @REGEXS, qr/
 	^v?	# optional leading 'v'
@@ -613,9 +612,10 @@
 sub _un_vstring {
     my $value = shift;
     # may be a v-string
-    if ( $] >= 5.006_000 && length($value) >= 3 && $value !~ /[._]/ ) {
+    if ( $] >= 5.006_000 && length($value) >= 3 && $value !~ /[._]/
+	&& (ord($value) < ord('0') || ord($value) > ord('9')) ) {
 	my $tvalue = sprintf("v%vd",$value);
-	if ( $tvalue =~ /^v\d+\.\d+\.\d+$/ ) {
+	if ( $tvalue =~ /^v\d+(\.\d+){2,}$/ ) {
 	    # must be a v-string
 	    $value = $tvalue;
 	}