Tcl Source Code

Check-in [2e8fc36e39]
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-6-branch
Files: files | file ages | folders
SHA3-256: 2e8fc36e39984559591a0692b392de1dacc4842f3ba6ee8998897ffe7090631e
User & Date: max 2022-08-04 15:09:59
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-21
20:28
ClientData -> 'void *" in TclOO headers check-in: 4a915166e6 user: jan.nijtmans tags: core-8-6-branch
2022-08-08
12:41
merge 8.6 check-in: 5220085b3c user: dgp tags: core-8-6-13-rc
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: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
09:51
merge branch bug-4eb3a155ac--procptr-bytecode, fixes SF [4eb3a155ac] and similar corner cases: reset... check-in: 73a6af23a5 user: sebres tags: core-8-6-branch
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/tclIO.c.
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446

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

    return total;
}







|
|







4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446

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

    return total;
}
Changes to tests/io.test.
326
327
328
329
330
331
332









333
334
335
336
337
338
339
    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"







>
>
>
>
>
>
>
>
>







326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
    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"