Storable 2.06 (was Re: Bug in ext/Storable/t/integer.t)
[p5sagit/p5-mst-13.2.git] / mg.c
diff --git a/mg.c b/mg.c
index 9e0b4fa..25f4585 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -57,6 +57,11 @@ S_save_magic(pTHX_ I32 mgs_ix, SV *sv)
 {
     MGS* mgs;
     assert(SvMAGICAL(sv));
+#ifdef PERL_COPY_ON_WRITE
+    /* Turning READONLY off for a copy-on-write scalar is a bad idea.  */
+    if (SvIsCOW(sv))
+      sv_force_normal(sv);
+#endif
 
     SAVEDESTRUCTOR_X(restore_magic, INT2PTR(void*, (IV)mgs_ix));
 
@@ -2057,8 +2062,15 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
            STATUS_POSIX_SET(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv));
        break;
     case '!':
+        {
+#ifdef VMS
+#   define PERL_VMS_BANG vaxc$errno
+#else
+#   define PERL_VMS_BANG 0
+#endif
        SETERRNO(SvIOK(sv) ? SvIVX(sv) : SvOK(sv) ? sv_2iv(sv) : 0,
-                (SvIV(sv) == EVMSERR) ? 4 : vaxc$errno);
+                (SvIV(sv) == EVMSERR) ? 4 : PERL_VMS_BANG);
+       }
        break;
     case '<':
        PL_uid = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);