Mail Archives: djgpp-workers/1999/04/10/13:23:47
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 <dir.h>"
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 <stdio.h> /* May get P_tmpdir. */
+#include <dir.h> /* 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;
}
- Raw text -