+2007-11-01 Bruno Haible <bruno@clisp.org>
+
+ * lib/putenv.c: Include <stdlib.h>. Remove rpl_putenv declaration.
+ (putenv): Renamed from rpl_putenv. Change argument type from
+ 'const char *' to 'char *'.
+ * m4/putenv.m4 (gl_FUNC_PUTENV): Require gl_STDLIB_H_DEFAULTS. Instead
+ of defining putenv in config.h, just set REPLACE_PUTENV.
+ * modules/putenv (Depends-on): Add stdlib.
+ (configure.ac): Invoke gl_STDLIB_MODULE_INDICATOR.
+ (Include): Use <stdlib.h>.
+ * lib/stdlib.in.h (putenv): New declaration.
+ * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize GNULIB_PUTENV and
+ REPLACE_PUTENV.
+ * modules/stdlib (Makefile.am): Substitute GNULIB_PUTENV and
+ REPLACE_PUTENV.
+ Needed for MacOS X 10.5.0.
+ Reported by Peter O'Gorman <peter@pogma.com>.
+
2007-11-01 Jim Meyering <meyering@redhat.com>
Treat an empty date string exactly like "0".
#include <config.h>
-/* undef putenv here, because some (e.g., Solaris 10) declare putenv in
- with a non-const argument. That would conflict with the declaration of
- rpl_putenv below (due to the #define putenv rpl_putenv from config.h). */
-#undef putenv
-int rpl_putenv (char const *);
+/* Specification. */
+#include <stdlib.h>
#include <stddef.h>
/* Put STRING, which is of the form "NAME=VALUE", in the environment.
If STRING contains no `=', then remove STRING from the environment. */
int
-rpl_putenv (const char *string)
+putenv (char *string)
{
const char *const name_end = strchr (string, '=');
register size_t size;
environ = new_environ;
}
else
- *ep = (char *) string;
+ *ep = string;
return 0;
}
#endif
+#if @GNULIB_PUTENV@
+# if @REPLACE_PUTENV@
+# undef putenv
+# define putenv rpl_putenv
+extern int putenv (char *string);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef putenv
+# define putenv(s) \
+ (GL_LINK_WARNING ("putenv is not POSIX compliant everywhere - " \
+ "use gnulib module putenv for portability"), \
+ putenv (s))
+#endif
+
+
#ifdef __cplusplus
}
#endif
-# putenv.m4 serial 12
-dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+# putenv.m4 serial 13
+dnl Copyright (C) 2002-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,
dnl with or without modifications, as long as this notice is preserved.
dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that.
AC_DEFUN([gl_FUNC_PUTENV],
-[AC_CACHE_CHECK([for SVID conformant putenv], jm_cv_func_svid_putenv,
- [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[
+[
+ AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+ AC_CACHE_CHECK([for SVID conformant putenv], jm_cv_func_svid_putenv,
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[
/* Put it in env. */
if (putenv ("CONFTEST_putenv=val"))
return 1;
jm_cv_func_svid_putenv=no,
dnl When crosscompiling, assume putenv is broken.
jm_cv_func_svid_putenv=no)
- ])
+ ])
if test $jm_cv_func_svid_putenv = no; then
+ REPLACE_PUTENV=1
AC_LIBOBJ(putenv)
- AC_DEFINE(putenv, rpl_putenv,
- [Define to rpl_putenv if the replacement function should be used.])
fi
])
-# stdlib_h.m4 serial 3
+# stdlib_h.m4 serial 4
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,
GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT])
GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP])
GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP])
+ GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV])
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_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP])
HAVE_REALLOC_POSIX=1; AC_SUBST([HAVE_REALLOC_POSIX])
REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
+ REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
])
m4/putenv.m4
Depends-on:
+stdlib
malloc-posix
configure.ac:
gl_FUNC_PUTENV
+gl_STDLIB_MODULE_INDICATOR([putenv])
Makefile.am:
Include:
+#include <stdlib.h>
License:
LGPL
-e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
-e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
-e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
+ -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|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|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
+ -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
< $(srcdir)/stdlib.in.h; \
} > $@-t