mirror of
https://git.savannah.gnu.org/git/make.git
synced 2024-12-25 05:29:46 +00:00
tests: Preserve Windows temp environment variables
* src/main.c (main): Show the temp filename on error. Also on Windows prefer TMP, then TEMP, and only lastly TMPDIR. * tests/test_driver.pl: Add TMP, TEMP, and USERPROFILE to the list of environment variables to preserve.
This commit is contained in:
parent
2be8661433
commit
8cdaabbf8e
2 changed files with 13 additions and 12 deletions
15
src/main.c
15
src/main.c
|
@ -1799,13 +1799,12 @@ main (int argc, char **argv, char **envp)
|
|||
#endif
|
||||
#define DEFAULT_TMPFILE "GmXXXXXX"
|
||||
|
||||
if (((tmpdir = getenv ("TMPDIR")) == NULL || *tmpdir == '\0')
|
||||
if (
|
||||
#if defined (__MSDOS__) || defined (WINDOWS32) || defined (__EMX__)
|
||||
/* These are also used commonly on these platforms. */
|
||||
&& ((tmpdir = getenv ("TEMP")) == NULL || *tmpdir == '\0')
|
||||
&& ((tmpdir = getenv ("TMP")) == NULL || *tmpdir == '\0')
|
||||
((tmpdir = getenv ("TMP")) == NULL || *tmpdir == '\0') &&
|
||||
((tmpdir = getenv ("TEMP")) == NULL || *tmpdir == '\0') &&
|
||||
#endif
|
||||
)
|
||||
((tmpdir = getenv ("TMPDIR")) == NULL || *tmpdir == '\0'))
|
||||
tmpdir = DEFAULT_TMPDIR;
|
||||
|
||||
template = alloca (strlen (tmpdir) + CSTRLEN (DEFAULT_TMPFILE) + 2);
|
||||
|
@ -1824,13 +1823,15 @@ main (int argc, char **argv, char **envp)
|
|||
strcat (template, DEFAULT_TMPFILE);
|
||||
outfile = get_tmpfile (&stdin_nm, template);
|
||||
if (outfile == 0)
|
||||
pfatal_with_name (_("fopen (temporary file)"));
|
||||
OSS (fatal, NILF,
|
||||
_("fopen: temporary file %s: %s"), newnm, strerror (errno));
|
||||
while (!feof (stdin) && ! ferror (stdin))
|
||||
{
|
||||
char buf[2048];
|
||||
size_t n = fread (buf, 1, sizeof (buf), stdin);
|
||||
if (n > 0 && fwrite (buf, 1, n, outfile) != n)
|
||||
pfatal_with_name (_("fwrite (temporary file)"));
|
||||
OSS (fatal, NILF,
|
||||
_("fwrite: temporary file %s: %s"), newnm, strerror (errno));
|
||||
}
|
||||
fclose (outfile);
|
||||
|
||||
|
|
|
@ -173,16 +173,16 @@ sub toplevel
|
|||
{
|
||||
# Pull in benign variables from the user's environment
|
||||
|
||||
foreach (# UNIX-specific things
|
||||
foreach (# POSIX-specific things
|
||||
'TZ', 'TMPDIR', 'HOME', 'USER', 'LOGNAME', 'PATH',
|
||||
'LD_LIBRARY_PATH',
|
||||
# SAN things
|
||||
# *SAN things
|
||||
'ASAN_OPTIONS', 'UBSAN_OPTIONS',
|
||||
# Purify things
|
||||
'PURIFYOPTIONS',
|
||||
# Windows NT-specific stuff
|
||||
'Path', 'SystemRoot',
|
||||
# DJGPP-specific stuff
|
||||
# Windows-specific things
|
||||
'Path', 'SystemRoot', 'TEMP', 'TMP', 'USERPROFILE',
|
||||
# DJGPP-specific things
|
||||
'DJDIR', 'DJGPP', 'SHELL', 'COMSPEC', 'HOSTNAME', 'LFN',
|
||||
'FNCASE', '387', 'EMU387', 'GROUP'
|
||||
) {
|
||||
|
|
Loading…
Reference in a new issue