Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2002-06-28
08:48 • Ticket [566669ffff] fix file dirname ~ status still Closed with 6 other ch... artifact: 7a9f92bb43 user: taguchiv6
2002-06-27
19:29 • Closed ticket [566669ffff]. artifact: c497a26c60 user: vincentdarley
15:21 • Ticket [566669ffff]: 5 changes artifact: c1ff4d88b5 user: vincentdarley
12:45 • Open ticket [566669ffff]. artifact: d1087721e4 user: taguchiv6
2002-06-21
23:29 • Pending ticket [566669ffff]. artifact: 2f20bb40f9 user: vincentdarley
2002-06-18
17:37 • Ticket [566669ffff]: 5 changes artifact: b7b9baa41e user: vincentdarley
14:41 • Add attachment tcl-file-normalize+dirname+tail-patch-20020618 to ticket... artifact: 7f5fce2b58 user: taguchiv6
14:41 • Ticket [566669ffff] fix file dirname ~ status still Open with 4 other chan... artifact: defc10fc3a user: taguchiv6
2002-06-13
15:37 • Ticket [566669ffff]: 4 changes artifact: cc9ecb88c8 user: vincentdarley
11:42 • Ticket [566669ffff]: 4 changes artifact: 4336553dd4 user: taguchiv6
11:42 • Add attachment tcl-file-normalize-patch-20020613 to ticket [566669fffff... artifact: 1a637490c7 user: taguchiv6
2002-06-11
15:32 • Ticket [566669ffff] fix file dirname ~ status still Open with 4 other chan... artifact: 96540c0e3e user: vincentdarley
08:12 • Ticket [566669ffff]: 4 changes artifact: 1c01ed2cfe user: taguchiv6
08:12 • Add attachment tcl-patch-ac to ticket [566669ffff] artifact: 16d83b4e07 user: taguchiv6
2002-06-10
17:36 • Ticket [566669ffff] fix file dirname ~ status still Open with 4 other chan... artifact: 8dc71fa975 user: nobody
15:59 • Ticket [566669ffff]: 6 changes artifact: 292429c459 user: vincentdarley
15:27 • Ticket [566669ffff]: 2 changes artifact: d291b369e2 user: dkf
10:29 • Ticket [566669ffff]: 4 changes artifact: 55b21a8e52 user: taguchiv6
10:29 • Add attachment tcl-patch-ac to ticket [566669ffff] artifact: b8d2950b1a user: taguchiv6
03:29 • New ticket [566669ffff] fix file dirname ~. artifact: 80aceda7a2 user: taguchiv6

[fix] file dirname ~

Closed / Fixed566669ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2002-06-10 03:29:15
Under Unix env, "file dirname ~" command does not
work fine.

TclpObjNormalizePath() in unix/tclUnixFCmd.c has a bug.
valiable "nextCheckPoint" sometime still 0, but
This value is used as argments for
Tcl_UtfToExternalDString().

This patch will fix this probrem.

Thanks.
taguchiv6plain2002-06-10 10:29:15
File Added - 24762: tcl-patch-ac
dkf Ticket [566669ffff]: 2 changes [History diff]2002-06-10 15:27:00
vincentdarleyplain2002-06-10 15:59:37
Logged In: YES 
user_id=32170

Would 'nextCheckpoint = pathLen' work for you as 
well?  I believe this will have the same value as 'strlen
(path), and will avoid the need to recompute the length.. 
(which will therefore be faster, in this crucial procedure).
nobodyplain2002-06-10 17:36:37
Logged In: NO 

What does 'file dirname ~' give for you?  Can you provide 
a test we can add to the test suite which shows the bug?

thanks,
taguchiv6plain2002-06-11 08:12:07
File Added - 24847: tcl-patch-ac

Logged In: YES 
user_id=357728

Here is a test sequence:

1. Original version:
%puts $env(HOME)
/root
% puts [pwd]
/usr/local/src/tcl-current/tcl/unix
% file dirname ~
/usr/local/src/tcl-current/tcl/unix

I think this return value is unexpected one.

2. Patched version:
%puts $env(HOME)
/root
% puts [pwd]
/usr/local/src/tcl-current/tcl/unix
% file dirname ~
/

I think it work fine.

And thanks Vince.
I cannot find out variable "pathLen" ;-)
So I used strlen(3).
But I think using "pathLen" is more excelent.

Here is a new patch for tclUnixFCmd.c, v1.21 2002/04/07.

Please commit it.
Thanks.
vincentdarleyplain2002-06-11 15:32:23
Logged In: YES 
user_id=32170

I've been informed that running the test suite with your 
patched version shows up a large number of errors...  
This means we can't commit the change.  I do accept 
that it is a bug, though!
taguchiv6plain2002-06-13 11:42:48
File Added - 25015: tcl-file-normalize-patch-20020613

Logged In: YES 
user_id=357728

How about this new patch?
vincentdarleyplain2002-06-13 15:37:40
Logged In: YES 
user_id=32170

Looks possible!  Have you run the entire test suite 
('make test') with this new change?  What happens?  Else 
can someone else with a Unix machine test this...
taguchiv6plain2002-06-18 14:41:22
File Added - 25299: tcl-file-normalize+dirname+tail-patch-20020618

Logged In: YES 
user_id=357728

Here is a new patch-set.

unix/tclUnixFCmd.c:
"file dirname ~" will return correct value.

generic/tclFileName.c:
Special case. if env(HOME) == "~", then
"file dirname ~" must return "~".

generic/tclCmdAH.c:
same case. if env(HOME) == "~", then
"file tail ~" must return "".

