bug-gnulib
[Top][All Lists]
Advanced

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

Re: coreutils failure on Mac OS X 10.5


From: Bruno Haible
Subject: Re: coreutils failure on Mac OS X 10.5
Date: Thu, 1 Nov 2007 02:28:21 +0100
User-agent: KMail/1.5.4

Hi Jim,

Peter O'Gorman wrote:
> checking for working mktime... yes
> checking for SVID conformant putenv... no
> checking for working strtod... yes

Good. This means that only 'putenv' and possibly 'realpath' are affected.

Jim, here is a proposed patch to the 'putenv' module. Apart from changing
the location of the "#define putenv rpl_putenv", this also changes the
parameter type from 'const char *' to 'char *', for POSIX compliance.


2007-11-01  Bruno Haible  <address@hidden>

        * 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.

*** lib/putenv.c.orig   2007-11-01 02:19:36.000000000 +0100
--- lib/putenv.c        2007-11-01 02:17:26.000000000 +0100
***************
*** 19,29 ****
  
  #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 *);
  
  #include <stddef.h>
  
--- 19,26 ----
  
  #include <config.h>
  
! /* Specification.  */
! #include <stdlib.h>
  
  #include <stddef.h>
  
***************
*** 95,101 ****
  /* 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)
  {
    const char *const name_end = strchr (string, '=');
    register size_t size;
--- 92,98 ----
  /* Put STRING, which is of the form "NAME=VALUE", in the environment.
     If STRING contains no `=', then remove STRING from the environment.  */
  int
! putenv (char *string)
  {
    const char *const name_end = strchr (string, '=');
    register size_t size;
***************
*** 131,137 ****
        environ = new_environ;
      }
    else
!     *ep = (char *) string;
  
    return 0;
  }
--- 128,134 ----
        environ = new_environ;
      }
    else
!     *ep = string;
  
    return 0;
  }
*** lib/stdlib.in.h.orig        2007-11-01 02:19:36.000000000 +0100
--- lib/stdlib.in.h     2007-11-01 02:08:37.000000000 +0100
***************
*** 167,172 ****
--- 167,187 ----
  #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
*** m4/putenv.m4.orig   2007-11-01 02:19:36.000000000 +0100
--- m4/putenv.m4        2007-11-01 02:15:01.000000000 +0100
***************
*** 1,5 ****
! # putenv.m4 serial 12
! dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 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.
--- 1,5 ----
! # 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,17 ****
  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],[
      /* Put it in env.  */
      if (putenv ("CONFTEST_putenv=val"))
        return 1;
--- 10,19 ----
  dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that.
  
  AC_DEFUN([gl_FUNC_PUTENV],
! [
!   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,39 ****
             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
      AC_LIBOBJ(putenv)
-     AC_DEFINE(putenv, rpl_putenv,
-       [Define to rpl_putenv if the replacement function should be used.])
    fi
  ])
--- 32,40 ----
             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)
    fi
  ])
*** m4/stdlib_h.m4.orig 2007-11-01 02:19:36.000000000 +0100
--- m4/stdlib_h.m4      2007-11-01 02:09:25.000000000 +0100
***************
*** 1,4 ****
! # stdlib_h.m4 serial 3
  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,
--- 1,4 ----
! # 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,30 ****
--- 25,31 ----
    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,35 ****
--- 33,37 ----
    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])
  ])
*** modules/putenv.orig 2007-11-01 02:19:36.000000000 +0100
--- modules/putenv      2007-11-01 02:10:13.000000000 +0100
***************
*** 6,19 ****
--- 6,22 ----
  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
*** modules/stdlib.orig 2007-11-01 02:19:36.000000000 +0100
--- modules/stdlib      2007-11-01 02:04:56.000000000 +0100
***************
*** 29,40 ****
--- 29,42 ----
              -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; \
        } > address@hidden





reply via email to

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