Change 32702 by [EMAIL PROTECTED] on 2007/12/22 16:05:50

        By moving the "can't upgrade downwards" croak() in Perl_sv_upgrade()
        after the type changing logic, we allow sv_upgrade() from SVt_NV to
        SVt_IV to "work" (SVt_NV beomes SVt_PVNV in the type changing logic)
        which simplifies the code for Perl_sv_setiv() slightly.

Affected files ...

... //depot/perl/sv.c#1447 edit

Differences ...

==== //depot/perl/sv.c#1447 (text) ====
Index: perl/sv.c
--- perl/sv.c#1446~32701~       2007-12-22 04:50:35.000000000 -0800
+++ perl/sv.c   2007-12-22 08:05:50.000000000 -0800
@@ -1123,11 +1123,6 @@
     if (old_type == new_type)
        return;
 
-    if (old_type > new_type)
-       Perl_croak(aTHX_ "sv_upgrade from type %d down to type %d",
-               (int)old_type, (int)new_type);
-
-
     old_body = SvANY(sv);
 
     /* Copying structures onto other structures that have been neatly zeroed
@@ -1208,6 +1203,11 @@
            Perl_croak(aTHX_ "Can't upgrade %s (%" UVuf ") to %" UVuf,
                       sv_reftype(sv, 0), (UV) old_type, (UV) new_type);
     }
+
+    if (old_type > new_type)
+       Perl_croak(aTHX_ "sv_upgrade from type %d down to type %d",
+               (int)old_type, (int)new_type);
+
     new_type_details = bodies_by_type + new_type;
 
     SvFLAGS(sv) &= ~SVTYPEMASK;
@@ -1485,10 +1485,8 @@
     SV_CHECK_THINKFIRST_COW_DROP(sv);
     switch (SvTYPE(sv)) {
     case SVt_NULL:
-       sv_upgrade(sv, SVt_IV);
-       break;
     case SVt_NV:
-       sv_upgrade(sv, SVt_PVNV);
+       sv_upgrade(sv, SVt_IV);
        break;
     case SVt_RV:
     case SVt_PV:
End of Patch.

Reply via email to