I would like to suggest a small patch to improve support of tmpdir.c for non-posix systems compilers like djgpp and other win32 compiler except cygwin. For binaries produced by djgpp and similars that run on Windows/DOS it cannot be assumed that the TMPDIR environment variable is set. Usualy it is not set at all but the TMP and/or TEMP environment variables are almost certainly set. In the case that those are also not set and the compiler does not provide a P_tmpdir value then "./" will be used as tmpdir. This patch would make porting gnu code a little bit easier. Comments, objections, suggestions are welcome.
Regards, Juan M. Guerrero Index: gnulib/lib/tmpdir.c =================================================================== RCS file: /sources/gnulib/gnulib/lib/tmpdir.c,v retrieving revision 1.4 diff -U 4 -r1.4 tmpdir.c --- gnulib/lib/tmpdir.c 1 Nov 2006 03:46:10 -0000 1.4 +++ gnulib/lib/tmpdir.c 6 Feb 2010 23:21:33 -0000 @@ -54,11 +54,18 @@ */ #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ /* Win32, Cygwin, OS/2, DOS */ # define ISSLASH(C) ((C) == '/' || (C) == '\\') +# if defined __CYGWIN__ + /* Cygwin does not honor TEMP nor TMP */ +# define HAVE_DIFFERENT_TMPDIRS 0 +# else +# define HAVE_DIFFERENT_TMPDIRS 1 +# endif #else /* Unix */ # define ISSLASH(C) ((C) == '/') +# define HAVE_DIFFERENT_TMPDIRS 0 #endif /* Return nonzero if DIR is an existent directory. */ @@ -98,8 +105,14 @@ { d = __secure_getenv ("TMPDIR"); if (d != NULL && direxists (d)) dir = d; +#if HAVE_DIFFERENT_TMPDIRS + else if ((d = __secure_getenv ("TMP")) && direxists (d)) + dir = d; + else if ((d = __secure_getenv ("TEMP")) && direxists (d)) + dir = d; +#endif else if (dir != NULL && direxists (dir)) /* nothing */ ; else dir = NULL; @@ -107,10 +120,15 @@ if (dir == NULL) { if (direxists (P_tmpdir)) dir = P_tmpdir; +#if !HAVE_DIFFERENT_TMPDIRS else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp")) dir = "/tmp"; +#else + else if (strcmp (P_tmpdir, ".") != 0 && direxists (".")) + dir = "./"; +#endif else { __set_errno (ENOENT); return -1;