Split setenv module into setenv and unsetenv. Get rid of setenv.h.
authorBruno Haible <bruno@clisp.org>
Wed, 26 Dec 2007 15:20:10 +0000 (16:20 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 26 Dec 2007 15:20:10 +0000 (16:20 +0100)
18 files changed:
NEWS
doc/functions/unsetenv.texi
lib/getdate.y
lib/relocwrapper.c
lib/setenv.c
lib/setenv.h [deleted file]
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 [new file with mode: 0644]
modules/xsetenv

diff --git a/NEWS b/NEWS
index adb0163..c30b272 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,11 @@ User visible incompatible changes
 
 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>.
 
index 82b00d4..644182a 100644 (file)
@@ -11,11 +11,12 @@ Portability problems fixed by Gnulib:
 @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
index e292f5e..1ed914f 100644 (file)
@@ -66,7 +66,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "setenv.h"
 #include "xalloc.h"
 
 
index ca186c3..76e3559 100644 (file)
@@ -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.
index 75488be..ea1d116 100644 (file)
 #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>
diff --git a/lib/setenv.h b/lib/setenv.h
deleted file mode 100644 (file)
index 9f5d0b7..0000000
+++ /dev/null
@@ -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
index dc9f98f..100ff52 100644 (file)
@@ -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 @@ extern int putenv (char *string);
 #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
index 90b8449..c783997 100644 (file)
@@ -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
 
 #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>
 
index 4939fe1..44e5c3f 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <stdlib.h>
 
-#include "setenv.h"
 #include "error.h"
 #include "gettext.h"
 
index 24b59c2..0b65f4f 100644 (file)
@@ -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" {
index d6901de..bbb5548 100644 (file)
@@ -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 @@ dnl with or without modifications, as long as this notice is preserved.
 
 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 @@ AC_DEFUN([gl_FUNC_SETENV],
 # 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 @@ int unsetenv();
 #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
 ])
index 278df74..fe4ce12 100644 (file)
@@ -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 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   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])
 ])
index 88b51af..59c1abf 100644 (file)
@@ -15,6 +15,7 @@ gettime
 intprops
 mktime
 setenv
+unsetenv
 time
 verify
 xalloc
index 0002774..4a2faf5 100644 (file)
@@ -19,7 +19,6 @@ lib/malloca.h
 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 @@ alloca-opt
 pathmax
 ssize_t
 stdbool
+stdlib
 unistd
 
 configure.ac:
index 9aaf726..1c93bfb 100644 (file)
@@ -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
index 1c6b4f2..07adcd1 100644 (file)
@@ -30,13 +30,18 @@ stdlib.h: stdlib.in.h
              -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
diff --git a/modules/unsetenv b/modules/unsetenv
new file mode 100644 (file)
index 0000000..261c8e4
--- /dev/null
@@ -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
+
index ea313e7..29319f1 100644 (file)
@@ -8,6 +8,7 @@ lib/xsetenv.c
 
 Depends-on:
 setenv
+unsetenv
 error
 exit
 gettext-h