bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] use gnulib modules close (new) and open to hook into open/cl


From: Bruno Haible
Subject: Re: [PATCH] use gnulib modules close (new) and open to hook into open/close
Date: Thu, 9 Oct 2008 13:20:31 +0200
User-agent: KMail/1.5.4

Hello Paolo,

> >   - Declare all functions defined in one .c file and used in another .c file
> >     in a .h file. This is a basic principle, which
> >       1. avoids passing too few or too many arguments to a function after
> >          a couple of refactorings,
> 
> Yes, I wasn't sure about how to do this, as I couldn't find examples of
> such internal functions in gnulib.

There's also the possibility to use internal header files, such as
acl-internal.h, getopt_int.h, printf-args.h, printf-parse.h, regex_internal.h,
spawn_int.h. But it did not seem worth here, for just 2 function declarations.

> >   - m4/close.m4: It's gl_REPLACE_CLOSE which assigns a value to 
> > REPLACE_CLOSE,
> >     therefore it's this macro which needs to require gl_UNISTD_H_DEFAULTS.
> 
> Isn't this a problem if gl_REPLACE_CLOSE is called conditionally
> (which it almost always is)?

No, it isn't, because gl_REPLACE_CLOSE is not called conditionally from the
top-level in configure.ac. Quoting the AC_REQUIRE doc:

   "if one macro depends upon
    another, the latter is expanded _before_ the body of the former.  To be
    more precise, the required macro is expanded before the outermost
    defined macro in the current expansion stack."

The outermost defined macro, here, is gl_INIT, and should not be invoked
conditionally.

> I'm passing the ball to you then.

OK, I'm starting the commits by applying this step 1.


2008-10-09  Paolo Bonzini  <address@hidden>

        Fix organization of 'open' replacement.
        * m4/open.m4 (gl_REPLACE_OPEN): New macro.
        (gl_FUNC_OPEN): Use it.
        (gl_PREREQ_OPEN): Add a : to make the body non-empty.

--- m4/open.m4.orig     2008-10-09 13:18:50.000000000 +0200
+++ m4/open.m4  2008-10-09 13:14:41.000000000 +0200
@@ -1,4 +1,4 @@
-# open.m4 serial 3
+# open.m4 serial 4
 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,
@@ -6,12 +6,10 @@
 
 AC_DEFUN([gl_FUNC_OPEN],
 [
-  AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
   AC_REQUIRE([AC_CANONICAL_HOST])
   case "$host_os" in
     mingw* | pw*)
-      REPLACE_OPEN=1
-      AC_LIBOBJ([open])
+      gl_REPLACE_OPEN
       ;;
     *)
       dnl open("foo/") should not create a file when the file name has a
@@ -43,17 +41,26 @@
         *no)
           AC_DEFINE([OPEN_TRAILING_SLASH_BUG], 1,
             [Define to 1 if open() fails to recognize a trailing slash.])
-          REPLACE_OPEN=1
-          AC_LIBOBJ([open])
-          gl_PREREQ_OPEN
+          gl_REPLACE_OPEN
           ;;
       esac
       ;;
   esac
 ])
 
+AC_DEFUN([gl_REPLACE_OPEN],
+[
+  AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
+  if test $REPLACE_OPEN != 1; then
+    AC_LIBOBJ([open])
+    gl_PREREQ_OPEN
+  fi
+  REPLACE_OPEN=1
+])
+
 # Prerequisites of lib/open.c.
 AC_DEFUN([gl_PREREQ_OPEN],
 [
   AC_REQUIRE([AC_C_INLINE])
+  :
 ])





reply via email to

[Prev in Thread] Current Thread [Next in Thread]