[PATCH ld/maint-diff-quiet-w] Windows: redirect fopen("/dev/null") to fopen("nul")

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

 



From: Johannes Sixt <j6t@xxxxxxxx>

An instance of fopen("/dev/null",...) was added to the code base. On
Windows, we have to use "nul" instead. This implements a compatibility
wrapper of fopen() that checks for this particular condition.

Signed-off-by: Johannes Sixt <j6t@xxxxxxxx>
---
 compat/mingw.c |    8 ++++++++
 compat/mingw.h |    3 +++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/compat/mingw.c b/compat/mingw.c
index 5edf152..57aec93 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -140,6 +140,14 @@ int mingw_open (const char *filename, int oflags, ...)
 	return fd;
 }

+#undef fopen
+FILE *mingw_fopen (const char *filename, const char *otype)
+{
+	if (!strcmp(filename, "/dev/null"))
+		filename = "nul";
+	return fopen(filename, otype);
+}
+
 /*
  * The unit of FILETIME is 100-nanoseconds since January 1, 1601, UTC.
  * Returns the 100-nanoseconds ("hekto nanoseconds") since the epoch.
diff --git a/compat/mingw.h b/compat/mingw.h
index f53bcca..e187b04 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -170,6 +170,9 @@ int link(const char *oldpath, const char *newpath);
 int mingw_open (const char *filename, int oflags, ...);
 #define open mingw_open

+FILE *mingw_fopen (const char *filename, const char *otype);
+#define fopen mingw_fopen
+
 char *mingw_getcwd(char *pointer, int len);
 #define getcwd mingw_getcwd

-- 
1.7.0.1285.g1a907.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]