Tcl Source Code

Check-in [cf8be3fc82]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | main
Files: files | file ages | folders
SHA3-256: cf8be3fc82dcee22fbf6337dffe3fa27804cd4ee812938494e61e674c2de54b3
User & Date: max 2022-08-04 15:15:46
Original Comment: 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/tktedit?name=c9d8a52fe
Context
2022-08-20
17:09
Merged fix for bug [baa51423c2] check-in: 87687f362f user: apnadkarni tags: trunk, main
2022-08-19
05:49
Merge trunk check-in: 8da10854c5 user: apnadkarni tags: tip-602
2022-08-08
12:48
merge trunk check-in: a8c6470f5d user: dgp tags: dgp-refactor
12:47
merge trunk check-in: fb43e49751 user: dgp tags: novem
2022-08-04
15:15
Fix a case of lf not being flushed in certain cases when the crlf sequence gets split across two buf... check-in: cf8be3fc82 user: max tags: trunk, main
15:09
Fix a case of lf not being flushed in certain cases when the crlf sequence gets split across two buf... check-in: 2e8fc36e39 user: max tags: core-8-6-branch
2022-07-29
11:10
merge 8.7 check-in: 7288bae49d user: sebres tags: trunk, main
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/tclIO.c.
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
 	     */

	    if (needNlFlush && (saved == 0 || src[-1] != '\n')) {
		needNlFlush = 0;
	    }
	}
    }
    if ((flushed < total) && (GotFlag(statePtr, CHANNEL_UNBUFFERED) ||
	    (needNlFlush && GotFlag(statePtr, CHANNEL_LINEBUFFERED)))) {
	if (FlushChannel(NULL, chanPtr, 0) != 0) {
	    return -1;
	}
    }

    UpdateInterest(chanPtr);








|
|







4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
 	     */

	    if (needNlFlush && (saved == 0 || src[-1] != '\n')) {
		needNlFlush = 0;
	    }
	}
    }
    if (((flushed < total) && GotFlag(statePtr, CHANNEL_UNBUFFERED)) ||
	    (needNlFlush && GotFlag(statePtr, CHANNEL_LINEBUFFERED))) {
	if (FlushChannel(NULL, chanPtr, 0) != 0) {
	    return -1;
	}
    }

    UpdateInterest(chanPtr);

Changes to tests/io.test.
332
333
334
335
336
337
338









339
340
341
342
343
344
345
    fconfigure $f -encoding ascii -buffering line -translation lf \
	     -buffersize 16
    puts -nonewline $f "abcdefg\nhijklmnopqrstuvwxyz"
    set x [list [contents $path(test1)]]
    close $f
    lappend x [contents $path(test1)]
} [list "abcdefg\nhijklmno" "abcdefg\nhijklmnopqrstuvwxyz"]










test io-4.1 {TranslateOutputEOL: lf} {
    # search for \n

    set f [open $path(test1) w]
    fconfigure $f -buffering line -translation lf
    puts $f "abcde"







>
>
>
>
>
>
>
>
>







332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
    fconfigure $f -encoding ascii -buffering line -translation lf \
	     -buffersize 16
    puts -nonewline $f "abcdefg\nhijklmnopqrstuvwxyz"
    set x [list [contents $path(test1)]]
    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

    set f [open $path(test1) w]
    fconfigure $f -buffering line -translation lf
    puts $f "abcde"