diff options
author | max <max@tclers.tk> | 2022-08-04 15:15:46 (GMT) |
---|---|---|
committer | max <max@tclers.tk> | 2022-08-04 15:15:46 (GMT) |
commit | eb3d10d523c074a318119a0d6116f724ecf56e94 (patch) | |
tree | def9dcb40173f71456556bf6c5a5e5706a7316b4 | |
parent | 13384df4afe1602c77e79a0661eb8f70419f1697 (diff) | |
parent | 7c269c207f4a9c13dd64edea5fa799a5d952742c (diff) | |
download | tcl-eb3d10d523c074a318119a0d6116f724ecf56e94.zip tcl-eb3d10d523c074a318119a0d6116f724ecf56e94.tar.gz tcl-eb3d10d523c074a318119a0d6116f724ecf56e94.tar.bz2 |
Fix a case of lf not being flushed in certain cases when the crlf sequence gets split across two buffers on channels in crlf mode with line buffering [https://core.tcl-lang.org/tcllib/tktview?name=c9d8a52fe]
-rw-r--r-- | generic/tclIO.c | 4 | ||||
-rw-r--r-- | tests/io.test | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 80780d7..5317e30 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -4454,8 +4454,8 @@ Write( } } } - if ((flushed < total) && (GotFlag(statePtr, CHANNEL_UNBUFFERED) || - (needNlFlush && GotFlag(statePtr, CHANNEL_LINEBUFFERED)))) { + if (((flushed < total) && GotFlag(statePtr, CHANNEL_UNBUFFERED)) || + (needNlFlush && GotFlag(statePtr, CHANNEL_LINEBUFFERED))) { if (FlushChannel(NULL, chanPtr, 0) != 0) { return -1; } diff --git a/tests/io.test b/tests/io.test index dca88a4..6314ace 100644 --- a/tests/io.test +++ b/tests/io.test @@ -336,6 +336,15 @@ test io-3.8 {WriteChars: reset sawLF after each buffer} { close $f lappend x [contents $path(test1)] } [list "abcdefg\nhijklmno" "abcdefg\nhijklmnopqrstuvwxyz"] +test io-3.9 {Write: flush line-buffered channels when crlf is split over two buffers} -body { + # https://core.tcl-lang.org/tcllib/tktedit?name=c9d8a52fe + set f [open $path(test1) w] + fconfigure $f -buffering line -translation crlf -buffersize 8 + puts $f "1234567" + string map {"\r" "<cr>" "\n" "<lf>"} [contents $path(test1)] +} -cleanup { + close $f +} -result "1234567<cr><lf>" test io-4.1 {TranslateOutputEOL: lf} { # search for \n |