Tcl Source Code

Check-in [658a9d7cb5]
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 | core-8-branch
Files: files | file ages | folders
SHA3-256: 658a9d7cb5d6db706710db7e0eadad0f1df72a84e898a95a185883f7f5b0ee74
User & Date: max 2022-08-04 15:26:18
Context
2022-08-20
10:13
closes [baa51423c28a3baf]: needEvent must be initialized in cycle (for each watching channel) check-in: fce5cfe1c7 user: sebres tags: core-8-branch
2022-08-18
20:16
TIP633 fconfigure -tolerantencoding: start command arguments check-in: b4f4a89e9d user: oehhar tags: tip633-fconfigure-tolerantencoding
20:11
mistake Closed-Leaf check-in: cefdc8fae1 user: oehhar tags: tip833-fconfigure-tolerantencoding
2022-08-14
02:21
sync with core-8-branch check-in: 654414a485 user: griffin tags: tip-629
2022-08-06
15:51
Merge core-8-branch check-in: 96c714325c user: apnadkarni tags: tip-625
01:38
Create new branch named "tip-602-87" check-in: 9c7a33a74c user: apnadkarni tags: tip-602-87
2022-08-04
15:26
Fix a case of lf not being flushed in certain cases when the crlf sequence gets split across two buf... check-in: 658a9d7cb5 user: max tags: core-8-branch
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
10:55
amend for [4eb3a155ac] SF-fix: 8.7 specific implementation and warnings silencing check-in: ae45d3af73 user: sebres tags: core-8-branch
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/tclIO.c.
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
 	     */

	    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);








|
|







4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
 	     */

	    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"