summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2007-02-19 00:08:40 +0000
committerBruno Haible <bruno@clisp.org>2007-02-19 00:08:40 +0000
commit41dccf6a007ea2fdc0eebd71f5bb3b73be43669f (patch)
treedba3436732206fd40763099c9f5c77153a084503
parentc002371c8ca3c2e0cd689b84bc5e94721ba00255 (diff)
downloadgnulib-41dccf6a007ea2fdc0eebd71f5bb3b73be43669f.tar.gz
getsubopt.h is replaced with <stdlib.h>.
-rw-r--r--ChangeLog16
-rw-r--r--lib/getsubopt.c3
-rw-r--r--lib/getsubopt.h40
-rw-r--r--lib/stdlib_.h25
-rw-r--r--m4/getsubopt.m49
-rw-r--r--m4/stdlib_h.m410
-rw-r--r--modules/getsubopt7
-rw-r--r--modules/stdlib2
8 files changed, 60 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index 5f92874715..947bb9e5ce 100644
--- 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>
diff --git a/lib/getsubopt.c b/lib/getsubopt.c
index 485a424927..cc0859d783 100644
--- a/lib/getsubopt.c
+++ b/lib/getsubopt.c
@@ -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
index 5308ef5e71..0000000000
--- a/lib/getsubopt.h
+++ /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
diff --git a/lib/stdlib_.h b/lib/stdlib_.h
index 5a23da1e83..a48f94cdf2 100644
--- a/lib/stdlib_.h
+++ b/lib/stdlib_.h
@@ -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.
diff --git a/m4/getsubopt.m4 b/m4/getsubopt.m4
index 4c479e0a5d..a390a939f8 100644
--- a/m4/getsubopt.m4
+++ b/m4/getsubopt.m4
@@ -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
])
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index 6874441fc0..d46a5f06db 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -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])
])
diff --git a/modules/getsubopt b/modules/getsubopt
index 0ecc321bb1..52e5d9e87e 100644
--- a/modules/getsubopt
+++ b/modules/getsubopt
@@ -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
diff --git a/modules/stdlib b/modules/stdlib
index d23fdc785f..6496e0ed14 100644
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -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)' \