Cygwin: fix utils path handling in case cygdrive path is just '/'
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
f881942d77
commit
26bcedda20
|
@ -11,3 +11,5 @@ What changed:
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
- Fix utils path handling in case cygdrive path is just '/'.
|
||||||
|
Addresses: https://cygwin.com/ml/cygwin/2018-02/msg00174.html
|
||||||
|
|
|
@ -672,7 +672,7 @@ read_mounts ()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
path_prefix_p (const char *path1, const char *path2, int len1)
|
path_prefix_p (const char *path1, const char *path2, size_t len1)
|
||||||
{
|
{
|
||||||
/* Handle case where PATH1 has trailing '/' and when it doesn't. */
|
/* Handle case where PATH1 has trailing '/' and when it doesn't. */
|
||||||
if (len1 > 0 && isslash (path1[len1 - 1]))
|
if (len1 > 0 && isslash (path1[len1 - 1]))
|
||||||
|
@ -778,7 +778,7 @@ rel_vconcat (const char *cwd, const char *s, va_list v)
|
||||||
cwd = pathbuf;
|
cwd = pathbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int max_len = -1;
|
int max_len = 0;
|
||||||
mnt_t *m, *match = NULL;
|
mnt_t *m, *match = NULL;
|
||||||
|
|
||||||
for (m = mount_table; m->posix; m++)
|
for (m = mount_table; m->posix; m++)
|
||||||
|
@ -786,7 +786,7 @@ rel_vconcat (const char *cwd, const char *s, va_list v)
|
||||||
if (m->flags & MOUNT_CYGDRIVE)
|
if (m->flags & MOUNT_CYGDRIVE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int n = strlen (m->native);
|
size_t n = strlen (m->native);
|
||||||
if (n < max_len || !path_prefix_p (m->native, cwd, n))
|
if (n < max_len || !path_prefix_p (m->native, cwd, n))
|
||||||
continue;
|
continue;
|
||||||
max_len = n;
|
max_len = n;
|
||||||
|
@ -821,7 +821,7 @@ rel_vconcat (const char *cwd, const char *s, va_list v)
|
||||||
static char *
|
static char *
|
||||||
vcygpath (const char *cwd, const char *s, va_list v)
|
vcygpath (const char *cwd, const char *s, va_list v)
|
||||||
{
|
{
|
||||||
int max_len = -1;
|
size_t max_len = 0;
|
||||||
mnt_t *m, *match = NULL;
|
mnt_t *m, *match = NULL;
|
||||||
|
|
||||||
if (!max_mount_entry)
|
if (!max_mount_entry)
|
||||||
|
@ -843,15 +843,23 @@ vcygpath (const char *cwd, const char *s, va_list v)
|
||||||
|
|
||||||
for (m = mount_table; m->posix; m++)
|
for (m = mount_table; m->posix; m++)
|
||||||
{
|
{
|
||||||
int n = strlen (m->posix);
|
size_t n = strlen (m->posix);
|
||||||
if (n < max_len || !path_prefix_p (m->posix, path, n))
|
if (n < max_len || !path_prefix_p (m->posix, path, n))
|
||||||
continue;
|
continue;
|
||||||
if ((m->flags & MOUNT_CYGDRIVE)
|
if (m->flags & MOUNT_CYGDRIVE)
|
||||||
&& ((int) strlen (path) < n + 2
|
{
|
||||||
|| path[n] != '/'
|
if (strlen (path) < n + 2)
|
||||||
|| !isalpha (path[n + 1])
|
continue;
|
||||||
|| path[n + 2] != '/'))
|
/* If cygdrive path is just '/', fix n for followup evaluation. */
|
||||||
continue;
|
if (n == 1)
|
||||||
|
n = 0;
|
||||||
|
if (path[n] != '/')
|
||||||
|
continue;
|
||||||
|
if (!isalpha (path[n + 1]))
|
||||||
|
continue;
|
||||||
|
if (path[n + 2] != '/')
|
||||||
|
continue;
|
||||||
|
}
|
||||||
max_len = n;
|
max_len = n;
|
||||||
match = m;
|
match = m;
|
||||||
}
|
}
|
||||||
|
@ -859,7 +867,7 @@ vcygpath (const char *cwd, const char *s, va_list v)
|
||||||
char *native;
|
char *native;
|
||||||
if (match == NULL)
|
if (match == NULL)
|
||||||
native = strdup (path);
|
native = strdup (path);
|
||||||
else if (max_len == (int) strlen (path))
|
else if (max_len == strlen (path))
|
||||||
native = strdup (match->native);
|
native = strdup (match->native);
|
||||||
else if (match->flags & MOUNT_CYGDRIVE)
|
else if (match->flags & MOUNT_CYGDRIVE)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue