Mercurial > hg > octave-lyh > gnulib-hg
changeset 9434:b839560eec9f
Define the putenv substitute in <stdlib.h> rather than in <config.h>.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Thu, 01 Nov 2007 13:23:33 +0100 |
parents | bb252eb60189 |
children | 1622176e7160 |
files | ChangeLog lib/putenv.c lib/stdlib.in.h m4/putenv.m4 m4/stdlib_h.m4 modules/putenv modules/stdlib |
diffstat | 7 files changed, 53 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +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".
--- a/lib/putenv.c +++ b/lib/putenv.c @@ -19,11 +19,8 @@ #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> @@ -95,7 +92,7 @@ /* 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; @@ -131,7 +128,7 @@ environ = new_environ; } else - *ep = (char *) string; + *ep = string; return 0; }
--- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -167,6 +167,21 @@ #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
--- a/m4/putenv.m4 +++ b/m4/putenv.m4 @@ -1,5 +1,5 @@ -# 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. @@ -10,8 +10,10 @@ 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; @@ -30,10 +32,9 @@ 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 ])
--- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -1,4 +1,4 @@ -# 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, @@ -25,6 +25,7 @@ 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]) @@ -32,4 +33,5 @@ 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]) ])
--- a/modules/putenv +++ b/modules/putenv @@ -6,14 +6,17 @@ 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
--- a/modules/stdlib +++ b/modules/stdlib @@ -29,12 +29,14 @@ -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