These behaviors are written in test code.

I've tested them using "make test".
I think these patch work fine.
some tests for "file" command and filesystem
will repare by this patch.

Thanks.
vincentdarleyplain2002-06-18 17:37:04
Logged In: YES 
user_id=32170

Assigning to Donal for his opinion on validity of the 
desired behaviour (the patch itself needs to be rewritten 
to move the desired behaviour deeper into Tcl).

I don't understand the comment "these behaviours are 
written in test code", when Tcl 8.4 currently passes all 
filesystem tests on unix, yet you are saying Tcl 8.4's 
behaviour is wrong?  Can you provide some new tests 
which (a) fail on Tcl 8.4 (and 8.3?) at present, but (b) 
pass with your patch?

cheers,  Vince.
vincentdarleyplain2002-06-21 23:29:41
Logged In: YES 
user_id=32170

I must say, I cannot reproduce your "bug" at all.  
According to your message below, (2002-06-18), you 
list the desired return values for various calls.  I've just 
compiled the latest tcl 8.4 cvs distribution and get the 
following:

% info tclv
8.4
% file dirname ~
/home/users/v/vi
% cd ~
% pwd
/home/users/v/vi/vincentdarley
% set env(HOME) ~
~
% file dirname ~
~
% file tail ~
%

I don't see how these differ from what you are expecting!

If you disagree, please provide a standard Tcl test which 
reproduces the problems you see.
taguchiv6plain2002-06-27 12:45:02
Logged In: YES 
user_id=357728

I've got following outputs from "make test"

==== cmdAH-8.44 Tcl_FileObjCmd: dirname FAILED
==== Contents of test case:

    global env
    set temp $env(HOME)
    set env(HOME) "~"
    testsetplatform unix
    set result [list [catch {file dirname ~} msg] $msg]
    set env(HOME) $temp
    set result

---- Result was:
0 /usr/local/src/tcl
---- Result should have been (exact matching):
0 ~
==== cmdAH-8.44 FAILED
==== cmdAH-8.46 Tcl_FileObjCmd: dirname FAILED
==== Contents of test case:

    global env
    set temp $env(HOME)
    set env(HOME) "/home/test"
    testsetplatform mac
    set result [list [catch {file dirname ~} msg] $msg]
    set env(HOME) $temp
    set result

---- Result was:
0 usr:local:src:tcl:unixhome
---- Result should have been (exact matching):
0 home:
==== cmdAH-8.46 FAILED


==== cmdAH-9.43 Tcl_FileObjCmd: tail FAILED
==== Contents of test case:

    global env
    set temp $env(HOME)
    set env(HOME) "~"
    testsetplatform unix
    set result [file tail ~]
    set env(HOME) $temp
    set result

---- Result was:
unix~
---- Result should have been (exact matching):

==== cmdAH-9.43 FAILED

... [snip] ...
==== filename-11.13 Tcl_GlobCmd FAILED
==== Contents of test case:

    list [catch {file join [lindex [glob ~] 0]} msg] $msg

---- Result was:
1 {no files matched glob pattern "~"}
---- Result should have been (exact matching):
0 /root
==== filename-11.13 FAILED


==== filename-11.45 Tcl_GlobCmd on root volume FAILED
==== Contents of test case:

    set res1 ""
    set res2 ""
    catch {
        set res1 [glob -dir [lindex [file volumes] 0] -tails
*]
    }
    catch {
        set tmpd [pwd]
        cd [lindex [file volumes] 0]
        set res2 [glob *]
        cd $tmpd
    }
    expr {$res1 == $res2}

---- Result was:
0
---- Result should have been (exact matching):
1
==== filename-11.45 FAILED
==== filesystem-5.1 cache and ~ FAILED
==== Contents of test case:
set orig $env(HOME)
        set ::env(HOME) /foo/bar/blah
        set testdir ~
        set res1 "Parent of ~ (/foo/bar/blah) is [file
dirname $testdir]"
        set ::env(HOME) /a/b/c
        set res2 "Parent of ~ (/a/b/c) is [file dirname
$testdir]"
        set ::env(HOME) $orig
        list $res1 $res2
---- Result was:
{Parent of ~ (/foo/bar/blah) is
/usr/local/src/tcl/unix/foo/bar} {Parent of ~ (/
a/b/c) is /usr/local/src/tcl/unix/a/b}
---- Result should have been (regexp matching):
{Parent of ~ \(/foo/bar/blah\) is (/foo/bar|foo:bar)}
{Parent of ~ \(/a/b/c\) is
 (/a/b|a:b)}
==== filesystem-5.1 FAILED
vincentdarleyplain2002-06-27 15:21:15
Logged In: YES 
user_id=32170

Could you give some more details of your platform 
(what version of what unix)?  Unless we can reliably 
reproduce this problem and find the root cause of it, we 
can't fix it.  Clearly on the unix platform I tested (Linux), 
this problem isn't seen.  Nor on Windows or MacOS.

The patch you've given addresses the symptom of the 
problem you are seeing, but not the root cause, so we 
cannot apply that as is.
vincentdarleyplain2002-06-27 19:29:26
Logged In: YES 
user_id=32170

Applied fix to cvs head.  Note that fix is different to 
attached patches.
taguchiv6plain2002-06-28 08:48:44
Logged In: YES 
user_id=357728

Thanks, Vince!

My plathomes are:
FreeBSD-3.2, 4.5, 4.6, and FreeBSD-5.0.

Under all version of FreeBSD, this probrem
has fixed.

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

Attachments: