diff options
-rwxr-xr-x | buildtools/configure.pl | 53 | ||||
-rw-r--r-- | doc/HISTORY | 4 |
2 files changed, 47 insertions, 10 deletions
diff --git a/buildtools/configure.pl b/buildtools/configure.pl index efb44ef7..f25c1ada 100755 --- a/buildtools/configure.pl +++ b/buildtools/configure.pl @@ -99,13 +99,17 @@ sub tmpdir() { my $retval; - if ($ENV{"TMPDIR"}) { - $retval = $ENV{"TMPDIR"}; + if ($ENV{'TMPDIR'}) { + $retval = $ENV{'TMPDIR'}; + } elsif ($ENV{'TEMP'}) { + $retval = $ENV{'TEMP'}; } else { - if ($Config{'osvers'} eq "djgpp") { - $retval = "/dev/env/DJDIR/tmp"; + if ($Config{'osvers'} eq 'djgpp') { + $retval = '/dev/env/DJDIR/tmp'; } else { - $retval = "/tmp"; + if (-d('/tmp')) { + $retval = '/tmp'; + } } } return $retval; @@ -122,14 +126,43 @@ sub tempFile($) { # DIR=>File::Spec->tmpdir(), # UNLINK=>0); my ($suffix) = @_; + my $fileName; local *file; # For some inexplicable reason, must be local, not my - my $i; - $i = 0; - do { - $fileName = tmpdir() . "/netpbm" . $i++ . $suffix; - } until sysopen(*file, $fileName, O_RDWR|O_CREAT|O_EXCL); + my $tmpdir = tmpdir(); + + if (!defined($tmpdir)) { + print STDERR ("Cannot determine what directory to use for " . + "temporary files. " . + "Set TMPDIR environment variable to fix this.\n"); + exit(1); + } else { + if (!-d($tmpdir)) { + print STDERR ("Temporary file directory '$tmpdir' does not " . + "exist. Create it or set TMPDIR environment " . + "variable appropriately\n"); + exit(1); + } else { + for (my $i = 0; $i < 50 && !defined($fileName); ++$i) { + my $trialFileName = tmpdir() . "/netpbm" . $i . $suffix; + + my $success = sysopen(*file, + $trialFileName, + O_RDWR|O_CREAT|O_EXCL); + + if ($success) { + $fileName = $trialFileName; + } + } + + if (!defined($fileName)) { + print STDERR ("Unable to create a temporary file in " . + "directory '$tmpdir'\n"); + exit(1); + } + } + } return(*file, $fileName); } diff --git a/doc/HISTORY b/doc/HISTORY index 07f2383d..2a194ddb 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -62,6 +62,10 @@ not yet BJH Release 10.47.00 Lots of changes to integer code, bit access, word access, etc. None functional. Some speedup. + configure: use TEMP environment variable for TMPDIR if TMPDIR + is not set. Don't try different temp file names forever; the + problem may not be the filename. + 09.03.29 BJH Release 10.46.00 xwdtopnm: Add -cmapdump . |