Posted to tcl by rmax at Thu Aug 04 10:43:44 GMT 2022view pretty

test io-4242 {crlf gets split over two buffers} -body {
    lassign [chan pipe] r w
    chan configure $r -blocking 0 -translation binary
    chan configure $w -buffering line -translation crlf -buffersize 8
    puts $w xxxxxxx
    expr {[read $r 10] == "xxxxxxx\r\n"}
} -cleanup {
    close $w
    close $r
} -result 1

Comments

Posted by sebres at Thu Aug 04 11:12:26 GMT 2022 [text] [code]

test io-4242 {flush & gets on line-buffered channels when crlf is split over two buffers} -body { lassign [chan pipe] r w foreach c [list $r $w] { fconfigure $c -blocking 0 -buffering line -translation crlf -buffersize 8 } set toev [after 1000 {set done TIMEOUT}] puts -nonewline $w xxxxxxx\r\n fileevent $r readable [list apply {r { gets $r done }} $r] vwait done set done } -cleanup { close $w close $r after cancel $toev } -result "xxxxxxx"

Posted by sebres at Thu Aug 04 11:18:20 GMT 2022 [text] [code]

test io-4242 {flush & gets on line-buffered channels when crlf is split over two buffers} -body { lassign [chan pipe] r w foreach c [list $r $w] { fconfigure $c -blocking 0 -buffering line -translation crlf -buffersize 8 } set toev [after 1000 {set ::done TIMEOUT}] puts -nonewline $w xxxxxxx\r\n fileevent $r readable [list apply {r { if {[gets $r line] > 0} {set ::done $line} }} $r] vwait ::done set ::done } -cleanup { close $w close $r after cancel $toev } -result "xxxxxxx"

Posted by sebres at Thu Aug 04 12:02:34 GMT 2022 [text] [code]

test io-4242-a {flush & gets on line-buffered channels when crlf is split over two buffers} -body { lassign [chan pipe] r w fconfigure $r -blocking 0 -buffering line -translation crlf -buffersize 8 fconfigure $w -blocking 0 -buffering line -translation binary -buffersize 8 set toev [after 1000 {set ::done TIMEOUT}] puts $w xxxxxxx fileevent $r readable [list apply {r { if {[gets $r line] > 0} {set ::done $line} }} $r] vwait ::done set ::done } -cleanup { close $w close $r after cancel $toev } -result "xxxxxxx" test io-4242-b {flush & gets on line-buffered channels when crlf is split over two buffers} -body { lassign [chan pipe] r w fconfigure $r -blocking 0 -buffering line -translation crlf -buffersize 8 fconfigure $w -blocking 0 -buffering line -translation crlf -buffersize 8 set toev [after 1000 {set ::done TIMEOUT}] puts $w xxxxxxx fileevent $r readable [list apply {r { if {[gets $r line] > 0} {set ::done $line} }} $r] vwait ::done set ::done } -cleanup { close $w close $r after cancel $toev } -result "xxxxxxx"

Posted by rmax at Thu Aug 04 12:15:26 GMT 2022 [text] [code]

test io-4242-b {flush & gets on line-buffered channels when crlf is split over two buffers} -body { lassign [chan pipe] r w fconfigure $r -blocking 0 -buffering line -translation crlf -buffersize 8 fconfigure $w -blocking 0 -translation binary -buffering none -buffersize 8 set toev [after 1000 {set ::done TIMEOUT}] puts -nonewline $w "1234567\r\n" fileevent $r readable [list apply {r { if {[gets $r line] > 0} {set ::done $line} }} $r] vwait ::done set ::done } -cleanup { close $w close $r after cancel $toev } -result "1234567"

Posted by rmax at Thu Aug 04 14:34:04 GMT 2022 [text] [code]

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>"