Skip to content
Tcl Source Code View Ticket
Login

View Ticket

every 4096th char is changed to a carriage return

Closed / Fixed218524ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:01:40
OriginalBugID: 887 Bug
Version: 8.1a2
SubmitDate: '1998-12-02'
LastModified: '1999-11-04'
Severity: CRIT
Status: Released
Submitter: admin
ChangedBy: hershey
OS: All
OSVersion: NA
Machine: NA
FixedDate: '1999-11-04'
FixedInVersion: 8.1b1
ClosedDate: '2000-10-25'


I have discovered the following problem in both tcl8.1a2 and the net
distribution of tcl8.1. Basically, if you write out more than 4096 bytes of
data that has carriage returns in it to a channel which has been
fconfigured to have translation crlf, it will change every 4096th character
to a carriage return.

Syd Polk

The following script illustrates the problem:

# Test 1 - Case that works
set bigstring {}

for {set i 0} {$i < 10000} {incr i} {
append bigstring "0"
}

set f [open foo.out w]
fconfigure $f -translation crlf
puts $f $bigstring nonewline
close $f

set f [open foo.out]
fconfigure $f -translation crlf
set readstring [read $f]
close $f
catch {file delete -force foo.out}

if {[string compare $bigstring $readstring] != 0} {
puts "Test 1 did not work"
}

# Test 2 - Fails

set bigstring {}

for {set i 0} {$i < 10000} {incr i} {
append bigstring "000000000\n"
}

set f [open foo.out w]
fconfigure $f -translation
crlf
puts $f $bigstring nonewline
close $f

set f [open foo.out]
fconfigure
$f -translation crlf
set readstring [read $f]
close $f
catch {file delete
-force foo.out}

if {[string compare $bigstring $readstring] != 0} {
puts "Test 2 did not work"
}


Fixed... 
-- 11/04/1999 hershey
welch Closed ticket [218524ffff]. [History diff]2000-10-26 08:23:19
dgp Ticket [218524ffff]: 3 changes [History diff]2001-04-06 03:24:04
Log in (anonymous is fine) to add a comment.