changeset 29236:ac34a764569d

Split setenv module into setenv and unsetenv. Get rid of setenv.h.
author Bruno Haible <bruno@clisp.org>
date Wed, 26 Dec 2007 16:20:10 +0100
parents dcfae8124cd4
children 4642f5a84b96
files NEWS doc/functions/unsetenv.texi lib/getdate.y lib/relocwrapper.c lib/setenv.c lib/setenv.h lib/stdlib.in.h lib/unsetenv.c lib/xsetenv.c lib/xsetenv.h m4/setenv.m4 m4/stdlib_h.m4 modules/getdate modules/relocatable-prog-wrapper modules/setenv modules/stdlib modules/unsetenv modules/xsetenv
diffstat 18 files changed, 94 insertions(+), 73 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed Dec 26 16:13:28 2007 +0100
+++ b/NEWS	Wed Dec 26 16:20:10 2007 +0100
@@ -6,6 +6,11 @@
 
 Date        Modules         Changes
 
+2007-12-24  setenv          The include file is changed from "setenv.h" to
+                            <stdlib.h>. Also, the unsetenv function is no
+                            longer declared in this module; use the 'unsetenv'
+                            module if you need it.
+
 2007-12-03  getpagesize     The include file is changed from "getpagesize.h"
                             to <unistd.h>.
 
--- a/doc/functions/unsetenv.texi	Wed Dec 26 16:13:28 2007 +0100
+++ b/doc/functions/unsetenv.texi	Wed Dec 26 16:20:10 2007 +0100
@@ -11,11 +11,12 @@
 @item
 This function is missing on some platforms:
 AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 9, mingw, BeOS.
+@item
+This function has the return type @samp{void} instead of @samp{int} on some
+platforms:
+MacOS X 10.3, FreeBSD 6.0, NetBSD 1.6, OpenBSD 3.8, OSF/1 5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This function has the return type @samp{void} instead of @samp{int} on some
-platforms.
 @end itemize
--- a/lib/getdate.y	Wed Dec 26 16:13:28 2007 +0100
+++ b/lib/getdate.y	Wed Dec 26 16:20:10 2007 +0100
@@ -66,7 +66,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "setenv.h"
 #include "xalloc.h"
 
 
--- a/lib/relocwrapper.c	Wed Dec 26 16:13:28 2007 +0100
+++ b/lib/relocwrapper.c	Wed Dec 26 16:20:10 2007 +0100
@@ -53,7 +53,6 @@
 
 #include "progname.h"
 #include "relocatable.h"
-#include "setenv.h"
 #include "c-ctype.h"
 
 /* Return a copy of the filename, with an extra ".bin" at the end.
--- a/lib/setenv.c	Wed Dec 26 16:13:28 2007 +0100
+++ b/lib/setenv.c	Wed Dec 26 16:20:10 2007 +0100
@@ -19,12 +19,14 @@
 #endif
 #include <alloca.h>
 
+/* Specification.  */
+#include <stdlib.h>
+
 #include <errno.h>
 #ifndef __set_errno
 # define __set_errno(ev) ((errno) = (ev))
 #endif
 
-#include <stdlib.h>
 #include <string.h>
 #if _LIBC || HAVE_UNISTD_H
 # include <unistd.h>
--- a/lib/setenv.h	Wed Dec 26 16:13:28 2007 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/* Setting environment variables.
-   Copyright (C) 2001-2004, 2007 Free Software Foundation, Inc.
-
-   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 3 of the License, 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, see <http://www.gnu.org/licenses/>.  */
-
-#if HAVE_SETENV || HAVE_UNSETENV
-
-/* Get setenv(), unsetenv() declarations.  */
-# include <stdlib.h>
-
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if !HAVE_SETENV
-
-/* Set NAME to VALUE in the environment.
-   If REPLACE is nonzero, overwrite an existing value.  */
-extern int setenv (const char *name, const char *value, int replace);
-
-#endif
-
-#if HAVE_UNSETENV
-
-# if VOID_UNSETENV
-/* On some systems, unsetenv() returns void.
-   This is the case for FreeBSD 4.8, NetBSD 1.6, OpenBSD 3.4.  */
-#  define unsetenv(name) ((unsetenv)(name), 0)
-# endif
-
-#else
-
-/* Remove the variable NAME from the environment.  */
-extern int unsetenv (const char *name);
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
--- a/lib/stdlib.in.h	Wed Dec 26 16:13:28 2007 +0100
+++ b/lib/stdlib.in.h	Wed Dec 26 16:20:10 2007 +0100
@@ -1,6 +1,6 @@
 /* A GNU-like <stdlib.h>.
 
-   Copyright (C) 1995, 2001-2002, 2006-2007 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2001-2004, 2006-2007 Free Software Foundation, Inc.
 
    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
@@ -176,6 +176,29 @@
 #endif
 
 
+#if @GNULIB_SETENV@
+# if !@HAVE_SETENV@
+/* Set NAME to VALUE in the environment.
+   If REPLACE is nonzero, overwrite an existing value.  */
+extern int setenv (const char *name, const char *value, int replace);
+# endif
+#endif
+
+
+#if @GNULIB_UNSETENV@
+# if @HAVE_UNSETENV@
+#  if @VOID_UNSETENV@
+/* On some systems, unsetenv() returns void.
+   This is the case for MacOS X 10.3, FreeBSD 4.8, NetBSD 1.6, OpenBSD 3.4.  */
+#   define unsetenv(name) ((unsetenv)(name), 0)
+#  endif
+# else
+/* Remove the variable NAME from the environment.  */
+extern int unsetenv (const char *name);
+# endif
+#endif
+
+
 #ifdef __cplusplus
 }
 #endif
--- a/lib/unsetenv.c	Wed Dec 26 16:13:28 2007 +0100
+++ b/lib/unsetenv.c	Wed Dec 26 16:20:10 2007 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992,1995-1999,2000-2002,2005-2006 Free Software Foundation, Inc.
+/* Copyright (C) 1992,1995-1999,2000-2002,2005-2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    This program is free software: you can redistribute it and/or modify
@@ -16,12 +16,14 @@
 
 #include <config.h>
 
+/* Specification.  */
+#include <stdlib.h>
+
 #include <errno.h>
 #if !_LIBC
 # define __set_errno(ev) ((errno) = (ev))
 #endif
 
-#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
--- a/lib/xsetenv.c	Wed Dec 26 16:13:28 2007 +0100
+++ b/lib/xsetenv.c	Wed Dec 26 16:20:10 2007 +0100
@@ -21,7 +21,6 @@
 
 #include <stdlib.h>
 
-#include "setenv.h"
 #include "error.h"
 #include "gettext.h"
 
--- a/lib/xsetenv.h	Wed Dec 26 16:13:28 2007 +0100
+++ b/lib/xsetenv.h	Wed Dec 26 16:20:10 2007 +0100
@@ -15,7 +15,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* Get unsetenv().  It can be used without error checking.  */
-#include "setenv.h"
+#include <stdlib.h>
 
 #ifdef __cplusplus
 extern "C" {
--- a/m4/setenv.m4	Wed Dec 26 16:13:28 2007 +0100
+++ b/m4/setenv.m4	Wed Dec 26 16:20:10 2007 +0100
@@ -1,4 +1,4 @@
-# setenv.m4 serial 8
+# setenv.m4 serial 9
 dnl Copyright (C) 2001-2004, 2006-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,
@@ -6,8 +6,10 @@
 
 AC_DEFUN([gl_FUNC_SETENV],
 [
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   AC_CHECK_FUNCS_ONCE([setenv])
   if test $ac_cv_func_setenv = no; then
+    HAVE_SETENV=0
     AC_LIBOBJ([setenv])
     gl_PREREQ_SETENV
   fi
@@ -16,14 +18,20 @@
 # Like gl_FUNC_SETENV, except prepare for separate compilation (no AC_LIBOBJ).
 AC_DEFUN([gl_FUNC_SETENV_SEPARATE],
 [
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   AC_CHECK_FUNCS_ONCE([setenv])
+  if test $ac_cv_func_setenv = no; then
+    HAVE_SETENV=0
+  fi
   gl_PREREQ_SETENV
 ])
 
 AC_DEFUN([gl_FUNC_UNSETENV],
 [
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   AC_CHECK_FUNCS([unsetenv])
   if test $ac_cv_func_unsetenv = no; then
+    HAVE_UNSETENV=0
     AC_LIBOBJ([unsetenv])
     gl_PREREQ_UNSETENV
   else
@@ -40,7 +48,7 @@
 #endif
 ], , gt_cv_func_unsetenv_ret='int', gt_cv_func_unsetenv_ret='void')])
     if test $gt_cv_func_unsetenv_ret = 'void'; then
-      AC_DEFINE(VOID_UNSETENV, 1, [Define if unsetenv() returns void, not int.])
+      VOID_UNSETENV=1
     fi
   fi
 ])
--- a/m4/stdlib_h.m4	Wed Dec 26 16:13:28 2007 +0100
+++ b/m4/stdlib_h.m4	Wed Dec 26 16:20:10 2007 +0100
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 4
+# stdlib_h.m4 serial 5
 dnl Copyright (C) 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,
