This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
Re: [Patch] Make add_item smarter
- From: Christopher Faylor <cgf-no-personal-reply-please at cygwin dot com>
- To: cygwin-patches at cygwin dot com
- Date: Sun, 30 May 2004 00:34:31 -0400
- Subject: Re: [Patch] Make add_item smarter
- References: <3.0.5.32.20040530002148.0081b840@incoming.verizon.net>
- Reply-to: cygwin-patches at cygwin dot com
On Sun, May 30, 2004 at 12:21:48AM -0400, Pierre A. Humblet wrote:
>2004-05-30 Pierre Humblet <pierre.humblet@ieee.org>
>
> * path.cc (mount_info::add_item): Make sure native path has drive
> or UNC form. Call normalize_xxx_path instead of [back]slashify.
> Remove test for double slashes. Reorganize to always debug_print.
>Index: path.cc
>===================================================================
>RCS file: /cvs/src/src/winsup/cygwin/path.cc,v
>retrieving revision 1.313
>diff -u -p -b -r1.313 path.cc
>--- path.cc 28 May 2004 19:50:06 -0000 1.313
>+++ path.cc 30 May 2004 04:06:43 -0000
>@@ -2176,41 +2176,40 @@ mount_info::sort ()
> int
> mount_info::add_item (const char *native, const char *posix, unsigned mountflags, int reg_p)
> {
>+ char nativetmp[CYG_MAX_PATH];
>+ char posixtmp[CYG_MAX_PATH];
>+ char *tail;
>+ int err[2];
Why an array here? It's not really being used as an array.
> /* Something's wrong if either path is NULL or empty, or if it's
> not a UNC or absolute path. */
>
>- if ((native == NULL) || (*native == 0) ||
>- (posix == NULL) || (*posix == 0) ||
>- !isabspath (native) || !isabspath (posix) ||
>+ if (native == NULL || *native == 0 || !isabspath (native) ||
Do we need an "isabsdospath"? Checking for isabspath and isdrive is
a little redundant although the compiler would probably optimize
nicely.
>+ !(is_unc_share (native) || isdrive (native)))
>+ err[0] = EINVAL;
>+ else
>+ err[0] = normalize_win32_path (native, nativetmp, &tail);
>+
>+ if (posix == NULL || *posix == 0 || !isabspath (posix) ||
> is_unc_share (posix) || isdrive (posix))
>+ err[1] = EINVAL;
>+ else
>+ err[1] = normalize_posix_path (posix, posixtmp, &tail);
>+
>+ debug_printf ("%s[%s], %s[%s], %p",
>+ native, err[0]?"error":nativetmp, posix, err[1]?"error":posixtmp,
>+ mountflags);
>+
>+ if (err[0] || err[1])
> {
>- set_errno (EINVAL);
>+ set_errno (err[0]?:err[1]);
> return -1;
> }
>
> /* Make sure both paths do not end in /. */
>- char nativetmp[CYG_MAX_PATH];
>- char posixtmp[CYG_MAX_PATH];
>-
>- backslashify (native, nativetmp, 0);
> nofinalslash (nativetmp, nativetmp);
Do we still need the nofinalslash?
cgf