987d88
diff --git a/editor/ppmfade b/editor/ppmfade
9ec283
index dcd7bf2..5091651 100755
987d88
--- a/editor/ppmfade
987d88
+++ b/editor/ppmfade
987d88
@@ -40,6 +40,7 @@ exec perl -w -x -S -- "$0" "$@"
cvsdist 686ba4
 #
987d88
 ##############################################################################
cvsdist 686ba4
 use strict;
cvsdist 686ba4
+use File::Temp "tempdir";
cvsdist 686ba4
 
9ec283
 sub doVersionHack($) {
9ec283
     my ($argvR) = @_;
9ec283
@@ -149,20 +150,26 @@ if ($first_file ne "undefined") {
cvsdist 686ba4
 
cvsdist 686ba4
 print("Frames are " . $width . "W x " . $height . "H\n");
cvsdist 686ba4
 
cvsdist 686ba4
+#
cvsdist 686ba4
+# We create a tmp-directory right here
cvsdist 686ba4
+#
cvsdist 686ba4
+my $tmpdir = tempdir("ppmfade.XXXXXX", CLEANUP => 1);
cvsdist 686ba4
+
cvsdist 686ba4
+
cvsdist 686ba4
 if ($first_file eq "undefined") {
cvsdist 686ba4
     print "Fading from black to ";
cvsdist 686ba4
-    system("ppmmake \\#000 $width $height >junk1$$.ppm");
cvsdist 686ba4
+    system("ppmmake \\#000 $width $height >$tmpdir/junk1$$.ppm");
cvsdist 686ba4
 } else {
cvsdist 686ba4
     print "Fading from $first_file to ";
cvsdist 686ba4
-    system("cp", $first_file, "junk1$$.ppm");
cvsdist 686ba4
+    system("cp", $first_file, "$tmpdir/junk1$$.ppm");
cvsdist 686ba4
 }
cvsdist 686ba4
 
cvsdist 686ba4
 if ($last_file eq "undefined") {
cvsdist 686ba4
     print "black.\n";
cvsdist 686ba4
-    system("ppmmake \\#000 $width $height >junk2$$.ppm");
cvsdist 686ba4
+    system("ppmmake \\#000 $width $height >$tmpdir/junk2$$.ppm");
cvsdist 686ba4
 } else {
cvsdist 686ba4
     print "$last_file\n";
cvsdist 686ba4
-    system("cp", $last_file, "junk2$$.ppm");
cvsdist 686ba4
+    system("cp", $last_file, "$tmpdir/junk2$$.ppm");
cvsdist 686ba4
 }
cvsdist 686ba4
 
cvsdist 686ba4
 #
9ec283
@@ -170,14 +177,14 @@ if ($last_file eq "undefined") {
21b205
 #
21b205
 
21b205
 # Here's what our temporary files are:
21b205
-#   junk1$$.ppm: The original (fade-from) image
21b205
-#   junk2$$.ppm: The target (fade-from) image
21b205
-#   junk3$$.ppm: The frame of the fade for the current iteration of the 
21b205
-#                the for loop.
21b205
-#   junk1a$$.ppm: If the fade involves a ppmmix sequence from one intermediate
21b205
-#                 image to another, this is the first frame of that 
21b205
-#                 sequence.
21b205
-#   junk2a$$.ppm: This is the last frame of the above-mentioned ppmmix sequence
21b205
+#   $tmpdir/junk1$$.ppm: The original (fade-from) image
21b205
+#   $tmpdir/junk2$$.ppm: The target (fade-from) image
21b205
+#   $tmpdir/junk3$$.ppm: The frame of the fade for the current iteration of the 
21b205
+#                	 the for loop.
21b205
+#   $tmpdir/junk1a$$.ppm: If the fade involves a ppmmix sequence from one intermediate
21b205
+#                         image to another, this is the first frame of that 
21b205
+#                         sequence.
21b205
+#   $tmpdir/junk2a$$.ppm: This is the last frame of the above-mentioned ppmmix sequence
21b205
 
21b205
 my $i;    # Frame number
21b205
 for ($i = 1; $i <= $nframes; $i++) {
9ec283
@@ -185,147 +192,147 @@ for ($i = 1; $i <= $nframes; $i++) {
cvsdist 686ba4
     if ($mode eq $SPREAD) {
cvsdist 686ba4
         if ($i <= 10) {
cvsdist 686ba4
             my $n = $spline20[$i] * 100;
cvsdist 686ba4
-            system("ppmspread $n junk1$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmspread $n $tmpdir/junk1$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         } elsif ($i <= 20) {
cvsdist 686ba4
             my $n;
cvsdist 686ba4
             $n = $spline20[$i] * 100;
cvsdist 686ba4
-            system("ppmspread $n junk1$$.ppm >junk1a$$.ppm");
cvsdist 686ba4
+            system("ppmspread $n $tmpdir/junk1$$.ppm >$tmpdir/junk1a$$.ppm");
cvsdist 686ba4
             $n = (1-$spline20[$i-10]) * 100;
cvsdist 686ba4
-            system("ppmspread $n junk2$$.ppm >junk2a$$.ppm");
cvsdist 686ba4
+            system("ppmspread $n $tmpdir/junk2$$.ppm >$tmpdir/junk2a$$.ppm");
cvsdist 686ba4
             $n = $spline10[$i-10];
cvsdist 686ba4
-            system("ppmmix $n junk1a$$.ppm junk2a$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmmix $n $tmpdir/junk1a$$.ppm $tmpdir/junk2a$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         } else {
cvsdist 686ba4
             my $n = (1-$spline20[$i-10])*100;
cvsdist 686ba4
-            system("ppmspread $n junk2$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmspread $n $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         }
cvsdist 686ba4
     } elsif ($mode eq $SHIFT) {
cvsdist 686ba4
         if ($i <= 10) {
cvsdist 686ba4
             my $n = $spline20[$i] * 100;
cvsdist 686ba4
-            system("ppmshift $n junk1$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmshift $n $tmpdir/junk1$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         } elsif ($i <= 20) {
cvsdist 686ba4
             my $n;
cvsdist 686ba4
             $n = $spline20[$i] * 100;
cvsdist 686ba4
-            system("ppmshift $n junk1$$.ppm >junk1a$$.ppm");
cvsdist 686ba4
+            system("ppmshift $n $tmpdir/junk1$$.ppm >$tmpdir/junk1a$$.ppm");
cvsdist 686ba4
             $n = (1-$spline20[$i-10])*100;
cvsdist 686ba4
-            system("ppmshift $n junk2$$.ppm >junk2a$$.ppm");
cvsdist 686ba4
+            system("ppmshift $n $tmpdir/junk2$$.ppm >$tmpdir/junk2a$$.ppm");
cvsdist 686ba4
             $n = $spline10[$i-10];
cvsdist 686ba4
-            system("ppmmix $n junk1a$$.ppm junk2a$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmmix $n $tmpdir/junk1a$$.ppm $tmpdir/junk2a$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         } else {
cvsdist 686ba4
             my $n = (1-$spline20[$i-10]) * 100;
cvsdist 686ba4
-            system("ppmshift $n junk2$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmshift $n $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         }
cvsdist 686ba4
     } elsif ($mode eq $RELIEF) {
cvsdist 686ba4
         if ($i == 1) {
cvsdist 686ba4
-            system("ppmrelief junk1$$.ppm >junk1r$$.ppm");
cvsdist 686ba4
+            system("ppmrelief $tmpdir/junk1$$.ppm >$tmpdir/junk1r$$.ppm");
cvsdist 686ba4
         }
cvsdist 686ba4
         if ($i <= 10) {
cvsdist 686ba4
             my $n = $spline10[$i];
cvsdist 686ba4
-            system("ppmmix $n junk1$$.ppm junk1r$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1r$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         } elsif ($i <= 20) {
cvsdist 686ba4
             my $n = $spline10[$i-10];
cvsdist 686ba4
-            system("ppmmix $n junk1r$$.ppm junk2r$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmmix $n $tmpdir/junk1r$$.ppm $tmpdir/junk2r$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         } else {
cvsdist 686ba4
             my $n = $spline10[$i-20];
cvsdist 686ba4
-            system("ppmmix $n junk2r$$.ppm junk2$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmmix $n $tmpdir/junk2r$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         }
cvsdist 686ba4
         if ($i == 10) {
cvsdist 686ba4
-            system("ppmrelief junk2$$.ppm >junk2r$$.ppm");
cvsdist 686ba4
+            system("ppmrelief $tmpdir/junk2$$.ppm >$tmpdir/junk2r$$.ppm");
cvsdist 686ba4
         }
cvsdist 686ba4
     } elsif ($mode eq $OIL) {
cvsdist 686ba4
         if ($i == 1) {
cvsdist 686ba4
-            system("ppmtopgm junk1$$.ppm | pgmoil >junko$$.ppm");
cvsdist 686ba4
-            system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
cvsdist 686ba4
-                   ">junk1o$$.ppm");
cvsdist 686ba4
+            system("ppmtopgm $tmpdir/junk1$$.ppm | pgmoil >$tmpdir/junko$$.ppm");
cvsdist 686ba4
+            system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
cvsdist 686ba4
+                   ">$tmpdir/junk1o$$.ppm");
cvsdist 686ba4
         }
cvsdist 686ba4
         if ($i <= 10) {
cvsdist 686ba4
             my $n = $spline10[$i];
cvsdist 686ba4
-            system("ppmmix $n junk1$$.ppm junk1o$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1o$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         } elsif ($i <= 20) {
cvsdist 686ba4
             my $n = $spline10[$i-10];
cvsdist 686ba4
-            system("ppmmix $n junk1o$$.ppm junk2o$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmmix $n $tmpdir/junk1o$$.ppm $tmpdir/junk2o$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         } else {
cvsdist 686ba4
             my $n = $spline10[$i-20];
cvsdist 686ba4
-            system("ppmmix $n junk2o$$.ppm junk2$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmmix $n $tmpdir/junk2o$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         }
cvsdist 686ba4
         if ($i == 10) {
cvsdist 686ba4
-            system("ppmtopgm junk2$$.ppm | pgmoil >junko$$.ppm");
cvsdist 686ba4
-            system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
cvsdist 686ba4
-                   ">junk2o$$.ppm");
cvsdist 686ba4
+            system("ppmtopgm $tmpdir/junk2$$.ppm | pgmoil >$tmpdir/junko$$.ppm");
cvsdist 686ba4
+            system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
cvsdist 686ba4
+                   ">$tmpdir/junk2o$$.ppm");
cvsdist 686ba4
         }
cvsdist 686ba4
     } elsif ($mode eq $EDGE) {
cvsdist 686ba4
         if ($i == 1) {
cvsdist 686ba4
-            system("ppmtopgm junk1$$.ppm | pgmedge >junko$$.ppm");
cvsdist 686ba4
-            system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
cvsdist 686ba4
-                   ">junk1o$$.ppm");
cvsdist 686ba4
+            system("ppmtopgm $tmpdir/junk1$$.ppm | pgmedge >$tmpdir/junko$$.ppm");
cvsdist 686ba4
+            system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
cvsdist 686ba4
+                   ">$tmpdir/junk1o$$.ppm");
cvsdist 686ba4
         }
cvsdist 686ba4
         if ($i <= 10) {
cvsdist 686ba4
             my $n = $spline10[$i];
cvsdist 686ba4
-            system("ppmmix $n junk1$$.ppm junk1o$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1o$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         } elsif ($i <= 20) {
cvsdist 686ba4
             my $n = $spline10[$i-10];
cvsdist 686ba4
-            system("ppmmix $n junk1o$$.ppm junk2o$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmmix $n $tmpdir/junk1o$$.ppm $tmpdir/junk2o$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         } else {
cvsdist 686ba4
             my $n = $spline10[$i-20];
cvsdist 686ba4
-            system("ppmmix $n junk2o$$.ppm junk2$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmmix $n $tmpdir/junk2o$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         }
cvsdist 686ba4
         if ($i == 10) {
cvsdist 686ba4
-            system("ppmtopgm junk2$$.ppm | pgmedge >junko$$.ppm");
cvsdist 686ba4
-            system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
cvsdist 686ba4
-                   ">junk2o$$.ppm");
cvsdist 686ba4
+            system("ppmtopgm $tmpdir/junk2$$.ppm | pgmedge >$tmpdir/junko$$.ppm");
cvsdist 686ba4
+            system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
cvsdist 686ba4
+                   ">$tmpdir/junk2o$$.ppm");
cvsdist 686ba4
         } 
cvsdist 686ba4
     } elsif ($mode eq $BENTLEY) {
cvsdist 686ba4
         if ($i == 1) {
cvsdist 686ba4
-            system("ppmtopgm junk1$$.ppm | pgmbentley >junko$$.ppm");
cvsdist 686ba4
-            system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
cvsdist 686ba4
-                   ">junk1o$$.ppm");
cvsdist 686ba4
+            system("ppmtopgm $tmpdir/junk1$$.ppm | pgmbentley >$tmpdir/junko$$.ppm");
cvsdist 686ba4
+            system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
cvsdist 686ba4
+                   ">$tmpdir/junk1o$$.ppm");
cvsdist 686ba4
         }
cvsdist 686ba4
         if ($i <= 10) {
cvsdist 686ba4
             my $n = $spline10[$i];
cvsdist 686ba4
-            system("ppmmix $n junk1$$.ppm junk1o$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1o$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         } elsif ($i <= 20) {
cvsdist 686ba4
             my $n = $spline10[$i-10];
cvsdist 686ba4
-            system("ppmmix $n junk1o$$.ppm junk2o$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmmix $n $tmpdir/junk1o$$.ppm $tmpdir/junk2o$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         } else {
cvsdist 686ba4
             my $n = $spline10[$i-20];
cvsdist 686ba4
-            system("ppmmix $n junk2o$$.ppm junk2$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmmix $n $tmpdir/junk2o$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         }
cvsdist 686ba4
         if ($i == 10) {
cvsdist 686ba4
-            system("ppmtopgm junk2$$.ppm | pgmbentley >junko$$.ppm");
cvsdist 686ba4
-            system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
cvsdist 686ba4
-                   ">junk2o$$.ppm");
cvsdist 686ba4
+            system("ppmtopgm $tmpdir/junk2$$.ppm | pgmbentley >$tmpdir/junko$$.ppm");
21b205
+            system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
cvsdist 686ba4
+                   ">$tmpdir/junk2o$$.ppm");
cvsdist 686ba4
         }
cvsdist 686ba4
     } elsif ($mode eq $BLOCK) {
cvsdist 686ba4
         if ($i <= 10) {
cvsdist 686ba4
             my $n = 1 - 1.9*$spline20[$i];
21b205
-            system("pamscale $n junk1$$.ppm | " .
21b205
-                   "pamscale -width $width -height $height >junk3$$.ppm");
21b205
+            system("pamscale $n $tmpdir/junk1$$.ppm | " .
21b205
+                   "pamscale -width $width -height $height >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         } elsif ($i <= 20) {
cvsdist 686ba4
             my $n = $spline10[$i-10];
cvsdist 686ba4
-            system("ppmmix $n junk1a$$.ppm junk2a$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+            system("ppmmix $n $tmpdir/junk1a$$.ppm $tmpdir/junk2a$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         } else {
cvsdist 686ba4
             my $n = 1 - 1.9*$spline20[31-$i];
21b205
-            system("pamscale $n junk2$$.ppm | " .
21b205
-                   "pamscale -width $width -height $height >junk3$$.ppm");
21b205
+            system("pamscale $n $tmpdir/junk2$$.ppm | " .
21b205
+                   "pamscale -width $width -height $height >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
         }
cvsdist 686ba4
         if ($i == 10) {
cvsdist 686ba4
-            system("cp", "junk3$$.ppm", "junk1a$$.ppm");
21b205
-            system("pamscale $n junk2$$.ppm | " .
21b205
-                   "pamscale -width $width -height $height >junk2a$$.ppm");
cvsdist 686ba4
+            system("cp", "$tmpdir/junk3$$.ppm", "$tmpdir/junk1a$$.ppm");
21b205
+            system("pamscale $n $tmpdir/junk2$$.ppm | " .
21b205
+                   "pamscale -width $width -height $height >$tmpdir/junk2a$$.ppm");
cvsdist 686ba4
         }    
cvsdist 686ba4
     } elsif ($mode eq $MIX) {
cvsdist 686ba4
         my $fade_factor = sqrt(1/($nframes-$i+1));
cvsdist 686ba4
-        system("ppmmix $fade_factor junk1$$.ppm junk2$$.ppm >junk3$$.ppm");
cvsdist 686ba4
+        system("ppmmix $fade_factor $tmpdir/junk1$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
cvsdist 686ba4
     } else {
cvsdist 686ba4
         print("Internal error: impossible mode value '$mode'\n");
cvsdist 686ba4
     }
cvsdist 686ba4
 
cvsdist 686ba4
     my $outfile = sprintf("%s.%04d.ppm", $base_name, $i);
cvsdist 686ba4
-    system("cp", "junk3$$.ppm", $outfile);
cvsdist 686ba4
+    system("cp", "$tmpdir/junk3$$.ppm", $outfile);
cvsdist 686ba4
 }
cvsdist 686ba4
 
cvsdist 686ba4
 #
cvsdist 686ba4
 #  Clean up shop.
cvsdist 686ba4
 #
cvsdist 686ba4
-system("rm junk*$$.ppm");
21b205
+system("rm $tmpdir/junk*$$.ppm");
cvsdist 686ba4
 
cvsdist 686ba4
 exit(0);