>>>> "APA" == Adrian Aichner
<adrian(a)xemacs.org> writes:
APA> with this patch
APA> (file-truename "c:\\*.txt")
APA> => "c:\\B-r-Backtrace.txt"
APA> (the first of my many *.txt files).
APA> XEmacs 21.1.14, however does not expand the wildcard:
APA> (file-truename "c:\\*.txt")
APA> => "c:\\*.txt"
Thanks. Especially for the confirmation about 21.1.14, this is the
same thing (modulo the drive-spec and directory-sep-char differences)
that the Unix version does.
I bet somebody "simplified" some function to not separate the
directory path from the basename (which might be a glob), since
file-truename is supposed to handle this.
It looks to me like win32_readlink should return EINVAL, meaning "not
a symlink", when passed "*.txt" or "?.txt". How about this
patch?
(Sorry to send you so many half-baked patches, Adrian, but I don't
understand this stuff very well.)
This is pretty bad style (somebody who understands what the code at
ll. 117--137 is doing should fix this), but should DTRT. Except that
(a) the author of the code seems to think that "readlink" is supposed
to correct case, and that's not possible for a glob, and (b) as the
comments say, this will not handle a symlink whose real name contains
glob (or shell op) characters correctly. But neither of those is
handled correctly in the existing code, anyway, so....
It looks like Cygwin (and Unix) readlink will, when passed "*.txt",
actually try to find a directory entry for "*.txt". Since normally no
such entry exists, Cygwin returns ENOENT (this is a documented return
value for Linux) and thus does not invoke win32_readlink (see l. 156).
Index: src/realpath.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/realpath.c,v
retrieving revision 1.7.2.2
diff -u -r1.7.2.2 realpath.c
--- src/realpath.c 22 Aug 2002 10:58:34 -0000 1.7.2.2
+++ src/realpath.c 8 Oct 2002 02:36:10 -0000
@@ -90,9 +90,16 @@
assert (*name);
/* Sort of check we have a valid filename. */
- if (strpbrk (name, "*?|<>\"") || strlen (name) >= MAX_PATH)
+ /* #### can we have escaped shell operators in a Windows filename? */
+ if (strpbrk (name, "|<>\"") || strlen (name) >= MAX_PATH)
{
errno = EIO;
return -1;
}
+ /* #### can we have escaped wildcards in a Windows filename? */
+ else if (strpbrk (name, "*?"))
+ {
+ errno = EINVAL; /* this valid path can't be a symlink */
+ return -1;
+ }
--
Institute of Policy and Planning Sciences
http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
My nostalgia for Icon makes me forget about any of the bad things. I don't
have much nostalgia for Perl, so its faults I remember. Scott Gilbert c.l.py