On 1/6/23 01:31, anothername27-unity--- via Gcc-patches wrote:
From: Himal <him...@proton.me>

Hi,

This might be a better fix.

Regards.

PS. I had to use a different email.

---
  libiberty/unlink-if-ordinary.c | 6 ++++++
  1 file changed, 6 insertions(+)

diff --git a/libiberty/unlink-if-ordinary.c b/libiberty/unlink-if-ordinary.c
index 84328b216..e765ac8b1 100644
--- a/libiberty/unlink-if-ordinary.c
+++ b/libiberty/unlink-if-ordinary.c
@@ -62,6 +62,12 @@ was made to unlink the file because it is special.
  int
  unlink_if_ordinary (const char *name)
  {
+/* MS-Windows 'stat' function (and in turn, S_ISREG)
+   reports the null device as a regular file.  */
+#ifdef _WIN32
+  if (stricmp (name, "nul") == 0)
+    return 1;
+#endif
Umm, wouldn't this return true for a real file called nul in the current directory? ie, don't you need to distinguish between the nul device and a file named nul based on the full path?

And not being a windows person, I'd really like to see some documentation which indicates that stat on the null device will indicate its a regular file. Alternately if one of the windows experts here can chime in, it'd be appreciated.
jeff

Reply via email to