@@ -26,12 +26,17 @@
   GNULIB_MKDTEMP=0;       AC_SUBST([GNULIB_MKDTEMP])
   GNULIB_MKSTEMP=0;       AC_SUBST([GNULIB_MKSTEMP])
   GNULIB_PUTENV=0;        AC_SUBST([GNULIB_PUTENV])
+  GNULIB_SETENV=0;        AC_SUBST([GNULIB_SETENV])
+  GNULIB_UNSETENV=0;      AC_SUBST([GNULIB_UNSETENV])
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_CALLOC_POSIX=1;    AC_SUBST([HAVE_CALLOC_POSIX])
   HAVE_GETSUBOPT=1;       AC_SUBST([HAVE_GETSUBOPT])
   HAVE_MALLOC_POSIX=1;    AC_SUBST([HAVE_MALLOC_POSIX])
   HAVE_MKDTEMP=1;         AC_SUBST([HAVE_MKDTEMP])
   HAVE_REALLOC_POSIX=1;   AC_SUBST([HAVE_REALLOC_POSIX])
+  HAVE_SETENV=1;          AC_SUBST([HAVE_SETENV])
+  HAVE_UNSETENV=1;        AC_SUBST([HAVE_UNSETENV])
   REPLACE_MKSTEMP=0;      AC_SUBST([REPLACE_MKSTEMP])
   REPLACE_PUTENV=0;       AC_SUBST([REPLACE_PUTENV])
+  VOID_UNSETENV=0;        AC_SUBST([VOID_UNSETENV])
 ])
--- a/modules/getdate	Wed Dec 26 16:13:28 2007 +0100
+++ b/modules/getdate	Wed Dec 26 16:20:10 2007 +0100
@@ -15,6 +15,7 @@
 intprops
 mktime
 setenv
+unsetenv
 time
 verify
 xalloc
--- a/modules/relocatable-prog-wrapper	Wed Dec 26 16:13:28 2007 +0100
+++ b/modules/relocatable-prog-wrapper	Wed Dec 26 16:20:10 2007 +0100
@@ -19,7 +19,6 @@
 lib/malloca.c
 lib/relocatable.h
 lib/relocatable.c
-lib/setenv.h
 lib/setenv.c
 lib/strerror.c
 lib/c-ctype.h
@@ -38,6 +37,7 @@
 pathmax
 ssize_t
 stdbool
+stdlib
 unistd
 
 configure.ac:
--- a/modules/setenv	Wed Dec 26 16:13:28 2007 +0100
+++ b/modules/setenv	Wed Dec 26 16:20:10 2007 +0100
@@ -1,26 +1,24 @@
 Description:
 setenv() function: set an environment variable.
-unsetenv() function: remove an environment variable.
 
 Files:
-lib/setenv.h
 lib/setenv.c
-lib/unsetenv.c
 m4/setenv.m4
 
 Depends-on:
+stdlib
 malloca
 alloca-opt
 unistd
 
 configure.ac:
 gl_FUNC_SETENV
-gl_FUNC_UNSETENV
+gl_STDLIB_MODULE_INDICATOR([setenv])
 
 Makefile.am:
 
 Include:
-"setenv.h"
+<stdlib.h>
 
 License:
 LGPL
--- a/modules/stdlib	Wed Dec 26 16:13:28 2007 +0100
+++ b/modules/stdlib	Wed Dec 26 16:20:10 2007 +0100
@@ -30,13 +30,18 @@
 	      -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
 	      -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
 	      -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
+	      -e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \
+	      -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
 	      -e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \
 	      -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
 	      -e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \
 	      -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
 	      -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \
+	      -e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \
+	      -e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \
 	      -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
 	      -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
+	      -e 's|@''VOID_UNSETENV''@|$(VOID_UNSETENV)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
 	      < $(srcdir)/stdlib.in.h; \
 	} > $@-t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/unsetenv	Wed Dec 26 16:20:10 2007 +0100
@@ -0,0 +1,26 @@
+Description:
+unsetenv() function: remove an environment variable.
+
+Files:
+lib/unsetenv.c
+m4/setenv.m4
+
+Depends-on:
+stdlib
+unistd
+
+configure.ac:
+gl_FUNC_UNSETENV
+gl_STDLIB_MODULE_INDICATOR([unsetenv])
+
+Makefile.am:
+
+Include:
+<stdlib.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- a/modules/xsetenv	Wed Dec 26 16:13:28 2007 +0100
+++ b/modules/xsetenv	Wed Dec 26 16:20:10 2007 +0100
@@ -8,6 +8,7 @@
 
 Depends-on:
 setenv
+unsetenv
 error
 exit
 gettext-h