summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2009-04-29 15:12:15 +0000
committerIan Lynagh <igloo@earth.li>2009-04-29 15:12:15 +0000
commitd611f0b5e71134cdbc8749aa3c02476d0db5283a (patch)
tree40d83e319b8ad1388d006fcb710134a90f06caf8 /utils
parent46aed8a4a084add708bbd119d19905105d5f0d72 (diff)
downloadhaskell-d611f0b5e71134cdbc8749aa3c02476d0db5283a.tar.gz
In mkdependC.prl, create temp files properly
Avoids a race condition, where one run deletes/overwrites the temp file of another.
Diffstat (limited to 'utils')
-rw-r--r--utils/mkdependC/mkdependC.prl7
1 files changed, 5 insertions, 2 deletions
diff --git a/utils/mkdependC/mkdependC.prl b/utils/mkdependC/mkdependC.prl
index 166c3f16a7..6f06b1cc70 100644
--- a/utils/mkdependC/mkdependC.prl
+++ b/utils/mkdependC/mkdependC.prl
@@ -6,6 +6,9 @@
#
# ToDo: strip out all the .h junk
#
+
+use File::Temp qw/ tempfile tempdir /;;
+
($Pgm = $0) =~ s/.*\/([^\/]+)$/\1/;
$Usage = "usage: $Pgm: not done yet\n";
@@ -178,8 +181,8 @@ sub slurp_file { # follows an example in the `open' item in perl man page
$fname = &tidy_dir_names($fname);
- ($tempfile = $fname) =~ s/\.[^\.]*$/\.d/;
- $tempfile =~ s|.*/([^/]+)$|$1|g;
+ ($fh, $tempfile) = tempfile();
+ close $fh;
# ${CPP} better be 'gcc -E', or the -x option will fail...
# ..and the -MM & -MMD.