fix environ on MAC
This commit is contained in:
parent
3fcf5f5ced
commit
53773207f4
@ -539,28 +539,28 @@ p_tmpdir(void)
|
|||||||
static int
|
static int
|
||||||
p_environ(void)
|
p_environ(void)
|
||||||
{
|
{
|
||||||
#if HAVE_ENVIRON
|
#if HAVE_ENVIRON && 0
|
||||||
#if defined(__MINGW32__) || _MSC_VER
|
#if HAVE__NSGETENVIRON
|
||||||
|
char ** ptr = _NSGetEnviron();
|
||||||
|
#elif defined(__MINGW32__) || _MSC_VER
|
||||||
extern char **_environ;
|
extern char **_environ;
|
||||||
|
char ** ptr = _environ;
|
||||||
#else
|
#else
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
char ** ptr = environ;
|
||||||
#endif
|
#endif
|
||||||
YAP_Term t1 = YAP_ARG1;
|
YAP_Term t1 = YAP_ARG1;
|
||||||
long int i;
|
long int i;
|
||||||
|
|
||||||
i = YAP_IntOfTerm(t1);
|
i = YAP_IntOfTerm(t1);
|
||||||
#if defined(__MINGW32__) || _MSC_VER
|
if (ptr[i] == NULL)
|
||||||
if (_environ[i] == NULL)
|
|
||||||
#else
|
|
||||||
if (environ[i] == NULL)
|
|
||||||
#endif
|
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
else {
|
else {
|
||||||
YAP_Term t = YAP_BufferToString(environ[i]);
|
YAP_Term t = YAP_BufferToString(ptr[i]);
|
||||||
return(YAP_Unify(t, YAP_ARG2));
|
return(YAP_Unify(t, YAP_ARG2));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
YAP_Error(0,0L,"environ not available in this configuration");
|
YAP_Error(0, 0L, "environ not available in this configuration" );
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,11 @@ pl_environ(term_t l)
|
|||||||
term_t vt = PL_new_term_ref();
|
term_t vt = PL_new_term_ref();
|
||||||
functor_t FUNCTOR_equal2 = PL_new_functor(PL_new_atom("="), 2);
|
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++)
|
for(e = environ; *e; e++)
|
||||||
|
#endif
|
||||||
{ char *s = strchr(*e, '=');
|
{ char *s = strchr(*e, '=');
|
||||||
|
|
||||||
if ( !s )
|
if ( !s )
|
||||||
|
Reference in New Issue
Block a user