From aafe9ca1aa829f64d4bad1df3ee1d5997fb17d71 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 27 Oct 2008 23:39:53 +0100 Subject: Fix definition of environ on Mac OS X (bugzilla: #5412). --- lib/replace/libreplace.m4 | 1 + lib/replace/replace.h | 9 +++++++++ 2 files changed, 10 insertions(+) (limited to 'lib/replace') diff --git a/lib/replace/libreplace.m4 b/lib/replace/libreplace.m4 index 5e13d4a47e..6f1543863a 100644 --- a/lib/replace/libreplace.m4 +++ b/lib/replace/libreplace.m4 @@ -222,6 +222,7 @@ AC_CHECK_TYPE(comparison_fn_t, AC_HAVE_DECL(setenv, [#include ]) AC_CHECK_FUNCS(setenv unsetenv) +AC_HAVE_DECL(environ, [#include ]) AC_CHECK_FUNCS(strnlen) AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) diff --git a/lib/replace/replace.h b/lib/replace/replace.h index af1208a8fc..a8164b642b 100644 --- a/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -182,6 +182,15 @@ char *rep_strndup(const char *s, size_t n); size_t rep_strnlen(const char *s, size_t n); #endif +#if !HAVE_DECL_ENVIRON +#ifdef __APPLE__ +#include +#define environ (*_NSGetEnviron()) +#else +extern char **environ; +#endif +#endif + #ifndef HAVE_SETENV #define setenv rep_setenv int rep_setenv(const char *name, const char *value, int overwrite); -- cgit