Change 35027 by [EMAIL PROTECTED] on 2008/12/06 01:05:03

        Integrate:
        [ 34142]
        Upgrade to version 0.76 by John Peacock
        Fix segfault in serialized version objects
        (bug #56606)

Affected files ...

... //depot/maint-5.10/perl/lib/version.pm#2 integrate
... //depot/maint-5.10/perl/lib/version.pod#2 integrate
... //depot/maint-5.10/perl/lib/version.t#2 integrate
... //depot/maint-5.10/perl/util.c#8 integrate

Differences ...

==== //depot/maint-5.10/perl/lib/version.pm#2 (text) ====
Index: perl/lib/version.pm
--- perl/lib/version.pm#1~32694~        2007-12-22 01:23:09.000000000 -0800
+++ perl/lib/version.pm 2008-12-05 17:05:03.000000000 -0800
@@ -6,7 +6,7 @@
 
 use vars qw(@ISA $VERSION $CLASS *qv);
 
-$VERSION = 0.74;
+$VERSION = 0.76;
 
 $CLASS = 'version';
 

==== //depot/maint-5.10/perl/lib/version.pod#2 (text) ====
Index: perl/lib/version.pod
--- perl/lib/version.pod#1~32694~       2007-12-22 01:23:09.000000000 -0800
+++ perl/lib/version.pod        2008-12-05 17:05:03.000000000 -0800
@@ -22,8 +22,12 @@
 =head1 DESCRIPTION
 
 Overloaded version objects for all modern versions of Perl.  This module
-implements all of the features of version objects which will be part
-of Perl 5.10.0.
+implements all of the features of version objects which are part
+of Perl 5.10.0.  All previous releases (i.e. before 0.74) are deprecated
+and should not be used due to incompatible API changes.  If you 'use
+version' in your code, you are strongly urged to set a minimum, e.g. 
+
+  use version 0.74; # to remain compatible with Perl v5.10.0
 
 =head2 BEST PRACTICES
 
@@ -407,6 +411,31 @@
 See also L<UNIVERSAL::VERSION>, as this also returns the stringified form
 when used as a class method.
 
+IMPORTANT NOTE: There is one exceptional cases shown in the above table
+where the "initializer" is not stringwise equivalent to the stringified
+representation.  If you use the C<qv()> operator on a version without a
+leading 'v' B<and> with only a single decimal place, the stringified output
+will have a leading 'v', to preserve the sense.  See the L<qv()> operator
+for more details.
+
+IMPORTANT NOTE 2: Attempting to bypass the normal stringification rules by
+manually applying L<numify()> and L<normal()> will sometimes yield
+surprising results:
+
+  print version->new(version->new("v1.0")->numify)->normal; # v1.0.0
+
+The reason for this is that the L<numify()> operator will turn "v1.0"
+into the equivalent string "1.000000".  Forcing the outer version object
+to L<normal()> form will display the mathematically equivalent "v1.0.0".
+
+As the example in L<new()> shows, you can always create a copy of an
+existing version object with the same value by the very compact:
+
+  $v2 = $v1->new($v1);
+
+and be assured that both C<$v1> and C<$v2> will be completely equivalent,
+down to the same internal representation as well as stringification.
+
 =back
 
 =over 4

==== //depot/maint-5.10/perl/lib/version.t#2 (text) ====
Index: perl/lib/version.t
--- perl/lib/version.t#1~32694~ 2007-12-22 01:23:09.000000000 -0800
+++ perl/lib/version.t  2008-12-05 17:05:03.000000000 -0800
@@ -551,7 +551,13 @@
        is $alpha2, $alpha1, "Don't fall for Data::Dumper's tricks";
     }
 
-
+    {
+       # http://rt.perl.org/rt3/Ticket/Display.html?id=56606
+       my $badv = bless { version => [1,2,3] }, "version";
+       is $badv, '1.002003', "Deal with badly serialized versions from YAML";  
+       my $badv2 = bless { qv => 1, version => [1,2,3] }, "version";
+       is $badv2, 'v1.2.3', "Deal with badly serialized versions from YAML ";  
+    }
 }
 
 1;

==== //depot/maint-5.10/perl/util.c#8 (text) ====
Index: perl/util.c
--- perl/util.c#7~34707~        2008-11-03 11:50:31.000000000 -0800
+++ perl/util.c 2008-12-05 17:05:03.000000000 -0800
@@ -4735,18 +4735,26 @@
 SV *
 Perl_vstringify(pTHX_ SV *vs)
 {
-    SV *pv;
     if ( SvROK(vs) )
        vs = SvRV(vs);
-    
+
     if ( !vverify(vs) )
        Perl_croak(aTHX_ "Invalid version object");
 
-    pv = *hv_fetchs((HV*)vs, "original", FALSE);
-    if ( SvPOK(pv) ) 
-       return newSVsv(pv);
-    else
-       return &PL_sv_undef;
+    if (hv_exists((HV*)vs, "original",  sizeof("original") - 1)) {
+       SV *pv;
+       pv = *hv_fetchs((HV*)vs, "original", FALSE);
+       if ( SvPOK(pv) )
+           return newSVsv(pv);
+       else
+           return &PL_sv_undef;
+    }
+    else {
+       if ( hv_exists((HV *)vs, "qv", 2) )
+           return vnormal(vs);
+       else
+           return vnumify(vs);
+    }
 }
 
 /*
End of Patch.

Reply via email to