From: Martin Str|mberg Message-Id: <199904101723.TAA12672@father.ludd.luth.se> Subject: TMPDIR=g: for gcc To: pavenis AT lanet DOT lv Date: Sat, 10 Apr 1999 19:23:38 +0200 (MET DST) Cc: djgpp-workers AT delorie DOT com (DJGPP-WORKERS) X-Mailer: ELM [version 2.4ME+ PL15 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Here's a patch to make gcc handle TMPDIR=g: (i. e. without trailing '/' or '\\'). I'm not sure how to add such DJGPP specific thing as "#include " so I just threw it in, hoping somebody here can say how to do that properly. Right, MartinS --- gcc.org/gnu/gcc-2.81/choose-temp.c Wed Dec 3 14:17:00 1997 +++ gcc/gnu/gcc-2.81/choose-temp.c Wed Apr 7 10:26:44 1999 @@ -39,6 +39,8 @@ #include /* May get P_tmpdir. */ +#include /* Necessary to get MAXPATH on *DOZE. */ + #ifdef IN_GCC #include "gansidecl.h" extern char *xmalloc (); @@ -80,11 +82,26 @@ try (dir, base) char *dir, *base; { + char tmp_name[MAXPATH]; + int len; + if (base != 0) return base; - if (dir != 0 - && access (dir, R_OK | W_OK | X_OK) == 0) - return dir; + if (dir != 0) + { + len = strlen(dir); + if (len < MAXPATH - 2) /* For ('/' or '\\') and '\0'. */ + { + strcpy (tmp_name, dir); + if (tmp_name[len-1] != '/' && tmp_name[len-1] != '\\') + { /* Hang on a '/'. */ + tmp_name[len-1] = '/'; + tmp_name[len] = '\0'; + } + if (access (tmp_name, R_OK | W_OK | X_OK) == 0) + return dir; + } + } return 0; }