diff options
author | Christopher Faylor <me@cgf.cx> | 2006-08-02 15:11:48 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2006-08-02 15:11:48 +0000 |
commit | 6f1d48621ed3fa1cbbfe115ee7c3f672f525b162 (patch) | |
tree | 0d541629006673e95f21fb7c47f95bf825f6f05c /winsup/cygwin/environ.cc | |
parent | 2dba45f4aab6206025bb2f09c6e6a68d20386628 (diff) | |
download | newlib-6f1d48621ed3fa1cbbfe115ee7c3f672f525b162.zip newlib-6f1d48621ed3fa1cbbfe115ee7c3f672f525b162.tar.gz newlib-6f1d48621ed3fa1cbbfe115ee7c3f672f525b162.tar.bz2 |
* environ.cc (env_win32_to_posix_path_list): Declare.
(conv_envvars): Use env_win32_to_posix_path_list rather than
cygwin_win32_to_posix_path_list.
(posify): Translate back to win32 path if errno is EIDRM.
* environ.h: Update copyright. Define ENV_CVT.
* path.cc (conv_path_list): If converting for the environment and removed an
element set errno to ENV_CVT.
(env_win32_to_posix_path_list): New function.
Diffstat (limited to 'winsup/cygwin/environ.cc')
-rw-r--r-- | winsup/cygwin/environ.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 2e8acdd..c11a657 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -43,6 +43,8 @@ extern bool allow_server; static char **lastenviron; +extern "C" int env_win32_to_posix_path_list (const char *, char *posix); + #define ENVMALLOC \ (CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) \ <= CYGWIN_VERSION_DLL_MALLOC_ENV) @@ -57,7 +59,7 @@ static char **lastenviron; static int return_MAX_PATH (const char *) {return CYG_MAX_PATH;} static win_env conv_envvars[] = { - {NL ("PATH="), NULL, NULL, cygwin_win32_to_posix_path_list, + {NL ("PATH="), NULL, NULL, env_win32_to_posix_path_list, cygwin_posix_to_win32_path_list, cygwin_win32_to_posix_path_list_buf_size, cygwin_posix_to_win32_path_list_buf_size, true}, @@ -181,8 +183,17 @@ posify (char **here, const char *value) char *outenv = (char *) malloc (1 + len + conv->posix_len (value)); memcpy (outenv, src, len); - conv->toposix (value, outenv + len); - conv->add_cache (outenv + len, *value != '/' ? value : NULL); + char *newvalue = outenv + len; + if (!conv->toposix (value, newvalue) || _impure_ptr->_errno != EIDRM) + conv->add_cache (newvalue, *value != '/' ? value : NULL); + else + { + /* The conversion routine removed elements from a path list so we have + to recalculate the windows path to remove elements there, too. */ + char cleanvalue[strlen (value) + 1]; + conv->towin32 (newvalue, cleanvalue); + conv->add_cache (newvalue, cleanvalue); + } debug_printf ("env var converted to %s", outenv); *here = outenv; |