From 1820a91386b8a2e511534da3d2601ab838381673 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 19 Dec 2010 18:35:54 +0100 Subject: [PATCH] unsetenv: Add missing declaration on OSF/1 5.1. * lib/stdlib.in.h (setenv): Test HAVE_DECL_UNSETENV, not HAVE_UNSETENV. * m4/setenv.m4 (gl_FUNC_UNSETENV): Test whether unsetenv is declared. Don't set HAVE_UNSETENV. In the test program, set _BSD. * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize HAVE_DECL_UNSETENV, not HAVE_UNSETENV. * modules/stdlib (Makefile.am): Substitute HAVE_DECL_UNSETENV, not HAVE_UNSETENV. * doc/posix-functions/unsetenv.texi: Mention the OSF/1 5.1 problem. --- ChangeLog | 12 ++++++++++++ doc/posix-functions/unsetenv.texi | 3 +++ lib/stdlib.in.h | 4 +++- m4/setenv.m4 | 9 +++++++-- m4/stdlib_h.m4 | 4 ++-- modules/stdlib | 2 +- 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 341743084..7bf4ff1cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2010-12-19 Bruno Haible + unsetenv: Add missing declaration on OSF/1 5.1. + * lib/stdlib.in.h (setenv): Test HAVE_DECL_UNSETENV, not HAVE_UNSETENV. + * m4/setenv.m4 (gl_FUNC_UNSETENV): Test whether unsetenv is declared. + Don't set HAVE_UNSETENV. In the test program, set _BSD. + * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize HAVE_DECL_UNSETENV, + not HAVE_UNSETENV. + * modules/stdlib (Makefile.am): Substitute HAVE_DECL_UNSETENV, not + HAVE_UNSETENV. + * doc/posix-functions/unsetenv.texi: Mention the OSF/1 5.1 problem. + +2010-12-19 Bruno Haible + setenv: Add missing declaration on OSF/1 5.1. * lib/stdlib.in.h (setenv): Test HAVE_DECL_SETENV, not HAVE_SETENV. * m4/setenv.m4 (gl_FUNC_SETENV_SEPARATE): Test whether setenv is diff --git a/doc/posix-functions/unsetenv.texi b/doc/posix-functions/unsetenv.texi index 5293942df..160ef8357 100644 --- a/doc/posix-functions/unsetenv.texi +++ b/doc/posix-functions/unsetenv.texi @@ -12,6 +12,9 @@ Portability problems fixed by Gnulib: This function is missing on some platforms: AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9, mingw, BeOS. @item +This function is not declared on some platforms: +OSF/1 5.1. +@item This function has the return type @samp{void} instead of @samp{int} on some platforms: MacOS X 10.3, FreeBSD 6.0, NetBSD 1.6, OpenBSD 3.8, OSF/1 5.1. diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 84097dce0..72c992fc0 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -704,12 +704,14 @@ _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - " _GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (unsetenv, int, (const char *name)); # else -# if !@HAVE_UNSETENV@ +# if !@HAVE_DECL_UNSETENV@ _GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (unsetenv, int, (const char *name)); # endif +# if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@) _GL_CXXALIASWARN (unsetenv); +# endif #elif defined GNULIB_POSIXCHECK # undef unsetenv # if HAVE_RAW_DECL_UNSETENV diff --git a/m4/setenv.m4 b/m4/setenv.m4 index fec4a2cce..ccbe267bd 100644 --- a/m4/setenv.m4 +++ b/m4/setenv.m4 @@ -1,4 +1,4 @@ -# setenv.m4 serial 19 +# setenv.m4 serial 20 dnl Copyright (C) 2001-2004, 2006-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -57,9 +57,12 @@ AC_DEFUN([gl_FUNC_SETENV_SEPARATE], AC_DEFUN([gl_FUNC_UNSETENV], [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_CHECK_DECLS_ONCE([unsetenv]) + if test $ac_cv_have_decl_unsetenv = no; then + HAVE_DECL_UNSETENV=0 + fi AC_CHECK_FUNCS([unsetenv]) if test $ac_cv_func_unsetenv = no; then - HAVE_UNSETENV=0 AC_LIBOBJ([unsetenv]) gl_PREREQ_UNSETENV else @@ -68,6 +71,8 @@ AC_DEFUN([gl_FUNC_UNSETENV], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[ +#undef _BSD +#define _BSD 1 /* unhide unsetenv declaration in OSF/1 5.1 */ #include extern #ifdef __cplusplus diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4 index 8cbda59ae..e5a74cccb 100644 --- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -1,4 +1,4 @@ -# stdlib_h.m4 serial 32 +# stdlib_h.m4 serial 33 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -99,7 +99,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA]) HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H]) HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT]) - HAVE_UNSETENV=1; AC_SUBST([HAVE_UNSETENV]) + HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV]) REPLACE_CALLOC=0; AC_SUBST([REPLACE_CALLOC]) REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC]) diff --git a/modules/stdlib b/modules/stdlib index 0058c7677..273095ec4 100644 --- a/modules/stdlib +++ b/modules/stdlib @@ -78,7 +78,7 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \ -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \ - -e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \ + -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \ -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \ -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \ -- 2.11.0