From 1efbb72ac42f18c3ab03bfd570535482b92bdbbc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net>
Date: Tue, 23 Mar 1999 10:10:01 -0800
Subject: [PATCH] moved location of temporary object files..

Rev: NT/tools/rntcc:1.23
---
 NT/tools/rntcc | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/NT/tools/rntcc b/NT/tools/rntcc
index 4b2c649a54..f5ee62dbde 100755
--- a/NT/tools/rntcc
+++ b/NT/tools/rntcc
@@ -14,6 +14,17 @@ int verbose=0;
 // Temporary variable
 int linking_failed;
 
+// Files to remove upon exit
+string *tmpfiles=({});
+
+void exit(int code)
+{
+  if(getenv("CLEANUP")!="no")
+    Array.map(tmpfiles,rm);
+
+  predef::exit(code);
+}
+
 string get_ext(string file)
 {
   sscanf(file=lower_case(reverse(file)),"%s.",file);
@@ -243,6 +254,7 @@ int main(int argc, string *argv)
 
   string errorfile="tmp"+getpid()+".err";
   rm(errorfile);
+  tmpfiles+=({errorfile});
 
   // Flags required to make the compiler behave well
   cflags+=({"-bm","-zq","-sg","-5","-fpi87","-fp3"});
@@ -275,23 +287,22 @@ int main(int argc, string *argv)
     }
 
     case "link":
+      int objnum;
       foreach(sources, string source)
 	{
-	  string obj=reverse(source);
-	  sscanf(obj,"%*s.%s",obj);
-	  obj=reverse(obj)+".obj";
-
+	  string obj=sprintf("TMP%dX%d.obj",getpid(),objnum++);
 	  compile( ({source}), obj, errorfile, cflags);
 	  objects+=({obj});
+	  tmpfiles+=({obj});
 	  check_errorfile(errorfile);
 	}
 
 //      objects+=({"BINMODE.OBJ"});
       string ldfile="TMP"+getpid()+".lk";
+      tmpfiles+=({ldfile});
       if(!output) output="a.out";
       rm(ldfile);
 
-
       target=output;
       if(!share) target+=".exe";
 
@@ -315,8 +326,6 @@ int main(int argc, string *argv)
 	  linking_failed++;
       });
 
-      if(getenv("CLEANUP")!="no")
-	rm(ldfile);
 
       if(linking_failed) exit(1);
   }
-- 
GitLab