bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

supersede: Support the file name "/dev/null" on native Windows


From: Bruno Haible
Subject: supersede: Support the file name "/dev/null" on native Windows
Date: Sun, 03 Jul 2022 12:02:38 +0200

On native Windows, msgfmt (which uses the 'supersede' module) fails when
passed the options   -o /dev/null

We have code already to map "/dev/null" to "NUL" on this platform (so that
we don't have to conditionalize this constant in tests and scripts) in
  open.c
  fopen.c
  freopen.c
This patch does the same thing in supersede.c.


2022-07-03  Bruno Haible  <bruno@clisp.org>

        supersede: Support the file name "/dev/null" on native Windows.
        * lib/supersede.c (open_supersede): On native Windows, map "/dev/null"
        to "NUL".

diff --git a/lib/supersede.c b/lib/supersede.c
index 6207286980..a72c4f40e8 100644
--- a/lib/supersede.c
+++ b/lib/supersede.c
@@ -93,6 +93,11 @@ open_supersede (const char *filename, int flags, mode_t mode,
     0;
     #endif
 
+#if defined _WIN32 && ! defined __CYGWIN__
+  if (strcmp (filename, "/dev/null") == 0)
+    filename = "NUL";
+#endif
+
   if (supersede_if_exists)
     {
       if (supersede_if_does_not_exist)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]