Writing to a channel fconfigure with -crlf sometimes corrupt
Closed / Duplicate217793ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:43:45
OriginalBugID: 923 Bug
Version: 8.1a2
SubmitDate: '1998-12-04'
LastModified: '1998-12-07'
Severity: SER
Status: Closed
Submitter: welch
ChangedBy: stanton
RelatedBugIDs: 887
OS: Windows NT
Machine: X86
FixedDate: '2000-10-25'
ClosedDate: '1998-12-07'
Name:
Syd Polk
CVS:
12-02-1998 tclIO.c revision 1.1.2.4
ReproducibleScript:
# 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"
}
ObservedBehavior:
The script complains that the data read in does not match the data written out.
DesiredBehavior:
No complaints.
Patch:
*** tclIO.cWed Dec 2 18:49:57 1998
--- tclIO.new.cWed Dec 2 18:49:32 1998
***************
*** 2561,2566 ****
--- 2561,2567 ----
total += dstWrote;
stage += stageRead;
stageLen -= stageRead;
+ sawLF = 0;
}
}
return total;
***************
*** 2672,2678 ****
srcStart = src;
! for (dstEnd = dst + srcLen; dst < dstEnd; ) {
if (*src == '\n') {
if (dstEnd < dstMax) {
dstEnd++;
--- 2673,2680 ----
srcStart = src;
! for (dstEnd = dst + (srcLen < *dstLenPtr ? srcLen : *dstLenPtr);
! dst < dstEnd; ) {
if (*src == '\n') {
if (dstEnd < dstMax) {
dstEnd++;
PatchFiles:
generic/tclIO.c
Your bug form spellls concatentate wrong in step 9.
welch Closed ticket [217793ffff].
[History diff]2000-10-26 07:49:18
dgp Ticket [217793ffff]: 3 changes
[History diff]2001-04-13 22:52:43
Log in (anonymous is fine) to add a comment.