* path.cc (normalize_win32_path): Detect components with only dots. Remove a

final .  if it follows '\\'.
(mount_info::conv_to_win32_path): Only backslashify the path when no mount is
found.
(chdir): Do not look for components with only dots.
This commit is contained in:
Christopher Faylor 2004-05-04 15:14:48 +00:00
parent 3dcb399b58
commit 5cc2189c09
2 changed files with 32 additions and 36 deletions

View File

@ -1,3 +1,11 @@
2004-04-11 Pierre Humblet <pierre.humblet@ieee.org>
* path.cc (normalize_win32_path): Detect components with only dots.
Remove a final . if it follows '\\'.
(mount_info::conv_to_win32_path): Only backslashify the path when no
mount is found.
(chdir): Do not look for components with only dots.
2004-04-20 Pierre Humblet <pierre.humblet@ieee.org>
Christopher Faylor <cgf@alum.bu.edu>

View File

@ -789,7 +789,7 @@ path_conv::check (const char *src, unsigned opt,
}
/* Copy the symlink contents to the end of tmp_buf.
Convert slashes. FIXME? I think it's fine / Pierre */
Convert slashes. */
for (char *p = sym.contents; *p; p++)
*headptr++ = *p == '\\' ? '/' : *p;
*headptr = '\0';
@ -1007,8 +1007,9 @@ normalize_win32_path (const char *src, char *dst, char **tail)
/* Backup if "..". */
else if (src[0] == '.' && src[1] == '.'
/* dst must be greater than dst_start */
&& dst[-1] == '\\'
&& (isdirsep (src[2]) || src[2] == 0))
&& dst[-1] == '\\')
{
if (isdirsep (src[2]) || src[2] == 0)
{
/* Back up over /, but not if it's the first one. */
if (dst > dst_root_start + 1)
@ -1020,6 +1021,13 @@ normalize_win32_path (const char *src, char *dst, char **tail)
if (isdirsep (*src))
src++;
}
else
{
int n = strspn (src, ".");
if (!src[n] || isdirsep (src[n])) /* just dots... */
return ENOENT;
}
}
/* Otherwise, add char to result. */
else
{
@ -1032,6 +1040,8 @@ normalize_win32_path (const char *src, char *dst, char **tail)
if ((dst - dst_start) >= CYG_MAX_PATH)
return ENAMETOOLONG;
}
if (dst > dst_start + 1 && dst[-1] == '.' && dst[-2] == '\\')
dst--;
*dst = '\0';
*tail = dst;
debug_printf ("%s = normalize_win32_path (%s)", dst_start, src_start);
@ -1502,11 +1512,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev,
chroot_ok = true;
}
else
{
if (strchr (src_path, ':') == NULL && !is_unc_share (src_path))
set_flags (flags, PATH_BINARY);
backslashify (src_path, dst, 0);
}
out:
MALLOC_CHECK;
@ -3305,24 +3311,6 @@ chdir (const char *in_dir)
return -1;
}
/* Look for trailing path component consisting entirely of dots. This
is needed only in case of chdir since Windows simply ignores count
of dots > 2 here instead of returning an error code. Counts of dots
<= 2 are already eliminated by normalize_posix_path. */
const char *p = strrchr (dir, '/');
if (!p)
p = dir;
else
p++;
size_t len = strlen (p);
if (len > 2 && strspn (p, ".") == len)
{
set_errno (ENOENT);
return -1;
}
const char *native_dir = path;
/* Check to see if path translates to something like C:.