getsubopt.h is replaced with <stdlib.h>.
authorBruno Haible <bruno@clisp.org>
Mon, 19 Feb 2007 00:08:40 +0000 (00:08 +0000)
committerBruno Haible <bruno@clisp.org>
Mon, 19 Feb 2007 00:08:40 +0000 (00:08 +0000)
ChangeLog
lib/getsubopt.c
lib/getsubopt.h [deleted file]
lib/stdlib_.h
m4/getsubopt.m4
m4/stdlib_h.m4
modules/getsubopt
modules/stdlib

index 5f92874..947bb9e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2007-02-18  Bruno Haible  <bruno@clisp.org>
 
+       * lib/stdlib_.h (getsubopt): New declaration, copied from getsubopt.h.
+       * modules/stdlib (stdlib.h): Also substitute GNULIB_GETSUBOPT and
+       HAVE_GETSUBOPT.
+       * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Also initialize
+       GNULIB_GETSUBOPT and HAVE_GETSUBOPT.
+       * lib/getsubopt.h: Remove file.
+       * modules/getsubopt (Files): Remove lib/getsubopt.h.
+       (Depends-on): Add stdlib.
+       (configure.ac): Invoke gl_STDLIB_MODULE_INDICATOR.
+       (Includes): Use <stdlib.h> instead of getsubopt.h.
+       * m4/getsubopt.m4 (gl_FUNC_GETSUBOPT): Require gl_STDLIB_H_DEFAULTS.
+       Set HAVE_GETSUBOPT.
+       * lib/getsubopt.c: Don't include getsubopt.h.
+
+2007-02-18  Bruno Haible  <bruno@clisp.org>
+
        * modules/fchdir (Depends-on): Add dup2.
 
 2007-02-18  Bruno Haible  <bruno@clisp.org>
