# HG changeset patch # User Bruno Haible # Date 1222611597 -7200 # Node ID 24f91ed1cb43f77198249030e7f7232102300220 # Parent d4c4e46404f1c81a7cdde642388c85439fce2e0e Override open more carefully. diff -r d4c4e46404f1 -r 24f91ed1cb43 ChangeLog --- a/ChangeLog Sun Sep 28 16:17:51 2008 +0200 +++ b/ChangeLog Sun Sep 28 16:19:57 2008 +0200 @@ -1,5 +1,12 @@ 2008-09-28 Bruno Haible + Override open more carefully. + * lib/open.c (orig_open): New function. + (rpl_open): Use orig_open instead of open. + * lib/fcntl.in.h: Add special invocation convention. + * m4/open.m4 (gl_PREREQ_OPEN): New macro. + (gl_FUNC_OPEN): Invoke it. + Override freopen more carefully. * lib/freopen.c (orig_freopen): New function. (rpl_freopen): Use orig_freopen instead of freopen. diff -r d4c4e46404f1 -r 24f91ed1cb43 lib/fcntl.in.h --- a/lib/fcntl.in.h Sun Sep 28 16:17:51 2008 +0200 +++ b/lib/fcntl.in.h Sun Sep 28 16:19:57 2008 +0200 @@ -17,9 +17,20 @@ /* written by Paul Eggert */ -#ifndef _GL_FCNTL_H +@PRAGMA_SYSTEM_HEADER@ + +#if defined __need_system_fcntl_h +/* Special invocation convention. */ -@PRAGMA_SYSTEM_HEADER@ +#include +#include +#include +#@INCLUDE_NEXT@ @NEXT_FCNTL_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _GL_FCNTL_H #include #include @@ -121,3 +132,4 @@ #endif /* _GL_FCNTL_H */ #endif /* _GL_FCNTL_H */ +#endif diff -r d4c4e46404f1 -r 24f91ed1cb43 lib/open.c --- a/lib/open.c Sun Sep 28 16:17:51 2008 +0200 +++ b/lib/open.c Sun Sep 28 16:19:57 2008 +0200 @@ -18,6 +18,18 @@ #include +/* Get the original definition of open. It might be defined as a macro. */ +#define __need_system_fcntl_h +#include +#undef __need_system_fcntl_h +#include + +static inline int +orig_open (const char *filename, int flags, mode_t mode) +{ + return open (filename, flags, mode); +} + /* Specification. */ #include @@ -32,7 +44,6 @@ int open (const char *filename, int flags, ...) -# undef open { mode_t mode; int fd; @@ -91,7 +102,7 @@ } # endif - fd = open (filename, flags, mode); + fd = orig_open (filename, flags, mode); # if OPEN_TRAILING_SLASH_BUG /* If the filename ends in a slash and fd does not refer to a directory, diff -r d4c4e46404f1 -r 24f91ed1cb43 m4/open.m4 --- a/m4/open.m4 Sun Sep 28 16:17:51 2008 +0200 +++ b/m4/open.m4 Sun Sep 28 16:19:57 2008 +0200 @@ -1,4 +1,4 @@ -# open.m4 serial 2 +# open.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, @@ -45,8 +45,15 @@ [Define to 1 if open() fails to recognize a trailing slash.]) REPLACE_OPEN=1 AC_LIBOBJ([open]) + gl_PREREQ_OPEN ;; esac ;; esac ]) + +# Prerequisites of lib/open.c. +AC_DEFUN([gl_PREREQ_OPEN], +[ + AC_REQUIRE([AC_C_INLINE]) +])