www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/04/10/13:23:47

From: Martin Str|mberg <ams AT ludd DOT luth DOT se>
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
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 <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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019