This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: cygpath and partial normalization of trailing /.
- From: Jan Nijtmans <jan dot nijtmans at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 5 Oct 2015 16:20:57 +0200
- Subject: Re: cygpath and partial normalization of trailing /.
- Authentication-results: sourceware.org; auth=none
- References: <caaf01d0b0a80e077f56abed63864729 at webmail dot webfaction dot com>
2015-10-05 14:29 GMT+02:00 Poor Yorick:
> Rather than normalizing half of it away and leaving half of it, Wouldn't it
> be
> better to either not normalize the trailing slash-dot sequence at all, or to
> completely normalize it away? If that which is delimited is removed, it
> would
> seem to make sense to removed the delimiter as well.
Here is a small test program, which shows that the
function cygwin_conv_path(CCP_POSIX_TO_WIN_A, ....)
does the stripping of the '.' and/or '/'. This function is
used by cygpath to do the actual conversion.
Output of the test program:
/cygdrive/c/Windows -> C:\Windows
/cygdrive/c/Windows/ -> C:\Windows <-- (1)
/cygdrive/c/Windows/. -> C:\Windows
/home/foo -> C:\Users\foo
/home/foo/ -> C:\Users\foo\
/home/foo/. -> C:\Users\foo\ <-- (2)
It indeed makes sense to:
- either strip both the '.' and the backslash
- or keep both of them.
The arrows (<--) mark lines that give inconsistant
results, when the input ends with a separator
and the output doesn't (1), or reverse (2).
Thanks for the bug report. I'm not confident enough in
the Cygwin source code, but I hope someone else
can shine some light on it and give advise.
================ test.c =================
#include <sys/cygwin.h>
#include <stdio.h>
static const char *paths[] = {
"/cygdrive/c/Windows",
"/cygdrive/c/Windows/",
"/cygdrive/c/Windows/.",
"/home/foo",
"/home/foo/",
"/home/foo/.",
0
};
void main() {
char buf[320];
const char **p = paths;
do {
cygwin_conv_path(CCP_POSIX_TO_WIN_A, *p, buf, sizeof(buf));
printf("%s -> %s\n", *p, buf);
} while (*++p);
}
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple