]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Portability to AIX 4.3.3.
authorBruno Haible <bruno@clisp.org>
Mon, 4 Mar 2002 20:29:02 +0000 (20:29 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:07:46 +0000 (12:07 +0200)
lib/ChangeLog
lib/Makefile.am
lib/setenv.c
lib/setenv.h
lib/unsetenv.c [new file with mode: 0644]
m4/ChangeLog
m4/setenv.m4

index 4953d02747e48b1b4319652d3eebbc547f034554..371e4f2a48c4717fb99129a24edb9a051f9c0f93 100644 (file)
@@ -1,3 +1,12 @@
+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.
index 39471eca587f841bdd771a42fbe58a03c7e2cd98..a566bd891ef4eae63f5862a5ff6199d4e81e7e24 100644 (file)
@@ -68,7 +68,7 @@ LIBADD_SOURCE = \
   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 \
@@ -116,7 +116,7 @@ INCLUDES = -I. -I$(srcdir) -I.. -I../intl -I$(top_srcdir)/intl
 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@
index 9653604de9cff09b4cb551eaf2d279b5e8d96679..c0047a149c287ef7f4adc8b4c60f0fe4dd4279bd 100644 (file)
@@ -1,4 +1,4 @@
-/* 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
@@ -60,7 +60,6 @@ __libc_lock_define_initialized (static, envlock)
 /* 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
@@ -267,43 +266,6 @@ setenv (name, value, replace)
   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.  */
@@ -326,6 +288,7 @@ clearenv ()
 
   return 0;
 }
+
 #ifdef _LIBC
 static void
 free_mem (void)
@@ -341,9 +304,7 @@ text_set_element (__libc_subfreeres, free_mem);
 
 
 # undef setenv
-# undef unsetenv
 # undef clearenv
 weak_alias (__setenv, setenv)
-weak_alias (__unsetenv, unsetenv)
 weak_alias (__clearenv, clearenv)
 #endif
index 594787785657c1bda187369618d59e4dd246c801..49e7c5d3164c9a253ea78bfa8add154fa95e1283 100644 (file)
 # 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
diff --git a/lib/unsetenv.c b/lib/unsetenv.c
new file mode 100644 (file)
index 0000000..56b35f0
--- /dev/null
@@ -0,0 +1,105 @@
+/* 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
index a7df09907cc87e658191da3398ac27745fc0019d..d13c147a69a66052b72575943c43aaeb9eab5d2e 100644 (file)
@@ -1,3 +1,7 @@
+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
index b27d057466534bf566e6614cbcd060b6434aa585..832193b5f39c2bf9e6907eb17a7ee21a7da110f4 100644 (file)
@@ -1,4 +1,4 @@
-# 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
@@ -29,7 +29,7 @@ AC_DEFUN([gt_CHECK_VAR_DECL],
 
 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)