Skip to content
Tcl Source Code View Ticket
Login

View Ticket

[file normalize] fails EIAS

Closed / Fixed3559678fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 14 years ago
Descriptionplain2012-08-20 01:40:58
Command/subcommand file normalize won't normalize some elements of glob's path list.

The expected behavior is to have that trailing '/' character removed, and it is not being removed.

Here is some small code (output commented in the end): [http://pastie.org/4552920].

However, if I ask for the string length of the list element, then it works: [http://pastie.org/4552993].

That a simple test case provided by kbk in IRC (#tcl, irc.freenode.com).

[22:38] <ijchain> <kbk> % file normalize [lindex [glob -dir [pwd] {{}}] 0]
[22:38] <ijchain> <kbk> /home/kennykb/fred/
[22:38] <ijchain> <kbk> % file normalize [join [glob -dir [pwd] {{}}] ""]
[22:38] <ijchain> <kbk> /home/kennykb/fred

I am on Windows 7, TCL Version is 8.6b2.
kennykbplain2012-08-20 08:49:10
Regression in 8.5 appears to be related to refactoring in tclPathObj.c. Tentatively assigning to dgp for analysis, since Vince isn't terribly active at the moment.
dgp Ticket [3559678fff]: 1 change [History diff]2012-08-20 22:01:04
dgpplain2012-08-20 22:03:12
Aside from the EIAS bug, can someone testify that [glob]
is returning the correct list of results?
dgpplain2012-08-20 22:14:49
The pattern "{}" is the empty set of alternative strings to match.
Maybe my brain is still on vacation, but I'd expect that to match nothing.
Simplest test, though:
% glob {{}}
.
dgpplain2012-08-20 22:16:05
Some spot testing suggests this is not a new regression.
dgpplain2012-08-21 00:33:18
Regression dates to checkin:

9cfcca63fb07d8c7d68befc16d84d01790094ac5 2004-01-21 19:59:32 UTC
dgpplain2012-08-21 01:44:17
Curious to me that the -dir switch is needed to trigger
the problem.  [pwd] isn't though.

% file normalize [lindex [glob -dir . {{}}] 0]
/local/tmp/dgp/fossil/tcl8.5/unix/
% info patch
8.5.12
dgpplain2012-08-21 03:13:48
Issue appears to be callers of TclNewFSPathObj() not
honoring its requirements.  Header comments state clearly
that 'len' may not be zero.
dgpplain2012-08-21 06:45:35
On further reflection, the empty string corner case for
paths and path components have been pushed here and
there so many times in intermittent games of "stomp the
bug" we're better off not trusting the comments.

Fix committed to core-8-5-branch
dgpplain2012-08-21 06:50:50
allow_comments - 1

....and trunk.
Log in (anonymous is fine) to add a comment.