summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2006-02-17 20:12:11 +0000
committerChristopher Faylor <me@cgf.cx>2006-02-17 20:12:11 +0000
commit753702223c7de6e18253d1cd89d6bf08cb00630d (patch)
treedc7f1a08b92e9718c32a2357c7b460e36da2f21e
parent3cfeb52a18498174c4bce17f31362ac35cb4c14e (diff)
downloadcygnal-753702223c7de6e18253d1cd89d6bf08cb00630d.tar.gz
cygnal-753702223c7de6e18253d1cd89d6bf08cb00630d.tar.bz2
cygnal-753702223c7de6e18253d1cd89d6bf08cb00630d.zip
* path.cc (conv_path_list): Eat empty paths when converting to POSIX.
(cygwin_conv_to_win32_path): Deal with Cygwin's necessity of adding a '/' to the end of a path ending in '.'.
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/path.cc54
2 files changed, 44 insertions, 16 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 23855f2b3..5802f6967 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+2006-02-17 Christopher Faylor <cgf@timesys.com>
+
+ * path.cc (conv_path_list): Eat empty paths when converting to POSIX.
+ (cygwin_conv_to_win32_path): Deal with Cygwin's necessity of adding a
+ '/' to the end of a path ending in '.'.
+
2006-02-16 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export sigignore and sigset.
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 4029ec5eb..e2480c2fc 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -1269,31 +1269,52 @@ nofinalslash (const char *src, char *dst)
static int
conv_path_list (const char *src, char *dst, int to_posix)
{
- char *s;
- char *d = dst;
- char src_delim = to_posix ? ';' : ':';
- char dst_delim = to_posix ? ':' : ';';
- int (*conv_fn) (const char *, char *) = (to_posix
- ? cygwin_conv_to_posix_path
- : cygwin_conv_to_win32_path);
+ char src_delim, dst_delim;
+ int (*conv_fn) (const char *, char *);
+
+ if (to_posix)
+ {
+ src_delim = ';';
+ dst_delim = ':';
+ conv_fn = cygwin_conv_to_posix_path;
+ }
+ else
+ {
+ src_delim = ':';
+ dst_delim = ';';
+ conv_fn = cygwin_conv_to_win32_path;
+ }
char *srcbuf = (char *) alloca (strlen (src) + 1);
- for (;;)
+ int err = 0;
+ char *d = dst - 1;
+ do
{
- s = strccpy (srcbuf, &src, src_delim);
+ char *s = strccpy (srcbuf, &src, src_delim);
int len = s - srcbuf;
if (len >= CYG_MAX_PATH)
- return ENAMETOOLONG;
- int err = (*conv_fn) (len ? srcbuf : ".", d);
+ {
+ err = ENAMETOOLONG;
+ break;
+ }
+ if (len)
+ err = conv_fn (srcbuf, ++d);
+ else if (!to_posix)
+ err = conv_fn (".", ++d);
+ else
+ continue;
if (err)
- return err;
- if (!*src++)
break;
d = strchr (d, '\0');
- *d++ = dst_delim;
+ *d = dst_delim;
}
- return 0;
+ while (*src++);
+
+ if (d < dst)
+ d++;
+ *d = '\0';
+ return err;
}
/* init: Initialize the mount table. */
@@ -3636,7 +3657,8 @@ cygwin_conv_to_win32_path (const char *path, char *win32_path)
return -1;
}
- strcpy (win32_path, p);
+
+ strcpy (win32_path, strcmp ((char *) p, ".\\") == 0 ? "." : (char *) p);
return 0;
}