[differences between cumulative patch application and perl5.004_01]
[p5sagit/p5-mst-13.2.git] / mg.c
diff --git a/mg.c b/mg.c
index 3d1e1ee..eb58886 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -591,7 +591,7 @@ MAGIC* mg;
     }
 #endif
 
-#if !defined(OS2) && !defined(AMIGAOS) && !defined(_WIN32)
+#if !defined(OS2) && !defined(AMIGAOS) && !defined(WIN32)
                            /* And you'll never guess what the dog had */
                            /*   in its mouth... */
     if (tainting) {
@@ -639,7 +639,7 @@ MAGIC* mg;
            }
        }
     }
-#endif /* neither OS2 nor AMIGAOS nor _WIN32 */
+#endif /* neither OS2 nor AMIGAOS nor WIN32 */
 
     return 0;
 }
@@ -654,10 +654,29 @@ MAGIC* mg;
 }
 
 int
-magic_clear_all_env()
+magic_clear_all_env(sv,mg)
+SV* sv;
+MAGIC* mg;
 {
-#if defined(VMS) || defined(WIN32)
-    DIE("'%ENV = @list;' is not implemented on this machine");
+#if defined(VMS)
+    die("Can't make list assignment to %%ENV on this system");
+#else
+#ifdef WIN32
+    char *envv = GetEnvironmentStrings();
+    char *cur = envv;
+    STRLEN len;
+    while (*cur) {
+       char *end = strchr(cur,'=');
+       if (end && end != cur) {
+           *end = '\0';
+           my_setenv(cur,Nullch);
+           *end = '=';
+           cur += strlen(end+1)+1;
+       }
+       else if ((len = strlen(cur)))
+           cur += len+1;
+    }
+    FreeEnvironmentStrings(envv);
 #else
     I32 i;
 
@@ -668,8 +687,9 @@ magic_clear_all_env()
            Safefree(environ[i]);
     environ[0] = Nullch;
 
-    return 0;
 #endif
+#endif
+    return 0;
 }
 
 int
@@ -1216,7 +1236,7 @@ SV* sv;
                croak(no_aelem, (I32)LvTARGOFF(sv));
        }
     }
-    SvREFCNT_inc(value);
+    (void)SvREFCNT_inc(value);
     SvREFCNT_dec(LvTARG(sv));
     LvTARG(sv) = value;
     LvTARGLEN(sv) = 0;