Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-04-13
22:52 • Ticket [217793ffff] Writing to a channel fconfigure with -crlf sometimes corrupt... artifact: d4bf8d7b11 user: dgp
2000-10-26
07:49 • Closed ticket [217793ffff]. artifact: d5d38687a7 user: welch
00:43 • New ticket [217793ffff]. artifact: 540c8e8136 user: nobody

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.