index 485a424..cc0859d 100644 (file)
@@ -1,4 +1,4 @@
-/* Parse comma separate list into words.
+/* Parse comma separated list into words.
    Copyright (C) 1996, 1997, 1999, 2004, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -19,7 +19,6 @@
 
 #if !_LIBC
 # include <config.h>
-# include "getsubopt.h"
 #endif
 
 #include <stdlib.h>
diff --git a/lib/getsubopt.h b/lib/getsubopt.h
deleted file mode 100644 (file)
index 5308ef5..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Parse comma separate list into words.
-   Copyright (C) 2004-2005 Free Software Foundation, Inc.
-   Contributed by Simon Josefsson <jas@extundo.com>, 2004.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software Foundation,
-   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
-
-/* Assuming *OPTIONP is a comma separated list of elements of the form
-   "token" or "token=value", getsubopt parses the first of these elements.
-   If the first element refers to a "token" that is member of the given
-   NULL-terminated array of tokens:
-     - It replaces the comma with a NUL byte, updates *OPTIONP to point past
-       the first option and the comma, sets *VALUEP to the value of the
-       element (or NULL if it doesn't contain an "=" sign),
-     - It returns the index of the "token" in the given array of tokens.
-   Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
-   For more details see the POSIX:2001 specification.
-   http://www.opengroup.org/susv3xsh/getsubopt.html */
-
-#if HAVE_GETSUBOPT
-
-/* Get getsubopt declaration.  */
-#include <stdlib.h>
-
-#else
-
-extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
-
-#endif
index 5a23da1..a48f94c 100644 (file)
@@ -44,6 +44,30 @@ extern "C" {
 #endif
 
 
+#if @GNULIB_GETSUBOPT@
+/* Assuming *OPTIONP is a comma separated list of elements of the form
+   "token" or "token=value", getsubopt parses the first of these elements.
+   If the first element refers to a "token" that is member of the given
+   NULL-terminated array of tokens:
+     - It replaces the comma with a NUL byte, updates *OPTIONP to point past
+       the first option and the comma, sets *VALUEP to the value of the
+       element (or NULL if it doesn't contain an "=" sign),
+     - It returns the index of the "token" in the given array of tokens.
+   Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
+   For more details see the POSIX:2001 specification.
+   http://www.opengroup.org/susv3xsh/getsubopt.html */
+# if !@HAVE_GETSUBOPT@
+extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getsubopt
+# define getsubopt(o,t,v) \
+    (GL_LINK_WARNING ("getsubopt is unportable - "\
+                      "use gnulib module getsubopt for portability"), \
+     getsubopt (o, t, v))
+#endif
+
+
 #if @GNULIB_MKDTEMP@
 # if !@HAVE_MKDTEMP@
 /* Create a unique temporary directory from TEMPLATE.
@@ -61,6 +85,7 @@ extern char * mkdtemp (char *template);
      mkdtemp (t))
 #endif
 
+
 #if @GNULIB_MKSTEMP@
 # if @REPLACE_MKSTEMP@
 /* Create a unique temporary file from TEMPLATE.
index 4c479e0..a390a93 100644 (file)
@@ -1,5 +1,5 @@
-# getsubopt.m4 serial 2
-dnl Copyright (C) 2004 Free Software Foundation, Inc.
+# getsubopt.m4 serial 3
+dnl Copyright (C) 2004, 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -9,8 +9,11 @@ AC_DEFUN([gl_FUNC_GETSUBOPT],
   dnl Persuade glibc <stdlib.h> to declare getsubopt().
   AC_REQUIRE([AC_GNU_SOURCE])
 
-  AC_REPLACE_FUNCS(getsubopt)
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([getsubopt])
   if test $ac_cv_func_getsubopt = no; then
+    HAVE_GETSUBOPT=0
+    AC_LIBOBJ([getsubopt])
     gl_PREREQ_GETSUBOPT
   fi
 ])
index 6874441..d46a5f0 100644 (file)
@@ -21,9 +21,11 @@ AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
 
 AC_DEFUN([gl_STDLIB_H_DEFAULTS],
 [
-  GNULIB_MKDTEMP=0;  AC_SUBST([GNULIB_MKDTEMP])
-  GNULIB_MKSTEMP=0;  AC_SUBST([GNULIB_MKSTEMP])
+  GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT])
+  GNULIB_MKDTEMP=0;   AC_SUBST([GNULIB_MKDTEMP])
+  GNULIB_MKSTEMP=0;   AC_SUBST([GNULIB_MKSTEMP])
   dnl Assume proper GNU behavior unless another module says otherwise.
-  HAVE_MKDTEMP=1;    AC_SUBST([HAVE_MKDTEMP])
-  REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
+  HAVE_GETSUBOPT=1;   AC_SUBST([HAVE_GETSUBOPT])
+  HAVE_MKDTEMP=1;     AC_SUBST([HAVE_MKDTEMP])
+  REPLACE_MKSTEMP=0;  AC_SUBST([REPLACE_MKSTEMP])
 ])
index 0ecc321..52e5d9e 100644 (file)
@@ -1,21 +1,22 @@
 Description:
-getsubopt: Parse comma separate list into words.
+getsubopt: Parse comma separated list into words.
 
 Files:
-lib/getsubopt.h
 lib/getsubopt.c
 m4/getsubopt.m4
 
 Depends-on:
 strchrnul
+stdlib
 
 configure.ac:
 gl_FUNC_GETSUBOPT
+gl_STDLIB_MODULE_INDICATOR([getsubopt])
 
 Makefile.am:
 
 Include:
-"getsubopt.h"
+<stdlib.h>
 
 License:
 LGPL
index d23fdc7..6496e0e 100644 (file)
@@ -21,8 +21,10 @@ stdlib.h: stdlib_.h
        rm -f $@-t $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''ABSOLUTE_STDLIB_H''@|$(ABSOLUTE_STDLIB_H)|g' \
+             -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
              -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
              -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
+             -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
              -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
              -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
              -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \