fix environ on MAC

This commit is contained in:
Vitor Santos Costa 2010-06-18 10:32:57 +01:00
parent 3fcf5f5ced
commit 53773207f4
2 changed files with 13 additions and 9 deletions

View File

@ -539,28 +539,28 @@ p_tmpdir(void)
static int
p_environ(void)
{
#if HAVE_ENVIRON
#if defined(__MINGW32__) || _MSC_VER
#if HAVE_ENVIRON && 0
#if HAVE__NSGETENVIRON
char ** ptr = _NSGetEnviron();
#elif defined(__MINGW32__) || _MSC_VER
extern char **_environ;
char ** ptr = _environ;
#else
extern char **environ;
char ** ptr = environ;
#endif
YAP_Term t1 = YAP_ARG1;
long int i;
i = YAP_IntOfTerm(t1);
#if defined(__MINGW32__) || _MSC_VER
if (_environ[i] == NULL)
#else
if (environ[i] == NULL)
#endif
if (ptr[i] == NULL)
return(FALSE);
else {
YAP_Term t = YAP_BufferToString(environ[i]);
YAP_Term t = YAP_BufferToString(ptr[i]);
return(YAP_Unify(t, YAP_ARG2));
}
#else
YAP_Error(0,0L,"environ not available in this configuration");
YAP_Error(0, 0L, "environ not available in this configuration" );
return(FALSE);
#endif
}

View File

@ -247,7 +247,11 @@ pl_environ(term_t l)
term_t vt = PL_new_term_ref();
functor_t FUNCTOR_equal2 = PL_new_functor(PL_new_atom("="), 2);
#if HAVE__NSGETENVIRON
for(e = _NSGetEnviron(); *e; e++)
#else
for(e = environ; *e; e++)
#endif
{ char *s = strchr(*e, '=');
if ( !s )