public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libiberty: Handle Windows nul device in unlink-if-ordinary.c [PR108276]
@ 2023-01-04  3:09 Himal
  2023-01-06  8:23 ` [PATCH] Handle Windows nul device in unlink-if-ordinary.c anothername27-unity
  2023-01-06  8:31 ` anothername27-unity
  0 siblings, 2 replies; 6+ messages in thread
From: Himal @ 2023-01-04  3:09 UTC (permalink / raw)
  To: gcc-patches

libiberty/ChangeLog:
        * unlink-if-ordinary.c (unlink_if_ordinary):
        Handle Windows nul device

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

diff --git a/libiberty/unlink-if-ordinary.c b/libiberty/unlink-if-ordinary.c
index 84328b216..ae9090e54 100644
--- a/libiberty/unlink-if-ordinary.c
+++ b/libiberty/unlink-if-ordinary.c
@@ -62,11 +62,18 @@ 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;
+#else
   struct stat st;

   if (lstat (name, &st) == 0
       && (S_ISREG (st.st_mode) || S_ISLNK (st.st_mode)))
     return unlink (name);
+#endif

   return 1;
 }
--
2.39.0



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-04-29 18:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-04  3:09 [PATCH] libiberty: Handle Windows nul device in unlink-if-ordinary.c [PR108276] Himal
2023-01-06  8:23 ` [PATCH] Handle Windows nul device in unlink-if-ordinary.c anothername27-unity
2023-01-06  8:31 ` anothername27-unity
2023-03-11 20:18   ` Jeff Law
2023-03-13  5:15     ` Himal
2023-04-29 18:10       ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).