summaryrefslogtreecommitdiff
path: root/lib/fopen.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2008-09-28 16:12:20 +0200
committerBruno Haible <bruno@clisp.org>2008-09-28 16:12:20 +0200
commit6608ac42ed5557e8340a1f45679c619909b751a1 (patch)
tree32250cc4bab010a96cc35387e43693d8bbaccff5 /lib/fopen.c
parent8df2459e40ab2ee726f4532c0699d4f7a40717d0 (diff)
downloadgnulib-6608ac42ed5557e8340a1f45679c619909b751a1.tar.gz
Override fopen more carefully.
Diffstat (limited to 'lib/fopen.c')
-rw-r--r--lib/fopen.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/fopen.c b/lib/fopen.c
index d6e048b79b..b20d3bcd5a 100644
--- a/lib/fopen.c
+++ b/lib/fopen.c
@@ -18,6 +18,17 @@
#include <config.h>
+/* Get the original definition of fopen. It might be defined as a macro. */
+#define __need_FILE
+#include <stdio.h>
+#undef __need_FILE
+
+static inline FILE *
+orig_fopen (const char *filename, const char *mode)
+{
+ return fopen (filename, mode);
+}
+
/* Specification. */
#include <stdio.h>
@@ -28,7 +39,6 @@
FILE *
rpl_fopen (const char *filename, const char *mode)
-#undef fopen
{
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
if (strcmp (filename, "/dev/null") == 0)
@@ -89,5 +99,5 @@ rpl_fopen (const char *filename, const char *mode)
}
# endif
- return fopen (filename, mode);
+ return orig_fopen (filename, mode);
}