Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2002-03-18
17:26 • Closed ticket [530960ffff]: Glob munges 1st char on Win98 plus 7 other chang... artifact: d70bd9d72b user: vincentdarley
17:09 • Ticket [530960ffff]: 4 changes artifact: 0db12dc27e user: jcw
15:53 • Ticket [530960ffff]: 4 changes artifact: 5c33c71eba user: jcw
15:48 • Ticket [530960ffff]: 4 changes artifact: 0d87e94921 user: jcw
15:35 • Ticket [530960ffff]: 4 changes artifact: c0a14c8a0f user: nobody
15:35 • Ticket [530960ffff]: 4 changes artifact: aafe128831 user: jcw
15:03 • Ticket [530960ffff]: 4 changes artifact: a0a9f66865 user: jcw
06:00 • Ticket [530960ffff]: 4 changes artifact: c2b2080d56 user: vincentdarley
05:56 • Ticket [530960ffff]: 5 changes artifact: 05460f6c37 user: vincentdarley
2002-03-17
21:26 • Add attachment globroot.txt to ticket [530960ffff] artifact: 1c645f8324 user: jcw
21:26 • Ticket [530960ffff] Glob munges 1st char on Win98 status still Open with 4 o... artifact: ee4731691c user: jcw
14:26 • New ticket [530960ffff]. artifact: e566a8bc8d user: jcw

Glob munges 1st char on Win98

Closed / Fixed530960ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2002-03-17 14:26:19
The sequence "cd \\; puts [glob *]" returns a list where 
each first character is lost.  This does not happen on 
WinNT4, but always on Win98SE.

Using "glob ./*" works as expected, though.

I suspect that this may also be the reason why exec 
fails (for example: "exec command /c dir"), complaining 
about not beign able to find COMMAND.COM.

This problem exists in ActiveTcl 8.4 beta (i.e. 8.4a4), 
and in the current cvs HEAD (i.e. 8.4a5).

I've looked in the glob code, which changed due to the 
new VFS layer, but have not been able to figure it out.
jcwplain2002-03-17 21:26:19
File Added - 19512: globroot.txt
vincentdarleyplain2002-03-18 05:56:54
Logged In: YES 
user_id=32170

I can't really debug this since I don't have any Win98 
machines to test on at all.  However, the bug occurs for 
one of three potential reasons.  First off, the way 'glob 
*' in the new fs works is to do a 'glob -dir [pwd] *' and 
strip off the pwd (for reasons explained in the comments in 
the code).  What is happening therefore is that too much is 
being stripped off.

Why?  Back to the three potential reasons:

(i) there's a bug in the code doing the stripping, (around 
line 1730 in tclIOUtil.c)

(ii) there's an assumption in the code (in a variety of 
places, I believe), that '[pwd]' is a normalized path which 
does not end in a directory delimiter, _unless_ it is the 
name of a root volume, in which case it will end in a 
delimiter.  On Windows, normalized paths contain forward 
slashes, not backslashes.  So I would hope 'pwd' is 'C:/' 
in the above case.  (and not C:\\ or C:).  So, please check 
this out!  If 'pwd' is incorrect, then code elsewhere needs 
fixing.

(iii) since the stripping works simply be checking how 
long 'pwd' is, and removing that, if 'glob -dir [pwd] *' is 
returning the wrong answer, (e.g. it returns C:Windows, 
skipping the slash), then the fault lies in 
TclpMatchInDirectory in win/tclWinFile.c

Hope that helps you to track it down.

Vince.
vincentdarleyplain2002-03-18 06:00:26
Logged In: YES 
user_id=32170

What do these return:

glob -dir / *
glob -dir \\ *
glob -dir C:/
jcwplain2002-03-18 15:03:14
Logged In: YES 
user_id=1983

All of glob -dir / *, \\ *, C:/ * seem to return the expected 
values.  But [pwd] returns paths with backslahes, so it looks 
like (ii) is the issue here.

I'll chase this further, thanks for these very helpful notes.
jcwplain2002-03-18 15:35:49
Logged In: YES 
user_id=1983

Well, 'pwd' does the right thing.  It's "file normalize" that 
messes it up again.  With a non-existent dir (and going to 
ActiveTcl 8.4 beta to make sure it wasn't the extra VFS 
layer):

  file normalize c:/a  ->  C:/a

With an existing dir, though:

  file normalize c:/windows  ->  C:\WINDOWS
nobodyplain2002-03-18 15:35:52
Logged In: NO 

Hang on!  I just remembered that to solve the big slowdown 
on Win95/98 with the vfs code we had to make normalized 
paths on those platforms have backslashes (and be 
the 'short' form of a path).  On Win NT/2000/XP the 
normalized form has forward slashes and the 'long form'.

This means 'pwd' should be C:\ on 98, and the problem is 
around line 1730 in tclIOUtil.c.  How about using the 
following block of code there:

cwdDir = Tcl_DuplicateObj(cwd);
Tcl_IncrRefCount(cwdDir);
cwdStr = Tcl_GetStringFromObj(cwdDir, 
&cwdLen);
#ifdef __WIN32__
if ((cwdStr[cwdLen-1] != sep) && (cwdStr
[cwdLen-1] != '\\')) {
#else
if (cwdStr[cwdLen-1] != sep) {
#endif
    Tcl_AppendToObj(cwdDir, &sep, 1);
    cwdLen++;
    /* Note: cwdStr may no longer be a 
valid pointer */
}
jcwplain2002-03-18 15:48:07
Logged In: YES 
user_id=1983

Yep, that did it (changed to \ to \\ of course).

Btw, the "short native form on 9x vs. long /'ed one on NT 
etc" is a horrible difference - I'd hope it gets documented 
in BLINKING RED - because this can easily trip over people 
who need to retain compatibility with 9x.

Ok, great.  Solved - thanks for the really quick turnaround.
jcwplain2002-03-18 15:53:54
Logged In: YES 
user_id=1983

Hang on...

It does solve the glob, but not typing "dir" in an 
interactive shell:

 % dir
 couldn't execute "C:\WINDOWS\COMMAND.COM": no such file or 
directory

Note that this dir problem does not happen in Activetcl 8.4 
beta, unly in my own (more recent?) builds.

Shall I create a different bug report for this one?  
(Assuming it is not my own bug this time)
jcwplain2002-03-18 17:09:24
Logged In: YES 
user_id=1983

DIR problem solved: it requires tclpip84.dll, since 
COMMAND.COM is a 16-bit app on Win98.

Ouch.  The source comment say that tclpip84.dll has to live 
next to the tcl app/dll, but it can live in c:\windows as 
well - which seems slightly more appropriate (there is a 
similar issue with msvcrt.dll, which is required for tclkit 
but does not exist on Win95).

FWIW, I changed the comparison with .com to be case-
insensitive - not sure it matters here, but it sure looks 
like it would be better, i.e. tclWinPipe.c line 1434, strcmp 
-> stricmp.

Anyway... end of story.  All issues have been resolved... :o)
vincentdarleyplain2002-03-18 17:26:37
Logged In: YES 
user_id=32170

Ok, I've added the fix to my patch of another bug 
(including the 'stricmp' thing).  Thanks!
Log in (anonymous is fine) to add a comment.

Attachments: