]> sourceware.org Git - newlib-cygwin.git/commitdiff
* environ.cc (env_win32_to_posix_path_list): Declare.
authorChristopher Faylor <me@cgf.cx>
Wed, 2 Aug 2006 15:11:48 +0000 (15:11 +0000)
committerChristopher Faylor <me@cgf.cx>
Wed, 2 Aug 2006 15:11:48 +0000 (15:11 +0000)
(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.

winsup/cygwin/ChangeLog
winsup/cygwin/environ.cc
winsup/cygwin/environ.h
winsup/cygwin/path.cc

index f2f42c7b4d3865239cab61bda12fa7b247f9eced..f9b288c06f2cb0df130d027aeda6ce69195796ed 100644 (file)
@@ -1,3 +1,14 @@
+2006-08-02  Christopher Faylor  <cgf@timesys.com>
+
+       * 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.
+
 2006-08-01  Christopher Faylor  <cgf@timesys.com>
 
        * environ.cc (dos_file_warning): Declare.
index 2e8acddcb8dc9d5e333aa67519b493a7935be516..c11a657d2095626b71e7cb397b6389f696865ce8 100644 (file)
@@ -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;
index b953148b402cd9b16c59334f73d759fc0dfc3632..84c88a3c9fd55e3061218dd2dd126fc7523e557f 100644 (file)
@@ -1,6 +1,6 @@
 /* environ.h: Declarations for environ manipulation
 
-   Copyright 2000, 2001, 2002 Red Hat, Inc.
+   Copyright 2000, 2001, 2002, 2003, 2005, 2006 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -48,3 +48,5 @@ extern "C" char __stdcall **cur_environ ();
 char ** __stdcall build_env (const char * const *envp, char *&envblock,
                             int &envc, bool need_envblock)
   __attribute__ ((regparm (3)));
+
+#define ENV_CVT -1
index 9a91aceb9cf1f97e7dc21f69ceec66c31d2fc0ea..f7dccc01fdbabdcc3153a939a9b47fbc9fb9e298 100644 (file)
@@ -75,6 +75,7 @@ details. */
 #include "shared_info.h"
 #include "registry.h"
 #include "cygtls.h"
+#include "environ.h"
 #include <assert.h>
 
 bool dos_file_warning = true;
@@ -1329,6 +1330,7 @@ conv_path_list (const char *src, char *dst, int to_posix)
 
   int err = 0;
   char *d = dst - 1;
+  bool saw_empty = false;
   do
     {
       char *s = strccpy (srcbuf, &src, src_delim);
@@ -1343,7 +1345,11 @@ conv_path_list (const char *src, char *dst, int to_posix)
       else if (!to_posix)
        err = conv_fn (".", ++d);
       else
-       continue;
+       {
+         if (to_posix == ENV_CVT)
+           saw_empty = true;
+         continue;
+       }
       if (err)
        break;
       d = strchr (d, '\0');
@@ -1351,6 +1357,9 @@ conv_path_list (const char *src, char *dst, int to_posix)
     }
   while (*src++);
 
+  if (saw_empty)
+    err = EIDRM;
+
   if (d < dst)
     d++;
   *d = '\0';
@@ -3885,6 +3894,12 @@ cygwin_posix_to_win32_path_list_buf_size (const char *path_list)
   return conv_path_list_buf_size (path_list, false);
 }
 
+extern "C" int
+env_win32_to_posix_path_list (const char *win32, char *posix)
+{
+  return_with_errno (conv_path_list (win32, posix, ENV_CVT));
+}
+
 extern "C" int
 cygwin_win32_to_posix_path_list (const char *win32, char *posix)
 {
This page took 0.04338 seconds and 5 git commands to generate.