* 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 '.'.
This commit is contained in:
Christopher Faylor 2006-02-17 20:12:11 +00:00
parent 3cfeb52a18
commit 753702223c
2 changed files with 44 additions and 16 deletions

View File

@ -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> 2006-02-16 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export sigignore and sigset. * cygwin.din: Export sigignore and sigset.

View File

@ -1269,31 +1269,52 @@ nofinalslash (const char *src, char *dst)
static int static int
conv_path_list (const char *src, char *dst, int to_posix) conv_path_list (const char *src, char *dst, int to_posix)
{ {
char *s; char src_delim, dst_delim;
char *d = dst; int (*conv_fn) (const char *, char *);
char src_delim = to_posix ? ';' : ':';
char dst_delim = to_posix ? ':' : ';'; if (to_posix)
int (*conv_fn) (const char *, char *) = (to_posix {
? cygwin_conv_to_posix_path src_delim = ';';
: cygwin_conv_to_win32_path); 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); 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; int len = s - srcbuf;
if (len >= CYG_MAX_PATH) 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) if (err)
return err;
if (!*src++)
break; break;
d = strchr (d, '\0'); 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. */ /* init: Initialize the mount table. */
@ -3636,7 +3657,8 @@ cygwin_conv_to_win32_path (const char *path, char *win32_path)
return -1; return -1;
} }
strcpy (win32_path, p);
strcpy (win32_path, strcmp ((char *) p, ".\\") == 0 ? "." : (char *) p);
return 0; return 0;
} }