Mercurial > hg > octave-nkf > gnulib-hg
changeset 10533:d4b37870fdc9
Override open more carefully.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 28 Sep 2008 16:19:57 +0200 |
parents | 81789aaf2d0b |
children | 4587ff5a50b5 |
files | ChangeLog lib/fcntl.in.h lib/open.c m4/open.m4 |
diffstat | 4 files changed, 42 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2008-09-28 Bruno Haible <bruno@clisp.org> + 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.
--- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h @@ -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 <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#@INCLUDE_NEXT@ @NEXT_FCNTL_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _GL_FCNTL_H #include <sys/types.h> #include <sys/stat.h> @@ -121,3 +132,4 @@ #endif /* _GL_FCNTL_H */ #endif /* _GL_FCNTL_H */ +#endif
--- a/lib/open.c +++ b/lib/open.c @@ -18,6 +18,18 @@ #include <config.h> +/* Get the original definition of open. It might be defined as a macro. */ +#define __need_system_fcntl_h +#include <fcntl.h> +#undef __need_system_fcntl_h +#include <sys/types.h> + +static inline int +orig_open (const char *filename, int flags, mode_t mode) +{ + return open (filename, flags, mode); +} + /* Specification. */ #include <fcntl.h> @@ -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,
--- a/m4/open.m4 +++ b/m4/open.m4 @@ -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]) +])