From 191bacb0be9c3f7949c9a16935bcb521f108e609 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 3 Dec 2000 06:21:40 +0000 Subject: [PATCH] * path.cc (normalize_win32_path): Handle UNC paths better. (slash_unc_prefix_p): Allow backslash UNC paths. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/path.cc | 14 +++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 75729c584..d00c15284 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +Sun Dec 3 01:20:25 2000 Christopher Faylor + + * path.cc (normalize_win32_path): Handle UNC paths better. + (slash_unc_prefix_p): Allow backslash UNC paths. + Sun Dec 3 00:20:25 2000 Christopher Faylor * Makefile.in: Remove some extra cruft. diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 8e392d772..b00b1ae8f 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -713,12 +713,20 @@ normalize_win32_path (const char *src, char *dst) char *dst_start = dst; char *dst_root_start = dst; - if (strchr (src, ':') == NULL) + if (strchr (src, ':') == NULL && !slash_unc_prefix_p (src)) { if (!cygcwd.get (dst, 0)) return get_errno (); if (SLASH_P (src[0])) - dst[2] = '\0'; + if (dst[1] == ':') + dst[2] = '\0'; + else if (slash_unc_prefix_p (dst)) + { + char *p = strpbrk (dst + 2, "\\/"); + if (p && (p = strpbrk (p + 1, "\\/"))) + *p = '\0'; + } + else if (strlen (dst) + 1 + strlen (src) >= MAX_PATH) { debug_printf ("ENAMETOOLONG = normalize_win32_path (%s)", src); @@ -881,7 +889,7 @@ slash_unc_prefix_p (const char *path) && isalpha (path[2]) && path[3] != 0 && !isdirsep (path[3]) - && ((p = strchr(&path[3], '/')) != NULL)); + && ((p = strpbrk(path + 3, "\\/")) != NULL)); if (!ret || p == NULL) return ret; return ret && isalnum (p[1]);