Tcl Source Code

View Ticket
Login
Ticket UUID: 1027690
Title: read $channel [file size "myfile"] doesn't work in 8.4 head
Type: Bug Version: obsolete: 8.4.7
Submitter: wobster Created on: 2004-09-14 04:58:01
Subsystem: 10. Objects Assigned To: dgp
Priority: 8 Severity:
Status: Closed Last Modified: 2004-09-15 08:50:26
Resolution: Fixed Closed By: dgp
    Closed on: 2004-09-14 16:30:48
Description:
I just checked out the head of the 8.4 branch. It
appears that there is a bug related to the "read"
command when executing this test case:

set f [open "myfile" r]
set contents [read $f [file size "myfile"]]

nothing is read.

But, if you do this:

set bytes [file size "myfile]
set contents [read $f $bytes]

it works fine.

This worked in earlier versions of 8.4.

p.s. please delete previous bug report. I wasn't logged
in when I submitted the bug.
User Comments: wobster added on 2004-09-15 08:50:26:
Logged In: YES 
user_id=60261

Thanks for the lightning fast fix! That must be a record.
Now, we can confidently migrate to 8.4.7+ without changing
our sources. :-)

dgp added on 2004-09-14 23:30:48:
Logged In: YES 
user_id=80530

fix committed.

dgp added on 2004-09-14 23:28:32:

File Added - 101481: 1027690.patch

Logged In: YES 
user_id=80530

Here's the fix.

dgp added on 2004-09-14 23:04:03:
Logged In: YES 
user_id=80530


Appears the patch for bug 868489
introduced this.  Thanks for the
testing to discover this quickly!

dgp added on 2004-09-14 22:51:43:
Logged In: YES 
user_id=80530


Can the original submitter confirm
this is a new bug, present in the
8.4 development branch, but not
in the Tcl 8.4.7 release ?

dgp added on 2004-09-14 22:35:11:
Logged In: YES 
user_id=80530

confirmed on Solaris 9.

Bug *not* present in the
Tcl 8.5 development branch.

wobster added on 2004-09-14 17:43:46:
Logged In: YES 
user_id=60261

Thanks for the tip. It appears that the problem is
OS-specific. It doesn't work on Solaris and Irix, but does
on Linux.

Actually, it looks like it's a problem with read. I tried
this test as well:

% pwd    
/tmp/bak/tcl8.4.7/unix
% set f [open "Makefile" r]
file6
% puts [file size "Makefile"]
50346
% read $f [file size "Makefile"]
% read $f $size ; # nothing printed
% read $f 50346
# Generated automatically from Makefile.in by configure.
...

For some reason, this works as well:
read $f [expr [file size "Makefile"] - 1]

The file size is actually 50346 by the way according to "ls
-l" and "wc -c".

dkf added on 2004-09-14 15:21:56:
Logged In: YES 
user_id=79902

Can't tell if this is a fault with [file size] (when it
belongs to category 36) or [read] (which I've assigned it to
for now.)

What is the size of that file BTW, or does that not matter?

dkf added on 2004-09-14 15:07:56:
Logged In: YES 
user_id=79902

As a workaround, try just doing this:
  set contents [read $f]
as that's been tuned to work fast in all releases of 8.4.

Attachments: