From 64cf49aa25e22d54010493cb2d57b685b0e85446 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Windows 11)" <rob@synchro.net>
Date: Thu, 23 Nov 2023 15:44:52 -0800
Subject: [PATCH] Add FCLOSE_OPEN_FILE to close a FILE*, if it's open
 (non-NULL), and NULLify it

Change CLOSE_OPEN_FILE to a do/while(0) to eliminate extraneous semicolon
---
 src/xpdev/filewrap.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/xpdev/filewrap.h b/src/xpdev/filewrap.h
index c187e65904..0ff267bc67 100644
--- a/src/xpdev/filewrap.h
+++ b/src/xpdev/filewrap.h
@@ -150,7 +150,8 @@
 #define O_DENYNONE		SH_DENYNO
 #endif
 
-#define CLOSE_OPEN_FILE(x)	while((x) >= 0) { close(x); (x)=-1; break; }
+#define CLOSE_OPEN_FILE(x)	do { if((x) >= 0)    { close(x);  (x) = -1;   } } while(0)
+#define FCLOSE_OPEN_FILE(x)	do { if((x) != NULL) { fclose(x); (x) = NULL; } } while(0)
 
 /**************/
 /* Prototypes */
-- 
GitLab