+2002-03-04 Bruno Haible <bruno@clisp.org>
+
+ Portability to AIX 4.3.3.
+ * unsetenv.c: New file, extracted from setenv.c.
+ * setenv.c: Move the unsetenv() function to unsetenv.c.
+ * setenv.h: Cope with systems that have setenv() but not unsetenv().
+ * Makefile.am (LIBADD_SOURCE): Add unsetenv.c.
+ (c-ctype.lo, tmpdir.lo): Depend on stdbool.h.
+
2002-02-21 Bruno Haible <bruno@clisp.org>
* strncasecmp.c (__strncasecmp): Trivial simplification.
memset.c \
mkdtemp.h mkdtemp.c \
pfnmatch.h pfnmatch.c \
- setenv.h setenv.c \
+ setenv.h setenv.c unsetenv.c \
libstdarg.h \
stpcpy.h stpcpy.c \
stpncpy.h stpncpy.c \
DISTCLEANFILES = fnmatch.h
-all-local execute.lo javacomp.lo javaexec.lo pipe-bidi.lo pipe-in.lo pipe-out.lo progname.lo wait-process.lo xerror.lo: @STDBOOL_H@
+all-local c-ctype.lo execute.lo javacomp.lo javaexec.lo pipe-bidi.lo pipe-in.lo pipe-out.lo progname.lo tmpdir.lo wait-process.lo xerror.lo: @STDBOOL_H@
stdbool.h: stdbool.h.in
cp $(srcdir)/stdbool.h.in stdbool.h
MOSTLYCLEANFILES = @STDBOOL_H@
-/* Copyright (C) 1992,95,96,97,98,99,2000,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1992,1995-1999,2000-2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
/* In the GNU C library we must keep the namespace clean. */
#ifdef _LIBC
# define setenv __setenv
-# define unsetenv __unsetenv
# define clearenv __clearenv
# define tfind __tfind
# define tsearch __tsearch
return __add_to_environ (name, value, NULL, replace);
}
-int
-unsetenv (name)
- const char *name;
-{
- size_t len;
- char **ep;
-
- if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
- {
- __set_errno (EINVAL);
- return -1;
- }
-
- len = strlen (name);
-
- LOCK;
-
- ep = __environ;
- while (*ep != NULL)
- if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
- {
- /* Found it. Remove this pointer by moving later ones back. */
- char **dp = ep;
-
- do
- dp[0] = dp[1];
- while (*dp++);
- /* Continue the loop in case NAME appears again. */
- }
- else
- ++ep;
-
- UNLOCK;
-
- return 0;
-}
-
/* The `clearenv' was planned to be added to POSIX.1 but probably
never made it. Nevertheless the POSIX.9 standard (POSIX bindings
for Fortran 77) requires this function. */
return 0;
}
+
#ifdef _LIBC
static void
free_mem (void)
# undef setenv
-# undef unsetenv
# undef clearenv
weak_alias (__setenv, setenv)
-weak_alias (__unsetenv, unsetenv)
weak_alias (__clearenv, clearenv)
#endif
# endif
#endif
-#if HAVE_SETENV
+#if HAVE_SETENV || HAVE_UNSETENV
/* Get setenv(), unsetenv() declarations. */
#include <stdlib.h>
-#else
+#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 PARAMS ((const char *name, const char *value, int replace));
+#endif
+
+#if !HAVE_UNSETENV
+
/* Remove the variable NAME from the environment. */
extern int unsetenv PARAMS ((const char *name));
-#ifdef __cplusplus
-}
#endif
+#ifdef __cplusplus
+}
#endif
--- /dev/null
+/* Copyright (C) 1992,1995-1999,2000-2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <errno.h>
+#if !_LIBC
+# if !defined errno && !defined HAVE_ERRNO_DECL
+extern int errno;
+# endif
+# define __set_errno(ev) ((errno) = (ev))
+#endif
+
+#if _LIBC || HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+#if _LIBC || HAVE_STRING_H
+# include <string.h>
+#endif
+#if _LIBC || HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#if !_LIBC
+# define __environ environ
+# ifndef HAVE_ENVIRON_DECL
+extern char **environ;
+# endif
+#endif
+
+#if _LIBC
+/* This lock protects against simultaneous modifications of `environ'. */
+# include <bits/libc-lock.h>
+__libc_lock_define_initialized (static, envlock)
+# define LOCK __libc_lock_lock (envlock)
+# define UNLOCK __libc_lock_unlock (envlock)
+#else
+# define LOCK
+# define UNLOCK
+#endif
+
+/* In the GNU C library we must keep the namespace clean. */
+#ifdef _LIBC
+# define unsetenv __unsetenv
+#endif
+
+
+int
+unsetenv (name)
+ const char *name;
+{
+ size_t len;
+ char **ep;
+
+ if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ len = strlen (name);
+
+ LOCK;
+
+ ep = __environ;
+ while (*ep != NULL)
+ if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
+ {
+ /* Found it. Remove this pointer by moving later ones back. */
+ char **dp = ep;
+
+ do
+ dp[0] = dp[1];
+ while (*dp++);
+ /* Continue the loop in case NAME appears again. */
+ }
+ else
+ ++ep;
+
+ UNLOCK;
+
+ return 0;
+}
+
+#ifdef _LIBC
+# undef unsetenv
+weak_alias (__unsetenv, unsetenv)
+#endif
+2002-03-04 Bruno Haible <bruno@clisp.org>
+
+ * setenv.m4 (gt_FUNC_SETENV): Also check whether unsetenv is missing.
+
2002-03-02 Bruno Haible <bruno@clisp.org>
* gettext.m4 (AM_GNU_GETTEXT): Set LIBINTL and LTLIBINTL to empty if
-# setenv.m4 serial 1 (gettext-0.11)
+# setenv.m4 serial 2 (gettext-0.11.1)
dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
AC_DEFUN([gt_FUNC_SETENV],
[
- AC_REPLACE_FUNCS(setenv)
+ AC_REPLACE_FUNCS(setenv unsetenv)
AC_CHECK_HEADERS(search.h stdlib.h string.h unistd.h)
AC_CHECK_FUNCS(tsearch)
gt_CHECK_VAR_DECL([#include <errno.h>], errno)