From 6608ac42ed5557e8340a1f45679c619909b751a1 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 28 Sep 2008 16:12:20 +0200 Subject: [PATCH] Override fopen more carefully. --- ChangeLog | 9 +++++++++ lib/fopen.c | 14 ++++++++++++-- m4/fopen.m4 | 9 ++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c301503c62..56bc03067c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-09-28 Bruno Haible + + Override fopen more carefully. + * lib/fopen.c (orig_fopen): New function. + (rpl_fopen): Use orig_fopen instead of open. + * m4/fopen.m4 (gl_PREREQ_FOPEN): New macro. + (gl_FUNC_FOPEN): Invoke it. + Needed on AIX. Reported by Rainer Tammer . + 2008-09-28 Bruno Haible * lib/pipe.h (create_pipe_out, create_pipe_bidi): Add comment about 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 +/* Get the original definition of fopen. It might be defined as a macro. */ +#define __need_FILE +#include +#undef __need_FILE + +static inline FILE * +orig_fopen (const char *filename, const char *mode) +{ + return fopen (filename, mode); +} + /* Specification. */ #include @@ -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); } diff --git a/m4/fopen.m4 b/m4/fopen.m4 index c1bbe88421..8f81a4a244 100644 --- a/m4/fopen.m4 +++ b/m4/fopen.m4 @@ -1,4 +1,4 @@ -# fopen.m4 serial 2 +# fopen.m4 serial 3 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -43,8 +43,15 @@ changequote([,])dnl [Define to 1 if fopen() fails to recognize a trailing slash.]) REPLACE_FOPEN=1 AC_LIBOBJ([fopen]) + gl_PREREQ_FOPEN ;; esac ;; esac ]) + +# Prerequisites of lib/fopen.c. +AC_DEFUN([gl_PREREQ_FOPEN], +[ + AC_REQUIRE([AC_C_INLINE]) +]) -- 2.30.2