mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Add support for using __environ instead of environ, if it exists and environ isn't set
darcs-hash:20070127165911-ac50b-72747760d767a6918152c2e4f254febb19ab1205.gz
This commit is contained in:
parent
be0bd50bad
commit
bd5a16d213
3 changed files with 39 additions and 7 deletions
25
configure.ac
25
configure.ac
|
@ -751,6 +751,31 @@ else
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check for __environ symbol
|
||||||
|
AC_MSG_CHECKING([for __environ symbol])
|
||||||
|
AC_TRY_LINK(
|
||||||
|
[
|
||||||
|
#include <unistd.h>
|
||||||
|
],
|
||||||
|
[
|
||||||
|
extern char **__environ;
|
||||||
|
char **tmp = __environ;
|
||||||
|
exit(tmp!=0);
|
||||||
|
],
|
||||||
|
have___environ=yes,
|
||||||
|
have___environ=no
|
||||||
|
)
|
||||||
|
if test "$have___environ" = yes; then
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(
|
||||||
|
[HAVE___ENVIRON],
|
||||||
|
[1],
|
||||||
|
[Define to 1 if the __environ symbol is exported.]
|
||||||
|
)
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if getopt_long exists and works
|
# Check if getopt_long exists and works
|
||||||
AC_MSG_CHECKING([if getopt_long exists and works])
|
AC_MSG_CHECKING([if getopt_long exists and works])
|
||||||
AC_TRY_LINK(
|
AC_TRY_LINK(
|
||||||
|
|
15
env.c
15
env.c
|
@ -1,7 +1,6 @@
|
||||||
/** \file env.c
|
/** \file env.c
|
||||||
Functions for setting and getting environment variables.
|
Functions for setting and getting environment variables.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -67,9 +66,13 @@
|
||||||
#define ENV_NULL L"\x1d"
|
#define ENV_NULL L"\x1d"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
At init, we read all the environment variables from this array
|
At init, we read all the environment variables from this array.
|
||||||
*/
|
*/
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
/**
|
||||||
|
This should be the same thing as \c environ, but it is possible only one of the two work...
|
||||||
|
*/
|
||||||
|
extern char **__environ;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -511,7 +514,6 @@ void env_init()
|
||||||
wchar_t *uname;
|
wchar_t *uname;
|
||||||
wchar_t *version;
|
wchar_t *version;
|
||||||
|
|
||||||
|
|
||||||
sb_init( &dyn_var );
|
sb_init( &dyn_var );
|
||||||
b_init( &export_buffer );
|
b_init( &export_buffer );
|
||||||
|
|
||||||
|
@ -553,7 +555,7 @@ void env_init()
|
||||||
hash_init( &top->env, &hash_wcs_func, &hash_wcs_cmp );
|
hash_init( &top->env, &hash_wcs_func, &hash_wcs_cmp );
|
||||||
global_env = top;
|
global_env = top;
|
||||||
global = &top->env;
|
global = &top->env;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Now the environemnt variable handling is set up, the next step
|
Now the environemnt variable handling is set up, the next step
|
||||||
is to insert valid data
|
is to insert valid data
|
||||||
|
@ -562,7 +564,7 @@ void env_init()
|
||||||
/*
|
/*
|
||||||
Import environment variables
|
Import environment variables
|
||||||
*/
|
*/
|
||||||
for( p=environ; *p; p++ )
|
for( p=environ?environ:__environ; p && *p; p++ )
|
||||||
{
|
{
|
||||||
wchar_t *key, *val;
|
wchar_t *key, *val;
|
||||||
wchar_t *pos;
|
wchar_t *pos;
|
||||||
|
@ -575,7 +577,6 @@ void env_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
val = wcschr( key, L'=' );
|
val = wcschr( key, L'=' );
|
||||||
|
|
||||||
|
|
||||||
if( val == 0 )
|
if( val == 0 )
|
||||||
{
|
{
|
||||||
|
@ -600,7 +601,7 @@ void env_init()
|
||||||
}
|
}
|
||||||
free(key);
|
free(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Set up the PATH variable
|
Set up the PATH variable
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -47,6 +47,12 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef HAVE___ENVIRON
|
||||||
|
|
||||||
|
char **__environ = 0;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef TPUTS_KLUDGE
|
#ifdef TPUTS_KLUDGE
|
||||||
|
|
||||||
int tputs(const char *str, int affcnt, int (*fish_putc)(tputs_arg_t))
|
int tputs(const char *str, int affcnt, int (*fish_putc)(tputs_arg_t))
|
||||||
|
|
Loading…
Reference in a new issue