~ chicken-core (chicken-5) 7faa100a2c28225d87f9b934efe5b5fc86fa67a3


commit 7faa100a2c28225d87f9b934efe5b5fc86fa67a3
Author:     Mario Domenech Goulart <Mario.Goulart@bmw.de>
AuthorDate: Tue Sep 17 22:49:03 2024 +0200
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Wed Sep 18 01:04:58 2024 +0200

    batch-driver.scm: Fix logic to create tempfile
    
    Fix the mess introduced by 8ce5a7bfdddb7a537516a.  Only create a
    tempfile when stdout is NOT used.
    
    Thanks to siiky for spotting that.

diff --git a/batch-driver.scm b/batch-driver.scm
index 0cd0a9a0..95a41096 100644
--- a/batch-driver.scm
+++ b/batch-driver.scm
@@ -232,7 +232,8 @@
         ;; Create a temporary file to receive the C code, so that it
         ;; can atomically be renamed to the actual output file after
         ;; the C generation.
-        (tmp-outfile (conc outfile ".tmp." (current-process-id) (current-seconds)))
+        (tmp-outfile (and outfile
+                          (conc outfile ".tmp." (current-process-id) (current-seconds))))
 	(opasses (default-optimization-passes))
 	(time0 #f)
 	(time-breakdown #f)
@@ -888,15 +889,16 @@
 				  (with-output-to-file emit-link-file (cut pp exts))))
 
                                ;; Code generation
-			      (let ((out (if outfile
+			      (let ((out (if tmp-outfile
                                              (open-output-file tmp-outfile)
                                              (current-output-port))) )
-				(dribble "generating `~A' ..." tmp-outfile)
+                                (when tmp-outfile
+                                  (dribble "generating `~A' ..." tmp-outfile))
 				(generate-code literals lliterals lambda-table out filename
 					       user-supplied-options dynamic db dbg-info)
 				(when tmp-outfile
-				  (close-output-port out))
-                                (rename-file tmp-outfile outfile #t))
+                                  (close-output-port out)
+                                  (rename-file tmp-outfile outfile #t)))
 			      (end-time "code generation")
 			      (when (memq 't debugging-chicken)
 				(##sys#display-times (##sys#stop-timer)))
Trap