bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Build failure on Solaris with CVS


From: Albert Chin
Subject: Build failure on Solaris with CVS
Date: Tue, 2 Nov 2004 17:13:31 -0600
User-agent: Mutt/1.5.6i

lib/getdate.y calls setenv() but Solaris only has putenv(). So, I
copied in m4/setenv.m4 and lib/unsetenv.c from gnulib and added the
gt_FUNC_SETENV call to configure.ac to use lib/setenv.c and
lib/unsetenv.c

-- 
albert chin (address@hidden)

-- snip snip
2004-11-02  Albert Chin <address@hidden>

        * configure.ac: Add call to gt_FUNC_SETENV to use
        lib/setenv.c and lib/unsetenv.c if host does not
        have setenv()/unsetenv().
        * lib/unsetenv.c, m4/setenv.m4: New file.

--- configure.ac        28 Jul 2004 06:58:09 -0000      1.53
+++ configure.ac        2 Nov 2004 23:10:56 -0000
@@ -232,6 +232,9 @@ AC_CHECK_DECLS([strsignal, sys_siglist, 
 # For src/kill.c and src/printf.c.
 AC_CHECK_DECLS([strtoimax, strtoumax])
 
+# For lib/setenv.c and lib/unsetenv.c.
+gt_FUNC_SETENV
+
 gl_LIB_CHECK
 
 AM_GNU_GETTEXT([external], [need-ngettext])
--- /dev/null   Sun Mar 24 15:28:28 2002
+++ m4/setenv.m4        Tue Nov  2 16:39:51 2004
@@ -0,0 +1,72 @@
+# setenv.m4 serial 5
+dnl Copyright (C) 2001-2004 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
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+AC_DEFUN([gt_FUNC_SETENV],
+[
+  AC_REPLACE_FUNCS(setenv unsetenv)
+  if test $ac_cv_func_setenv = no; then
+    gl_PREREQ_SETENV
+  fi
+  if test $ac_cv_func_unsetenv = no; then
+    gl_PREREQ_UNSETENV
+  else
+    AC_CACHE_CHECK([for unsetenv() return type], gt_cv_func_unsetenv_ret,
+      [AC_TRY_COMPILE([#include <stdlib.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+int unsetenv (const char *name);
+#else
+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.])
+    fi
+  fi
+])
+
+# Check if a variable is properly declared.
+# gt_CHECK_VAR_DECL(includes,variable)
+AC_DEFUN([gt_CHECK_VAR_DECL],
+[
+  define([gt_cv_var], [gt_cv_var_]$2[_declaration])
+  AC_MSG_CHECKING([if $2 is properly declared])
+  AC_CACHE_VAL(gt_cv_var, [
+    AC_TRY_COMPILE([$1
+      extern struct { int foo; } $2;],
+      [$2.foo = 1;],
+      gt_cv_var=no,
+      gt_cv_var=yes)])
+  AC_MSG_RESULT($gt_cv_var)
+  if test $gt_cv_var = yes; then
+    AC_DEFINE([HAVE_]translit($2, [a-z], [A-Z])[_DECL], 1,
+              [Define if you have the declaration of $2.])
+  fi
+])
+
+# Prerequisites of lib/setenv.c.
+AC_DEFUN([gl_PREREQ_SETENV],
+[
+  AC_REQUIRE([AC_FUNC_ALLOCA])
+  AC_CHECK_HEADERS_ONCE(unistd.h)
+  AC_CHECK_HEADERS(search.h)
+  AC_CHECK_FUNCS(tsearch)
+  gt_CHECK_VAR_DECL([#include <errno.h>], errno)
+  gt_CHECK_VAR_DECL([#include <unistd.h>], environ)
+])
+
+# Prerequisites of lib/unsetenv.c.
+AC_DEFUN([gl_PREREQ_UNSETENV],
+[
+  AC_CHECK_HEADERS_ONCE(unistd.h)
+  gt_CHECK_VAR_DECL([#include <errno.h>], errno)
+  gt_CHECK_VAR_DECL([#include <unistd.h>], environ)
+])
--- /dev/null   Sun Mar 24 15:28:28 2002
+++ lib/unsetenv.c      Tue Nov  2 16:42:49 2004
@@ -0,0 +1,99 @@
+/* Copyright (C) 1992,1995-1999,2000-2002 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
+   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., 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
+
+#include <stdlib.h>
+#include <string.h>
+#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 (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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]