* path.cc (normalize_win32_path): Don't add a trailing slash when one already
exists. (mount_info::conv_to_win32_path): Use existing code for dealing with relative path names when input is already a win32 path.
This commit is contained in:
parent
97f3429f4f
commit
fc6f4e20ec
|
@ -1,3 +1,10 @@
|
||||||
|
Wed Apr 26 23:23:23 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* path.cc (normalize_win32_path): Don't add a trailing slash when one
|
||||||
|
already exists.
|
||||||
|
(mount_info::conv_to_win32_path): Use existing code for dealing with
|
||||||
|
relative path names when input is already a win32 path.
|
||||||
|
|
||||||
2000-04-26 DJ Delorie <dj@cygnus.com>
|
2000-04-26 DJ Delorie <dj@cygnus.com>
|
||||||
|
|
||||||
* Makefile.in (install): install regexp.h
|
* Makefile.in (install): install regexp.h
|
||||||
|
|
|
@ -640,8 +640,7 @@ normalize_win32_path (const char *cwd, const char *src, char *dst)
|
||||||
const char *src_start = src;
|
const char *src_start = src;
|
||||||
char *dst_start = dst;
|
char *dst_start = dst;
|
||||||
|
|
||||||
if (!SLASH_P (src[0])
|
if (!SLASH_P (src[0]) && strchr (src, ':') == NULL)
|
||||||
&& strchr (src, ':') == NULL)
|
|
||||||
{
|
{
|
||||||
if (strlen (cwd) + 1 + strlen (src) >= MAX_PATH)
|
if (strlen (cwd) + 1 + strlen (src) >= MAX_PATH)
|
||||||
{
|
{
|
||||||
|
@ -650,6 +649,7 @@ normalize_win32_path (const char *cwd, const char *src, char *dst)
|
||||||
}
|
}
|
||||||
strcpy (dst, cwd);
|
strcpy (dst, cwd);
|
||||||
dst += strlen (dst);
|
dst += strlen (dst);
|
||||||
|
if (!*cwd || !SLASH_P (dst[-1]))
|
||||||
*dst++ = '\\';
|
*dst++ = '\\';
|
||||||
}
|
}
|
||||||
/* Two leading \'s? If so, preserve them. */
|
/* Two leading \'s? If so, preserve them. */
|
||||||
|
@ -925,40 +925,32 @@ mount_info::conv_to_win32_path (const char *src_path, char *win32_path,
|
||||||
mount_item *mi = NULL; /* initialized to avoid compiler warning */
|
mount_item *mi = NULL; /* initialized to avoid compiler warning */
|
||||||
char pathbuf[MAX_PATH];
|
char pathbuf[MAX_PATH];
|
||||||
|
|
||||||
/* The rule is :'s can't appear in [our] POSIX path names so this is a safe
|
char cwd[MAX_PATH];
|
||||||
test; if ':' is present it already be in Win32 form. */
|
getcwd_inner (cwd, MAX_PATH, TRUE); /* FIXME: check rc */
|
||||||
/* Additional test: If the path has \'s in it, we assume that it's a Win32
|
|
||||||
path, either. */
|
/* Determine where the destination should be placed. */
|
||||||
if (strchr (src_path, ':') != NULL
|
if (full_win32_path != NULL)
|
||||||
|| (strchr (src_path, '\\')/* && !strchr (src_path, '/')*/))
|
dst = full_win32_path;
|
||||||
|
else if (win32_path != NULL)
|
||||||
|
dst = win32_path;
|
||||||
|
|
||||||
|
if (dst == NULL)
|
||||||
|
goto out; /* Sanity check. */
|
||||||
|
|
||||||
|
/* An MS-DOS spec has either a : or a \. If this is found, short
|
||||||
|
circuit most of the rest of this function. */
|
||||||
|
if (strpbrk (src_path, ":\\") != NULL)
|
||||||
{
|
{
|
||||||
debug_printf ("%s already win32", src_path);
|
debug_printf ("%s already win32", src_path);
|
||||||
rc = normalize_win32_path ("", src_path, pathbuf);
|
rc = normalize_win32_path (current_directory_name, src_path, dst);
|
||||||
if (rc)
|
if (rc)
|
||||||
|
{
|
||||||
|
debug_printf ("normalize_win32_path failed, rc %d", rc);
|
||||||
return rc;
|
return rc;
|
||||||
/* FIXME: Do we have to worry about trailing_slash_p here? */
|
|
||||||
if (win32_path != NULL)
|
|
||||||
{
|
|
||||||
/* If src_path is a relativ win32 path, normalize_win32_path
|
|
||||||
adds a leading slash, nevertheless. So we have to test
|
|
||||||
that here */
|
|
||||||
strcpy (win32_path, strchr("/\\", src_path[0]) || src_path[1] == ':'
|
|
||||||
? pathbuf : pathbuf + 1);
|
|
||||||
}
|
|
||||||
if (full_win32_path != NULL)
|
|
||||||
{
|
|
||||||
*full_win32_path = '\0';
|
|
||||||
/* Add drive if it's a local relative Win32 path */
|
|
||||||
if (! strchr(src_path, ':') && strncmp (src_path, "\\\\", 2))
|
|
||||||
{
|
|
||||||
GetCurrentDirectory (MAX_PATH, full_win32_path);
|
|
||||||
if (src_path[0] == '\\') // drive relative absolute path
|
|
||||||
full_win32_path[2] = '\0';
|
|
||||||
}
|
|
||||||
strcat (full_win32_path, pathbuf);
|
|
||||||
}
|
}
|
||||||
|
isrelpath = !isabspath (src_path);
|
||||||
*flags = set_flags_from_win32_path (pathbuf);
|
*flags = set_flags_from_win32_path (pathbuf);
|
||||||
goto out;
|
goto fillin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Normalize the path, taking out ../../ stuff, we need to do this
|
/* Normalize the path, taking out ../../ stuff, we need to do this
|
||||||
|
@ -977,13 +969,8 @@ mount_info::conv_to_win32_path (const char *src_path, char *win32_path,
|
||||||
converting it to a DOS-style path, looking up the appropriate drive
|
converting it to a DOS-style path, looking up the appropriate drive
|
||||||
in the mount table. */
|
in the mount table. */
|
||||||
|
|
||||||
char cwd[MAX_PATH];
|
|
||||||
|
|
||||||
/* No need to fetch cwd if path is absolute. */
|
/* No need to fetch cwd if path is absolute. */
|
||||||
if ((isrelpath = !isslash (*src_path)))
|
isrelpath = !isslash (*src_path);
|
||||||
getcwd_inner (cwd, MAX_PATH, TRUE); /* FIXME: check rc */
|
|
||||||
else
|
|
||||||
strcpy (cwd, "/"); /* some innocuous value */
|
|
||||||
|
|
||||||
rc = normalize_posix_path (cwd, src_path, pathbuf);
|
rc = normalize_posix_path (cwd, src_path, pathbuf);
|
||||||
|
|
||||||
|
@ -994,15 +981,6 @@ mount_info::conv_to_win32_path (const char *src_path, char *win32_path,
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine where the destination should be placed. */
|
|
||||||
if (full_win32_path != NULL)
|
|
||||||
dst = full_win32_path;
|
|
||||||
else if (win32_path != NULL)
|
|
||||||
dst = win32_path;
|
|
||||||
|
|
||||||
if (dst == NULL)
|
|
||||||
goto out; /* Sanity check. */
|
|
||||||
|
|
||||||
/* See if this is a cygwin "device" */
|
/* See if this is a cygwin "device" */
|
||||||
if (win32_device_name (pathbuf, dst, devn, unit))
|
if (win32_device_name (pathbuf, dst, devn, unit))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue