diff options
Diffstat (limited to 'tests/io.test')
-rw-r--r-- | tests/io.test | 1873 |
1 files changed, 934 insertions, 939 deletions
diff --git a/tests/io.test b/tests/io.test index 0688c14..a0f4297 100644 --- a/tests/io.test +++ b/tests/io.test @@ -52,13 +52,13 @@ testConstraint largefileSupport 0 set umaskValue 0 testConstraint umask [expr {![catch {set umaskValue [scan [exec /bin/sh -c umask] %o]}]}] -testConstraint makeFileInHome [expr {![file exists ~/_test_] && [file writable ~]}] +testConstraint makeFileInHome [expr {(![file exists ~/_test_]) && [file writable ~]}] # set up a long data file for some of the following tests set path(longfile) [makeFile {} longfile] set f [open $path(longfile) w] -fconfigure $f -eofchar {} -translation lf +chan configure $f -eofchar {} -translation lf for { set i 0 } { $i < 100 } { incr i} { puts $f "#123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef \#123456789abcdef01 @@ -68,12 +68,12 @@ close $f set path(cat) [makeFile { set f stdin - if {$argv != ""} { + if {$argv ne ""} { set f [open [lindex $argv 0]] } - fconfigure $f -encoding binary -translation lf -blocking 0 -eofchar \x1a - fconfigure stdout -encoding binary -translation lf -buffering none - fileevent $f readable "foo $f" + chan configure $f -encoding binary -translation lf -blocking 0 -eofchar \x1a + chan configure stdout -encoding binary -translation lf -buffering none + chan event $f readable "foo $f" proc foo {f} { set x [read $f] catch {puts -nonewline $x} @@ -89,7 +89,7 @@ set thisScript [file join [pwd] [info script]] proc contents {file} { set f [open $file] - fconfigure $f -translation binary + chan configure $f -translation binary set a [read $f] close $f return $a @@ -101,14 +101,14 @@ test io-1.5 {Tcl_WriteChars: CheckChannelErrors} {emptyTest} { set path(test1) [makeFile {} test1] test io-1.6 {Tcl_WriteChars: WriteBytes} { set f [open $path(test1) w] - fconfigure $f -encoding binary + chan configure $f -encoding binary puts -nonewline $f "a\u4e4d\0" close $f contents $path(test1) } "a\x4d\x00" test io-1.7 {Tcl_WriteChars: WriteChars} { set f [open $path(test1) w] - fconfigure $f -encoding shiftjis + chan configure $f -encoding shiftjis puts -nonewline $f "a\u4e4d\0" close $f contents $path(test1) @@ -122,7 +122,7 @@ test io-1.8 {Tcl_WriteChars: WriteChars} { # go into an infinite loop. set f [open $path(test2) w] - fconfigure $f -encoding iso2022-jp + chan configure $f -encoding iso2022-jp puts -nonewline $f [format %s%c [string repeat " " 4] 12399] close $f contents $path(test2) @@ -140,7 +140,7 @@ test io-1.9 {Tcl_WriteChars: WriteChars} { # With default buffer size set f [open $path(test2) w] - fconfigure $f -encoding iso2022-jp + chan configure $f -encoding iso2022-jp puts -nonewline $f $data close $f lappend sizes [file size $path(test2)] @@ -150,7 +150,7 @@ test io-1.9 {Tcl_WriteChars: WriteChars} { # go into the next buffer. set f [open $path(test2) w] - fconfigure $f -encoding iso2022-jp -buffersize 16 + chan configure $f -encoding iso2022-jp -buffersize 16 puts -nonewline $f $data close $f lappend sizes [file size $path(test2)] @@ -162,7 +162,7 @@ test io-1.9 {Tcl_WriteChars: WriteChars} { # and then again to the second buffer. set f [open $path(test2) w] - fconfigure $f -encoding iso2022-jp -buffersize 17 + chan configure $f -encoding iso2022-jp -buffersize 17 puts -nonewline $f $data close $f lappend sizes [file size $path(test2)] @@ -171,7 +171,7 @@ test io-1.9 {Tcl_WriteChars: WriteChars} { # 3 bytes of escaped data. set f [open $path(test2) w] - fconfigure $f -encoding iso2022-jp -buffersize 18 + chan configure $f -encoding iso2022-jp -buffersize 18 puts -nonewline $f $data close $f lappend sizes [file size $path(test2)] @@ -180,7 +180,7 @@ test io-1.9 {Tcl_WriteChars: WriteChars} { # data and escape bytes. set f [open $path(test2) w] - fconfigure $f -encoding iso2022-jp -buffersize 19 + chan configure $f -encoding iso2022-jp -buffersize 19 puts -nonewline $f $data close $f lappend sizes [file size $path(test2)] @@ -192,7 +192,7 @@ test io-2.1 {WriteBytes} { # loop until all bytes are written set f [open $path(test1) w] - fconfigure $f -encoding binary -buffersize 16 -translation crlf + chan configure $f -encoding binary -buffersize 16 -translation crlf puts $f "abcdefghijklmnopqrstuvwxyz" close $f contents $path(test1) @@ -202,7 +202,7 @@ test io-2.2 {WriteBytes: savedLF > 0} { # \n -> \r\n expansion. It gets stuck at beginning of this buffer. set f [open $path(test1) w] - fconfigure $f -encoding binary -buffersize 16 -translation crlf + chan configure $f -encoding binary -buffersize 16 -translation crlf puts -nonewline $f "123456789012345\n12" set x [list [contents $path(test1)]] close $f @@ -214,7 +214,7 @@ test io-2.3 {WriteBytes: flush on line} { # only up to the \n. set f [open $path(test1) w] - fconfigure $f -encoding binary -buffering line -translation crlf + chan configure $f -encoding binary -buffering line -translation crlf puts -nonewline $f "\n12" set x [contents $path(test1)] close $f @@ -222,7 +222,7 @@ test io-2.3 {WriteBytes: flush on line} { } "\r\n12" test io-2.4 {WriteBytes: reset sawLF after each buffer} { set f [open $path(test1) w] - fconfigure $f -encoding binary -buffering line -translation lf \ + chan configure $f -encoding binary -buffering line -translation lf \ -buffersize 16 puts -nonewline $f "abcdefg\nhijklmnopqrstuvwxyz" set x [list [contents $path(test1)]] @@ -234,7 +234,7 @@ test io-3.1 {WriteChars: compatibility with WriteBytes} { # loop until all bytes are written set f [open $path(test1) w] - fconfigure $f -encoding ascii -buffersize 16 -translation crlf + chan configure $f -encoding ascii -buffersize 16 -translation crlf puts $f "abcdefghijklmnopqrstuvwxyz" close $f contents $path(test1) @@ -244,7 +244,7 @@ test io-3.2 {WriteChars: compatibility with WriteBytes: savedLF > 0} { # \n -> \r\n expansion. It gets stuck at beginning of this buffer. set f [open $path(test1) w] - fconfigure $f -encoding ascii -buffersize 16 -translation crlf + chan configure $f -encoding ascii -buffersize 16 -translation crlf puts -nonewline $f "123456789012345\n12" set x [list [contents $path(test1)]] close $f @@ -256,7 +256,7 @@ test io-3.3 {WriteChars: compatibility with WriteBytes: flush on line} { # only up to the \n. set f [open $path(test1) w] - fconfigure $f -encoding ascii -buffering line -translation crlf + chan configure $f -encoding ascii -buffering line -translation crlf puts -nonewline $f "\n12" set x [contents $path(test1)] close $f @@ -266,7 +266,7 @@ test io-3.4 {WriteChars: loop over stage buffer} { # stage buffer maps to more than can be queued at once. set f [open $path(test1) w] - fconfigure $f -encoding jis0208 -buffersize 16 + chan configure $f -encoding jis0208 -buffersize 16 puts -nonewline $f "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" set x [list [contents $path(test1)]] close $f @@ -278,7 +278,7 @@ test io-3.5 {WriteChars: saved != 0} { # requested buffersize. set f [open $path(test1) w] - fconfigure $f -encoding jis0208 -buffersize 17 + chan configure $f -encoding jis0208 -buffersize 17 puts -nonewline $f "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" set x [list [contents $path(test1)]] close $f @@ -295,7 +295,7 @@ test io-3.6 {WriteChars: (stageRead + dstWrote == 0)} { # (the last byte of \uff21 plus the all of \uff22) appended. set f [open $path(test1) w] - fconfigure $f -encoding shiftjis -buffersize 16 + chan configure $f -encoding shiftjis -buffersize 16 puts -nonewline $f "12345678901234\uff21\uff22" set x [list [contents $path(test1)]] close $f @@ -309,7 +309,7 @@ test io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} { # of the next channel buffer. set f [open $path(test1) w] - fconfigure $f -encoding jis0208 -buffersize 17 + chan configure $f -encoding jis0208 -buffersize 17 puts -nonewline $f "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" set x [list [contents $path(test1)]] close $f @@ -317,7 +317,7 @@ test io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} { } [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"] test io-3.8 {WriteChars: reset sawLF after each buffer} { set f [open $path(test1) w] - fconfigure $f -encoding ascii -buffering line -translation lf \ + chan configure $f -encoding ascii -buffering line -translation lf \ -buffersize 16 puts -nonewline $f "abcdefg\nhijklmnopqrstuvwxyz" set x [list [contents $path(test1)]] @@ -329,7 +329,7 @@ test io-4.1 {TranslateOutputEOL: lf} { # search for \n set f [open $path(test1) w] - fconfigure $f -buffering line -translation lf + chan configure $f -buffering line -translation lf puts $f "abcde" set x [list [contents $path(test1)]] close $f @@ -339,7 +339,7 @@ test io-4.2 {TranslateOutputEOL: cr} { # search for \n, replace with \r set f [open $path(test1) w] - fconfigure $f -buffering line -translation cr + chan configure $f -buffering line -translation cr puts $f "abcde" set x [list [contents $path(test1)]] close $f @@ -349,7 +349,7 @@ test io-4.3 {TranslateOutputEOL: crlf} { # simple case: search for \n, replace with \r set f [open $path(test1) w] - fconfigure $f -buffering line -translation crlf + chan configure $f -buffering line -translation crlf puts $f "abcde" set x [list [contents $path(test1)]] close $f @@ -361,7 +361,7 @@ test io-4.4 {TranslateOutputEOL: crlf} { # dest buffer while (dstEnd < dstMax). set f [open $path(test1) w] - fconfigure $f -translation crlf -buffersize 16 + chan configure $f -translation crlf -buffersize 16 puts -nonewline $f "1234567\n\n\n\n\nA" set x [list [contents $path(test1)]] close $f @@ -371,7 +371,7 @@ test io-4.5 {TranslateOutputEOL: crlf} { # Check for overflow of the destination buffer set f [open $path(test1) w] - fconfigure $f -translation crlf -buffersize 12 + chan configure $f -translation crlf -buffersize 12 puts -nonewline $f "12345678901\n456789012345678901234" close $f set x [contents $path(test1)] @@ -379,7 +379,7 @@ test io-4.5 {TranslateOutputEOL: crlf} { test io-5.1 {CheckFlush: not full} { set f [open $path(test1) w] - fconfigure $f + chan configure $f puts -nonewline $f "12345678901234567890" set x [list [contents $path(test1)]] close $f @@ -387,7 +387,7 @@ test io-5.1 {CheckFlush: not full} { } [list "" "12345678901234567890"] test io-5.2 {CheckFlush: full} { set f [open $path(test1) w] - fconfigure $f -buffersize 16 + chan configure $f -buffersize 16 puts -nonewline $f "12345678901234567890" set x [list [contents $path(test1)]] close $f @@ -395,7 +395,7 @@ test io-5.2 {CheckFlush: full} { } [list "1234567890123456" "12345678901234567890"] test io-5.3 {CheckFlush: not line} { set f [open $path(test1) w] - fconfigure $f -buffering line + chan configure $f -buffering line puts -nonewline $f "12345678901234567890" set x [list [contents $path(test1)]] close $f @@ -403,7 +403,7 @@ test io-5.3 {CheckFlush: not line} { } [list "" "12345678901234567890"] test io-5.4 {CheckFlush: line} { set f [open $path(test1) w] - fconfigure $f -buffering line -translation lf -encoding ascii + chan configure $f -buffering line -translation lf -encoding ascii puts -nonewline $f "1234567890\n1234567890" set x [list [contents $path(test1)]] close $f @@ -411,7 +411,7 @@ test io-5.4 {CheckFlush: line} { } [list "1234567890\n1234567890" "1234567890\n1234567890"] test io-5.5 {CheckFlush: none} { set f [open $path(test1) w] - fconfigure $f -buffering none + chan configure $f -buffering none puts -nonewline $f "1234567890" set x [list [contents $path(test1)]] close $f @@ -434,7 +434,7 @@ test io-6.3 {Tcl_GetsObj: how many have we used?} { # if (bufPtr != NULL) {oldRemoved = bufPtr->nextRemoved} set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf puts $f "abc\ndefg" close $f set f [open $path(test1)] @@ -444,22 +444,22 @@ test io-6.3 {Tcl_GetsObj: how many have we used?} { } {0 3 5 4 defg} test io-6.4 {Tcl_GetsObj: encoding == NULL} { set f [open $path(test1) w] - fconfigure $f -translation binary + chan configure $f -translation binary puts $f "\x81\u1234\0" close $f set f [open $path(test1)] - fconfigure $f -translation binary + chan configure $f -translation binary set x [list [gets $f line] $line] close $f set x } [list 3 "\x81\x34\x00"] test io-6.5 {Tcl_GetsObj: encoding != NULL} { set f [open $path(test1) w] - fconfigure $f -translation binary + chan configure $f -translation binary puts $f "\x88\xea\x92\x9a" close $f set f [open $path(test1)] - fconfigure $f -encoding shiftjis + chan configure $f -encoding shiftjis set x [list [gets $f line] $line] close $f set x @@ -486,7 +486,7 @@ test io-6.7 {Tcl_GetsObj: error in input} {stdio openpipe} { puts -nonewline $f "hi\nwould" flush $f gets $f - fconfigure $f -blocking 0 + chan configure $f -blocking 0 set x [gets $f line] close $f set x @@ -496,7 +496,7 @@ test io-6.8 {Tcl_GetsObj: remember if EOF is seen} { puts $f "abcdef\x1aghijk\nwombat" close $f set f [open $path(test1)] - fconfigure $f -eofchar \x1a + chan configure $f -eofchar \x1a set x [list [gets $f line] $line [gets $f line] $line] close $f set x @@ -506,7 +506,7 @@ test io-6.9 {Tcl_GetsObj: remember if EOF is seen} { puts $f "abcdefghijk\nwom\u001abat" close $f set f [open $path(test1)] - fconfigure $f -eofchar \x1a + chan configure $f -eofchar \x1a set x [list [gets $f line] $line [gets $f line] $line] close $f set x @@ -516,62 +516,62 @@ test io-6.10 {Tcl_GetsObj: lf mode: no chars} { set f [open $path(test1) w] close $f set f [open $path(test1)] - fconfigure $f -translation lf + chan configure $f -translation lf set x [list [gets $f line] $line] close $f set x } {-1 {}} test io-6.11 {Tcl_GetsObj: lf mode: lone \n} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "\n" close $f set f [open $path(test1)] - fconfigure $f -translation lf + chan configure $f -translation lf set x [list [gets $f line] $line [gets $f line] $line] close $f set x } {0 {} -1 {}} test io-6.12 {Tcl_GetsObj: lf mode: lone \r} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "\r" close $f set f [open $path(test1)] - fconfigure $f -translation lf + chan configure $f -translation lf set x [list [gets $f line] $line [gets $f line] $line] close $f set x } [list 1 "\r" -1 ""] test io-6.13 {Tcl_GetsObj: lf mode: 1 char} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f a close $f set f [open $path(test1)] - fconfigure $f -translation lf + chan configure $f -translation lf set x [list [gets $f line] $line [gets $f line] $line] close $f set x } {1 a -1 {}} test io-6.14 {Tcl_GetsObj: lf mode: 1 char followed by EOL} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "a\n" close $f set f [open $path(test1)] - fconfigure $f -translation lf + chan configure $f -translation lf set x [list [gets $f line] $line [gets $f line] $line] close $f set x } {1 a -1 {}} test io-6.15 {Tcl_GetsObj: lf mode: several chars} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "abcd\nefgh\rijkl\r\nmnop" close $f set f [open $path(test1)] - fconfigure $f -translation lf + chan configure $f -translation lf set x [list [gets $f line] $line [gets $f line] $line [gets $f line] $line [gets $f line] $line] close $f set x @@ -580,62 +580,62 @@ test io-6.16 {Tcl_GetsObj: cr mode: no chars} { set f [open $path(test1) w] close $f set f [open $path(test1)] - fconfigure $f -translation cr + chan configure $f -translation cr set x [list [gets $f line] $line] close $f set x } {-1 {}} test io-6.17 {Tcl_GetsObj: cr mode: lone \n} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "\n" close $f set f [open $path(test1)] - fconfigure $f -translation cr + chan configure $f -translation cr set x [list [gets $f line] $line [gets $f line] $line] close $f set x } [list 1 "\n" -1 ""] test io-6.18 {Tcl_GetsObj: cr mode: lone \r} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "\r" close $f set f [open $path(test1)] - fconfigure $f -translation cr + chan configure $f -translation cr set x [list [gets $f line] $line [gets $f line] $line] close $f set x } {0 {} -1 {}} test io-6.19 {Tcl_GetsObj: cr mode: 1 char} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f a close $f set f [open $path(test1)] - fconfigure $f -translation cr + chan configure $f -translation cr set x [list [gets $f line] $line [gets $f line] $line] close $f set x } {1 a -1 {}} test io-6.20 {Tcl_GetsObj: cr mode: 1 char followed by EOL} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "a\r" close $f set f [open $path(test1)] - fconfigure $f -translation cr + chan configure $f -translation cr set x [list [gets $f line] $line [gets $f line] $line] close $f set x } {1 a -1 {}} test io-6.21 {Tcl_GetsObj: cr mode: several chars} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "abcd\nefgh\rijkl\r\nmnop" close $f set f [open $path(test1)] - fconfigure $f -translation cr + chan configure $f -translation cr set x [list [gets $f line] $line [gets $f line] $line [gets $f line] $line [gets $f line] $line] close $f set x @@ -644,84 +644,84 @@ test io-6.22 {Tcl_GetsObj: crlf mode: no chars} { set f [open $path(test1) w] close $f set f [open $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf set x [list [gets $f line] $line] close $f set x } {-1 {}} test io-6.23 {Tcl_GetsObj: crlf mode: lone \n} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "\n" close $f set f [open $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf set x [list [gets $f line] $line [gets $f line] $line] close $f set x } [list 1 "\n" -1 ""] test io-6.24 {Tcl_GetsObj: crlf mode: lone \r} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "\r" close $f set f [open $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf set x [list [gets $f line] $line [gets $f line] $line] close $f set x } [list 1 "\r" -1 ""] test io-6.25 {Tcl_GetsObj: crlf mode: \r\r} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "\r\r" close $f set f [open $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf set x [list [gets $f line] $line [gets $f line] $line] close $f set x } [list 2 "\r\r" -1 ""] test io-6.26 {Tcl_GetsObj: crlf mode: \r\n} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "\r\n" close $f set f [open $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf set x [list [gets $f line] $line [gets $f line] $line] close $f set x } [list 0 "" -1 ""] test io-6.27 {Tcl_GetsObj: crlf mode: 1 char} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f a close $f set f [open $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf set x [list [gets $f line] $line [gets $f line] $line] close $f set x } {1 a -1 {}} test io-6.28 {Tcl_GetsObj: crlf mode: 1 char followed by EOL} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "a\r\n" close $f set f [open $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf set x [list [gets $f line] $line [gets $f line] $line] close $f set x } {1 a -1 {}} test io-6.29 {Tcl_GetsObj: crlf mode: several chars} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "abcd\nefgh\rijkl\r\nmnop" close $f set f [open $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf set x [list [gets $f line] $line [gets $f line] $line [gets $f line] $line] close $f set x @@ -730,25 +730,25 @@ test io-6.30 {Tcl_GetsObj: crlf mode: buffer exhausted} {testchannel} { # if (eol >= dstEnd) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "123456789012345\r\nabcdefghijklmnoprstuvwxyz" close $f set f [open $path(test1)] - fconfigure $f -translation crlf -buffersize 16 + chan configure $f -translation crlf -buffersize 16 set x [list [gets $f line] $line [testchannel inputbuffered $f]] close $f set x } [list 15 "123456789012345" 15] -test io-6.31 {Tcl_GetsObj: crlf mode: buffer exhausted, blocked} {stdio testchannel openpipe fileevent} { +test io-6.31 {Tcl_GetsObj: crlf mode: buffer exhausted, blocked} {stdio testchannel openpipe chan event} { # (FilterInputBytes() != 0) set f [open "|[list [interpreter] $path(cat)]" w+] - fconfigure $f -translation {crlf lf} -buffering none + chan configure $f -translation {crlf lf} -buffering none puts -nonewline $f "bbbbbbbbbbbbbb\r\n123456789012345\r" - fconfigure $f -buffersize 16 + chan configure $f -buffersize 16 set x [gets $f] - fconfigure $f -blocking 0 - lappend x [gets $f line] $line [fblocked $f] [testchannel inputbuffered $f] + chan configure $f -blocking 0 + lappend x [gets $f line] $line [chan blocked $f] [testchannel inputbuffered $f] close $f set x } [list "bbbbbbbbbbbbbb" -1 "" 1 16] @@ -756,11 +756,11 @@ test io-6.32 {Tcl_GetsObj: crlf mode: buffer exhausted, more data} {testchannel} # not (FilterInputBytes() != 0) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "123456789012345\r\n123" close $f set f [open $path(test1)] - fconfigure $f -translation crlf -buffersize 16 + chan configure $f -translation crlf -buffersize 16 set x [list [gets $f line] $line [tell $f] [testchannel inputbuffered $f]] close $f set x @@ -769,11 +769,11 @@ test io-6.33 {Tcl_GetsObj: crlf mode: buffer exhausted, at eof} { # eol still equals dstEnd set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "123456789012345\r" close $f set f [open $path(test1)] - fconfigure $f -translation crlf -buffersize 16 + chan configure $f -translation crlf -buffersize 16 set x [list [gets $f line] $line [eof $f]] close $f set x @@ -782,11 +782,11 @@ test io-6.34 {Tcl_GetsObj: crlf mode: buffer exhausted, not followed by \n} { # not (*eol == '\n') set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "123456789012345\rabcd\r\nefg" close $f set f [open $path(test1)] - fconfigure $f -translation crlf -buffersize 16 + chan configure $f -translation crlf -buffersize 16 set x [list [gets $f line] $line [tell $f]] close $f set x @@ -795,151 +795,151 @@ test io-6.35 {Tcl_GetsObj: auto mode: no chars} { set f [open $path(test1) w] close $f set f [open $path(test1)] - fconfigure $f -translation auto + chan configure $f -translation auto set x [list [gets $f line] $line] close $f set x } {-1 {}} test io-6.36 {Tcl_GetsObj: auto mode: lone \n} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "\n" close $f set f [open $path(test1)] - fconfigure $f -translation auto + chan configure $f -translation auto set x [list [gets $f line] $line [gets $f line] $line] close $f set x } [list 0 "" -1 ""] test io-6.37 {Tcl_GetsObj: auto mode: lone \r} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "\r" close $f set f [open $path(test1)] - fconfigure $f -translation auto + chan configure $f -translation auto set x [list [gets $f line] $line [gets $f line] $line] close $f set x } [list 0 "" -1 ""] test io-6.38 {Tcl_GetsObj: auto mode: \r\r} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "\r\r" close $f set f [open $path(test1)] - fconfigure $f -translation auto + chan configure $f -translation auto set x [list [gets $f line] $line [gets $f line] $line [gets $f line] $line] close $f set x } [list 0 "" 0 "" -1 ""] test io-6.39 {Tcl_GetsObj: auto mode: \r\n} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "\r\n" close $f set f [open $path(test1)] - fconfigure $f -translation auto + chan configure $f -translation auto set x [list [gets $f line] $line [gets $f line] $line] close $f set x } [list 0 "" -1 ""] test io-6.40 {Tcl_GetsObj: auto mode: 1 char} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f a close $f set f [open $path(test1)] - fconfigure $f -translation auto + chan configure $f -translation auto set x [list [gets $f line] $line [gets $f line] $line] close $f set x } {1 a -1 {}} test io-6.41 {Tcl_GetsObj: auto mode: 1 char followed by EOL} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "a\r\n" close $f set f [open $path(test1)] - fconfigure $f -translation auto + chan configure $f -translation auto set x [list [gets $f line] $line [gets $f line] $line] close $f set x } {1 a -1 {}} test io-6.42 {Tcl_GetsObj: auto mode: several chars} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "abcd\nefgh\rijkl\r\nmnop" close $f set f [open $path(test1)] - fconfigure $f -translation auto + chan configure $f -translation auto set x [list [gets $f line] $line [gets $f line] $line] lappend x [gets $f line] $line [gets $f line] $line [gets $f line] $line close $f set x } [list 4 "abcd" 4 "efgh" 4 "ijkl" 4 "mnop" -1 ""] -test io-6.43 {Tcl_GetsObj: input saw cr} {stdio testchannel openpipe fileevent} { +test io-6.43 {Tcl_GetsObj: input saw cr} {stdio testchannel openpipe chan event} { # if (chanPtr->flags & INPUT_SAW_CR) set f [open "|[list [interpreter] $path(cat)]" w+] - fconfigure $f -translation {auto lf} -buffering none + chan configure $f -translation {auto lf} -buffering none puts -nonewline $f "bbbbbbbbbbbbbbb\n123456789abcdef\r" - fconfigure $f -buffersize 16 + chan configure $f -buffersize 16 set x [list [gets $f]] - fconfigure $f -blocking 0 + chan configure $f -blocking 0 lappend x [gets $f line] $line [testchannel queuedcr $f] - fconfigure $f -blocking 1 + chan configure $f -blocking 1 puts -nonewline $f "\nabcd\refg\x1a" lappend x [gets $f line] $line [testchannel queuedcr $f] lappend x [gets $f line] $line close $f set x } [list "bbbbbbbbbbbbbbb" 15 "123456789abcdef" 1 4 "abcd" 0 3 "efg"] -test io-6.44 {Tcl_GetsObj: input saw cr, not followed by cr} {stdio testchannel openpipe fileevent} { +test io-6.44 {Tcl_GetsObj: input saw cr, not followed by cr} {stdio testchannel openpipe chan event} { # not (*eol == '\n') set f [open "|[list [interpreter] $path(cat)]" w+] - fconfigure $f -translation {auto lf} -buffering none + chan configure $f -translation {auto lf} -buffering none puts -nonewline $f "bbbbbbbbbbbbbbb\n123456789abcdef\r" - fconfigure $f -buffersize 16 + chan configure $f -buffersize 16 set x [list [gets $f]] - fconfigure $f -blocking 0 + chan configure $f -blocking 0 lappend x [gets $f line] $line [testchannel queuedcr $f] - fconfigure $f -blocking 1 + chan configure $f -blocking 1 puts -nonewline $f "abcd\refg\x1a" lappend x [gets $f line] $line [testchannel queuedcr $f] lappend x [gets $f line] $line close $f set x } [list "bbbbbbbbbbbbbbb" 15 "123456789abcdef" 1 4 "abcd" 0 3 "efg"] -test io-6.45 {Tcl_GetsObj: input saw cr, skip right number of bytes} {stdio testchannel openpipe fileevent} { +test io-6.45 {Tcl_GetsObj: input saw cr, skip right number of bytes} {stdio testchannel openpipe chan event} { # Tcl_ExternalToUtf() set f [open "|[list [interpreter] $path(cat)]" w+] - fconfigure $f -translation {auto lf} -buffering none - fconfigure $f -encoding unicode + chan configure $f -translation {auto lf} -buffering none + chan configure $f -encoding unicode puts -nonewline $f "bbbbbbbbbbbbbbb\n123456789abcdef\r" - fconfigure $f -buffersize 16 + chan configure $f -buffersize 16 gets $f - fconfigure $f -blocking 0 + chan configure $f -blocking 0 set x [list [gets $f line] $line [testchannel queuedcr $f]] - fconfigure $f -blocking 1 + chan configure $f -blocking 1 puts -nonewline $f "\nabcd\refg" lappend x [gets $f line] $line [testchannel queuedcr $f] close $f set x } [list 15 "123456789abcdef" 1 4 "abcd" 0] -test io-6.46 {Tcl_GetsObj: input saw cr, followed by just \n should give eof} {stdio testchannel openpipe fileevent} { +test io-6.46 {Tcl_GetsObj: input saw cr, followed by just \n should give eof} {stdio testchannel openpipe chan event} { # memmove() set f [open "|[list [interpreter] $path(cat)]" w+] - fconfigure $f -translation {auto lf} -buffering none + chan configure $f -translation {auto lf} -buffering none puts -nonewline $f "bbbbbbbbbbbbbbb\n123456789abcdef\r" - fconfigure $f -buffersize 16 + chan configure $f -buffersize 16 gets $f - fconfigure $f -blocking 0 + chan configure $f -blocking 0 set x [list [gets $f line] $line [testchannel queuedcr $f]] - fconfigure $f -blocking 1 + chan configure $f -blocking 1 puts -nonewline $f "\n\x1a" lappend x [gets $f line] $line [testchannel queuedcr $f] close $f @@ -949,11 +949,11 @@ test io-6.47 {Tcl_GetsObj: auto mode: \r at end of buffer, peek for \n} {testcha # (eol == dstEnd) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "123456789012345\r\nabcdefghijklmnopq" close $f set f [open $path(test1)] - fconfigure $f -translation auto -buffersize 16 + chan configure $f -translation auto -buffersize 16 set x [list [gets $f] [testchannel inputbuffered $f]] close $f set x @@ -962,11 +962,11 @@ test io-6.48 {Tcl_GetsObj: auto mode: \r at end of buffer, no more avail} {testc # PeekAhead() did not get any, so (eol >= dstEnd) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "123456789012345\r" close $f set f [open $path(test1)] - fconfigure $f -translation auto -buffersize 16 + chan configure $f -translation auto -buffersize 16 set x [list [gets $f] [testchannel queuedcr $f]] close $f set x @@ -975,7 +975,7 @@ test io-6.49 {Tcl_GetsObj: auto mode: \r followed by \n} {testchannel} { # if (*eol == '\n') {skip++} set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "123456\r\n78901" close $f set f [open $path(test1)] @@ -987,7 +987,7 @@ test io-6.50 {Tcl_GetsObj: auto mode: \r not followed by \n} {testchannel} { # not (*eol == '\n') set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "123456\r78901" close $f set f [open $path(test1)] @@ -999,7 +999,7 @@ test io-6.51 {Tcl_GetsObj: auto mode: \n} { # else if (*eol == '\n') {goto gotoeol;} set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "123456\n78901" close $f set f [open $path(test1)] @@ -1011,11 +1011,11 @@ test io-6.52 {Tcl_GetsObj: saw EOF character} {testchannel} { # if (eof != NULL) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "123456\x1ak9012345\r" close $f set f [open $path(test1)] - fconfigure $f -eofchar \x1a + chan configure $f -eofchar \x1a set x [list [gets $f] [testchannel queuedcr $f] [tell $f] [gets $f]] close $f set x @@ -1045,30 +1045,30 @@ test io-6.55 {Tcl_GetsObj: overconverted} { # Tcl_ExternalToUtf(), make sure state updated set f [open $path(test1) w] - fconfigure $f -encoding iso2022-jp + chan configure $f -encoding iso2022-jp puts $f "there\u4e00ok\n\u4e01more bytes\nhere" close $f set f [open $path(test1)] - fconfigure $f -encoding iso2022-jp + chan configure $f -encoding iso2022-jp set x [list [gets $f line] $line [gets $f line] $line [gets $f line] $line] close $f set x } [list 8 "there\u4e00ok" 11 "\u4e01more bytes" 4 "here"] -test io-6.56 {Tcl_GetsObj: incomplete lines should disable file events} {stdio openpipe fileevent} { +test io-6.56 {Tcl_GetsObj: incomplete lines should disable file events} {stdio openpipe chan event} { update set f [open "|[list [interpreter] $path(cat)]" w+] - fconfigure $f -buffering none + chan configure $f -buffering none puts -nonewline $f "foobar" - fconfigure $f -blocking 0 + chan configure $f -blocking 0 variable x {} after 500 [namespace code { lappend x timeout }] - fileevent $f readable [namespace code { lappend x [gets $f] }] + chan event $f readable [namespace code { lappend x [gets $f] }] vwait [namespace which -variable x] vwait [namespace which -variable x] - fconfigure $f -blocking 1 + chan configure $f -blocking 1 puts -nonewline $f "baz\n" after 500 [namespace code { lappend x timeout }] - fconfigure $f -blocking 0 + chan configure $f -blocking 0 vwait [namespace which -variable x] vwait [namespace which -variable x] close $f @@ -1079,11 +1079,11 @@ test io-7.1 {FilterInputBytes: split up character at end of buffer} { # (result == TCL_CONVERT_MULTIBYTE) set f [open $path(test1) w] - fconfigure $f -encoding shiftjis + chan configure $f -encoding shiftjis puts $f "1234567890123\uff10\uff11\uff12\uff13\uff14\nend" close $f set f [open $path(test1)] - fconfigure $f -encoding shiftjis -buffersize 16 + chan configure $f -encoding shiftjis -buffersize 16 set x [gets $f] close $f set x @@ -1092,43 +1092,43 @@ test io-7.2 {FilterInputBytes: split up character in middle of buffer} { # (bufPtr->nextAdded < bufPtr->bufLength) set f [open $path(test1) w] - fconfigure $f -encoding binary + chan configure $f -encoding binary puts -nonewline $f "1234567890\n123\x82\x4f\x82\x50\x82" close $f set f [open $path(test1)] - fconfigure $f -encoding shiftjis + chan configure $f -encoding shiftjis set x [list [gets $f line] $line [eof $f]] close $f set x } [list 10 "1234567890" 0] test io-7.3 {FilterInputBytes: split up character at EOF} {testchannel} { set f [open $path(test1) w] - fconfigure $f -encoding binary + chan configure $f -encoding binary puts -nonewline $f "1234567890123\x82\x4f\x82\x50\x82" close $f set f [open $path(test1)] - fconfigure $f -encoding shiftjis + chan configure $f -encoding shiftjis set x [list [gets $f line] $line] lappend x [tell $f] [testchannel inputbuffered $f] [eof $f] lappend x [gets $f line] $line close $f set x } [list 15 "1234567890123\uff10\uff11" 18 0 1 -1 ""] -test io-7.4 {FilterInputBytes: recover from split up character} {stdio openpipe fileevent} { +test io-7.4 {FilterInputBytes: recover from split up character} {stdio openpipe chan event} { set f [open "|[list [interpreter] $path(cat)]" w+] - fconfigure $f -encoding binary -buffering none + chan configure $f -encoding binary -buffering none puts -nonewline $f "1234567890123\x82\x4f\x82\x50\x82" - fconfigure $f -encoding shiftjis -blocking 0 - fileevent $f read [namespace code "ready $f"] + chan configure $f -encoding shiftjis -blocking 0 + chan event $f read [namespace code "ready $f"] variable x {} proc ready {f} { variable x - lappend x [gets $f line] $line [fblocked $f] + lappend x [gets $f line] $line [chan blocked $f] } vwait [namespace which -variable x] - fconfigure $f -encoding binary -blocking 1 + chan configure $f -encoding binary -blocking 1 puts $f "\x51\x82\x52" - fconfigure $f -encoding shiftjis + chan configure $f -encoding shiftjis vwait [namespace which -variable x] close $f set x @@ -1138,42 +1138,42 @@ test io-8.1 {PeekAhead: only go to device if no more cached data} {testchannel} # (bufPtr->nextPtr == NULL) set f [open $path(test1) w] - fconfigure $f -encoding ascii -translation lf + chan configure $f -encoding ascii -translation lf puts -nonewline $f "123456789012345\r\n2345678" close $f set f [open $path(test1)] - fconfigure $f -encoding ascii -translation auto -buffersize 16 + chan configure $f -encoding ascii -translation auto -buffersize 16 # here gets $f set x [testchannel inputbuffered $f] close $f set x } "7" -test io-8.2 {PeekAhead: only go to device if no more cached data} {stdio testchannel openpipe fileevent} { +test io-8.2 {PeekAhead: only go to device if no more cached data} {stdio testchannel openpipe chan event} { # not (bufPtr->nextPtr == NULL) set f [open "|[list [interpreter] $path(cat)]" w+] - fconfigure $f -translation lf -encoding ascii -buffering none + chan configure $f -translation lf -encoding ascii -buffering none puts -nonewline $f "123456789012345\r\nbcdefghijklmnopqrstuvwxyz" variable x {} - fileevent $f read [namespace code "ready $f"] + chan event $f read [namespace code "ready $f"] proc ready {f} { variable x lappend x [gets $f line] $line [testchannel inputbuffered $f] } - fconfigure $f -encoding unicode -buffersize 16 -blocking 0 + chan configure $f -encoding unicode -buffersize 16 -blocking 0 vwait [namespace which -variable x] - fconfigure $f -translation auto -encoding ascii -blocking 1 + chan configure $f -translation auto -encoding ascii -blocking 1 # here vwait [namespace which -variable x] close $f set x } [list -1 "" 42 15 "123456789012345" 25] -test io-8.3 {PeekAhead: no cached data available} {stdio testchannel openpipe fileevent} { +test io-8.3 {PeekAhead: no cached data available} {stdio testchannel openpipe chan event} { # (bytesLeft == 0) set f [open "|[list [interpreter] $path(cat)]" w+] - fconfigure $f -translation {auto binary} + chan configure $f -translation {auto binary} puts -nonewline $f "abcdefghijklmno\r" flush $f set x [list [gets $f line] $line [testchannel queuedcr $f]] @@ -1187,11 +1187,11 @@ test io-8.4 {PeekAhead: cached data available in this buffer} { # not (bytesLeft == 0) set f [open $path(test1) w+] - fconfigure $f -translation binary + chan configure $f -translation binary puts $f "${a}\r\nabcdef" close $f set f [open $path(test1)] - fconfigure $f -encoding binary -translation auto + chan configure $f -encoding binary -translation auto # "${a}\r" was converted in one operation (because ENCODING_LINESIZE # is 30). To check if "\n" follows, calls PeekAhead and determines @@ -1202,11 +1202,11 @@ test io-8.4 {PeekAhead: cached data available in this buffer} { set x } $a unset a -test io-8.5 {PeekAhead: don't peek if last read was short} {stdio testchannel openpipe fileevent} { +test io-8.5 {PeekAhead: don't peek if last read was short} {stdio testchannel openpipe chan event} { # (bufPtr->nextAdded < bufPtr->length) set f [open "|[list [interpreter] $path(cat)]" w+] - fconfigure $f -translation {auto binary} + chan configure $f -translation {auto binary} puts -nonewline $f "abcdefghijklmno\r" flush $f # here @@ -1214,11 +1214,11 @@ test io-8.5 {PeekAhead: don't peek if last read was short} {stdio testchannel op close $f set x } {15 abcdefghijklmno 1} -test io-8.6 {PeekAhead: change to non-blocking mode} {stdio testchannel openpipe fileevent} { +test io-8.6 {PeekAhead: change to non-blocking mode} {stdio testchannel openpipe chan event} { # ((chanPtr->flags & CHANNEL_NONBLOCKING) == 0) set f [open "|[list [interpreter] $path(cat)]" w+] - fconfigure $f -translation {auto binary} -buffersize 16 + chan configure $f -translation {auto binary} -buffersize 16 puts -nonewline $f "abcdefghijklmno\r" flush $f # here @@ -1226,11 +1226,11 @@ test io-8.6 {PeekAhead: change to non-blocking mode} {stdio testchannel openpipe close $f set x } {15 abcdefghijklmno 1} -test io-8.7 {PeekAhead: cleanup} {stdio testchannel openpipe fileevent} { +test io-8.7 {PeekAhead: cleanup} {stdio testchannel openpipe chan event} { # Make sure bytes are removed from buffer. set f [open "|[list [interpreter] $path(cat)]" w+] - fconfigure $f -translation {auto binary} -buffering none + chan configure $f -translation {auto binary} -buffering none puts -nonewline $f "abcdefghijklmno\r" # here set x [list [gets $f line] $line [testchannel queuedcr $f]] @@ -1268,7 +1268,7 @@ test io-10.3 {Tcl_ReadChars: loop until enough copied} { close $f set f [open $path(test1)] - fconfigure $f -buffersize 16 + chan configure $f -buffersize 16 # here set x [read $f 19] close $f @@ -1308,7 +1308,7 @@ test io-11.1 {ReadBytes: want to read a lot} { puts -nonewline $f abcdefghijkl close $f set f [open $path(test1)] - fconfigure $f -encoding binary + chan configure $f -encoding binary # here set x [read $f 1000] close $f @@ -1321,7 +1321,7 @@ test io-11.2 {ReadBytes: want to read all} { puts -nonewline $f abcdefghijkl close $f set f [open $path(test1)] - fconfigure $f -encoding binary + chan configure $f -encoding binary # here set x [read $f] close $f @@ -1334,7 +1334,7 @@ test io-11.3 {ReadBytes: allocate more space} { puts -nonewline $f abcdefghijklmnopqrstuvwxyz close $f set f [open $path(test1)] - fconfigure $f -buffersize 16 -encoding binary + chan configure $f -buffersize 16 -encoding binary # here set x [read $f] close $f @@ -1347,7 +1347,7 @@ test io-11.4 {ReadBytes: EOF char found} { puts $f abcdefghijklmnopqrstuvwxyz close $f set f [open $path(test1)] - fconfigure $f -eofchar m -encoding binary + chan configure $f -eofchar m -encoding binary # here set x [list [read $f] [eof $f] [read $f] [eof $f]] close $f @@ -1385,46 +1385,46 @@ test io-12.3 {ReadChars: allocate more space} { puts -nonewline $f abcdefghijklmnopqrstuvwxyz close $f set f [open $path(test1)] - fconfigure $f -buffersize 16 + chan configure $f -buffersize 16 # here set x [read $f] close $f set x } {abcdefghijklmnopqrstuvwxyz} -test io-12.4 {ReadChars: split-up char} {stdio testchannel openpipe fileevent} { +test io-12.4 {ReadChars: split-up char} {stdio testchannel openpipe chan event} { # (srcRead == 0) set f [open "|[list [interpreter] $path(cat)]" w+] - fconfigure $f -encoding binary -buffering none -buffersize 16 + chan configure $f -encoding binary -buffering none -buffersize 16 puts -nonewline $f "123456789012345\x96" - fconfigure $f -encoding shiftjis -blocking 0 + chan configure $f -encoding shiftjis -blocking 0 - fileevent $f read [namespace code "ready $f"] + chan event $f read [namespace code "ready $f"] proc ready {f} { variable x lappend x [read $f] [testchannel inputbuffered $f] } variable x {} - fconfigure $f -encoding shiftjis + chan configure $f -encoding shiftjis vwait [namespace which -variable x] - fconfigure $f -encoding binary -blocking 1 + chan configure $f -encoding binary -blocking 1 puts -nonewline $f "\x7b" after 500 ;# Give the cat process time to catch up - fconfigure $f -encoding shiftjis -blocking 0 + chan configure $f -encoding shiftjis -blocking 0 vwait [namespace which -variable x] close $f set x } [list "123456789012345" 1 "\u672c" 0] -test io-12.5 {ReadChars: fileevents on partial characters} {stdio openpipe fileevent} { +test io-12.5 {ReadChars: chan events on partial characters} {stdio openpipe chan event} { set path(test1) [makeFile { - fconfigure stdout -encoding binary -buffering none + chan configure stdout -encoding binary -buffering none gets stdin; puts -nonewline "\xe7" gets stdin; puts -nonewline "\x89" gets stdin; puts -nonewline "\xa6" } test1] set f [open "|[list [interpreter] $path(test1)]" r+] - fileevent $f readable [namespace code { + chan event $f readable [namespace code { lappend x [read $f] if {[eof $f]} { lappend x eof @@ -1432,7 +1432,7 @@ test io-12.5 {ReadChars: fileevents on partial characters} {stdio openpipe filee }] puts $f "go1" flush $f - fconfigure $f -blocking 0 -encoding utf-8 + chan configure $f -blocking 0 -encoding utf-8 variable x {} vwait [namespace which -variable x] after 500 [namespace code { lappend x timeout }] @@ -1452,22 +1452,22 @@ test io-12.5 {ReadChars: fileevents on partial characters} {stdio openpipe filee test io-13.1 {TranslateInputEOL: cr mode} {} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "abcd\rdef\r" close $f set f [open $path(test1)] - fconfigure $f -translation cr + chan configure $f -translation cr set x [read $f] close $f set x } "abcd\ndef\n" test io-13.2 {TranslateInputEOL: crlf mode} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "abcd\r\ndef\r\n" close $f set f [open $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf set x [read $f] close $f set x @@ -1476,11 +1476,11 @@ test io-13.3 {TranslateInputEOL: crlf mode: naked cr} { # (src >= srcMax) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "abcd\r\ndef\r" close $f set f [open $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf set x [read $f] close $f set x @@ -1489,11 +1489,11 @@ test io-13.4 {TranslateInputEOL: crlf mode: cr followed by not \n} { # (src >= srcMax) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "abcd\r\ndef\rfgh" close $f set f [open $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf set x [read $f] close $f set x @@ -1502,23 +1502,23 @@ test io-13.5 {TranslateInputEOL: crlf mode: naked lf} { # (src >= srcMax) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "abcd\r\ndef\nfgh" close $f set f [open $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf set x [read $f] close $f set x } "abcd\ndef\nfgh" -test io-13.6 {TranslateInputEOL: auto mode: saw cr in last segment} {stdio testchannel openpipe fileevent} { +test io-13.6 {TranslateInputEOL: auto mode: saw cr in last segment} {stdio testchannel openpipe chan event} { # (chanPtr->flags & INPUT_SAW_CR) # This test may fail on slower machines. set f [open "|[list [interpreter] $path(cat)]" w+] - fconfigure $f -blocking 0 -buffering none -translation {auto lf} + chan configure $f -blocking 0 -buffering none -translation {auto lf} - fileevent $f read [namespace code "ready $f"] + chan event $f read [namespace code "ready $f"] proc ready {f} { variable x lappend x [read $f] [testchannel queuedcr $f] @@ -1541,11 +1541,11 @@ test io-13.7 {TranslateInputEOL: auto mode: naked \r} {testchannel openpipe} { # (src >= srcMax) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "abcd\r" close $f set f [open $path(test1)] - fconfigure $f -translation auto + chan configure $f -translation auto set x [list [read $f] [testchannel queuedcr $f]] close $f set x @@ -1554,22 +1554,22 @@ test io-13.8 {TranslateInputEOL: auto mode: \r\n} { # (*src == '\n') set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "abcd\r\ndef" close $f set f [open $path(test1)] - fconfigure $f -translation auto + chan configure $f -translation auto set x [read $f] close $f set x } "abcd\ndef" test io-13.9 {TranslateInputEOL: auto mode: \r followed by not \n} { set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "abcd\rdef" close $f set f [open $path(test1)] - fconfigure $f -translation auto + chan configure $f -translation auto set x [read $f] close $f set x @@ -1578,11 +1578,11 @@ test io-13.10 {TranslateInputEOL: auto mode: \n} { # not (*src == '\r') set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "abcd\ndef" close $f set f [open $path(test1)] - fconfigure $f -translation auto + chan configure $f -translation auto set x [read $f] close $f set x @@ -1591,11 +1591,11 @@ test io-13.11 {TranslateInputEOL: EOF char} { # (*chanPtr->inEofChar != '\0') set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "abcd\ndefgh" close $f set f [open $path(test1)] - fconfigure $f -translation auto -eofchar e + chan configure $f -translation auto -eofchar e set x [read $f] close $f set x @@ -1604,11 +1604,11 @@ test io-13.12 {TranslateInputEOL: find EOF char in src} { # (*chanPtr->inEofChar != '\0') set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "\r\n\r\n\r\nab\r\n\r\ndef\r\n\r\n\r\n" close $f set f [open $path(test1)] - fconfigure $f -translation auto -eofchar e + chan configure $f -translation auto -eofchar e set x [read $f] close $f set x @@ -1618,7 +1618,7 @@ test io-13.12 {TranslateInputEOL: find EOF char in src} { # Tcl_SetStdChannel and Tcl_GetStdChannel. Incidentally we are # also testing channel table management. -if {[info commands testchannel] != ""} { +if {[info commands testchannel] ne ""} { set consoleFileNames [lsort [testchannel open]] } else { # just to avoid an error @@ -1627,18 +1627,18 @@ if {[info commands testchannel] != ""} { test io-14.1 {Tcl_SetStdChannel and Tcl_GetStdChannel} {testchannel} { set l "" - lappend l [fconfigure stdin -buffering] - lappend l [fconfigure stdout -buffering] - lappend l [fconfigure stderr -buffering] + lappend l [chan configure stdin -buffering] + lappend l [chan configure stdout -buffering] + lappend l [chan configure stderr -buffering] lappend l [lsort [testchannel open]] set l } [list line line none $consoleFileNames] test io-14.2 {Tcl_SetStdChannel and Tcl_GetStdChannel} { interp create x set l "" - lappend l [x eval {fconfigure stdin -buffering}] - lappend l [x eval {fconfigure stdout -buffering}] - lappend l [x eval {fconfigure stderr -buffering}] + lappend l [x eval {chan configure stdin -buffering}] + lappend l [x eval {chan configure stdout -buffering}] + lappend l [x eval {chan configure stderr -buffering}] interp delete x set l } {line line none} @@ -1755,7 +1755,7 @@ test io-14.8 {reuse of stdio special channels} {stdio openpipe} { close $f set c } hello -test io-14.9 {reuse of stdio special channels} {stdio openpipe fileevent} { +test io-14.9 {reuse of stdio special channels} {stdio openpipe chan event} { file delete $path(script) file delete $path(test1) set f [open $path(script) w] @@ -1919,7 +1919,7 @@ test io-20.1 {Tcl_CreateChannel: initial settings} { set old [encoding system] encoding system ascii set f [open $path(test1) w] - set x [fconfigure $f -encoding] + set x [chan configure $f -encoding] close $f encoding system $old close $a @@ -1927,13 +1927,13 @@ test io-20.1 {Tcl_CreateChannel: initial settings} { } {ascii} test io-20.2 {Tcl_CreateChannel: initial settings} {win} { set f [open $path(test1) w+] - set x [list [fconfigure $f -eofchar] [fconfigure $f -translation]] + set x [list [chan configure $f -eofchar] [chan configure $f -translation]] close $f set x } [list [list \x1a ""] {auto crlf}] test io-20.3 {Tcl_CreateChannel: initial settings} {unix} { set f [open $path(test1) w+] - set x [list [fconfigure $f -eofchar] [fconfigure $f -translation]] + set x [list [chan configure $f -eofchar] [chan configure $f -translation]] close $f set x } {{{} {}} {auto lf}} @@ -1945,8 +1945,8 @@ test io-20.5 {Tcl_CreateChannel: install channel in empty slot} {stdio openpipe} set f1 [} puts $f [list open $path(stdout) w]] puts $f { - fconfigure $f1 -buffersize 777 - puts stderr [fconfigure stdout -buffersize] + chan configure $f1 -buffersize 777 + puts stderr [chan configure stdout -buffersize] } close $f set f [open "|[list [interpreter] $path(script)]"] @@ -1985,7 +1985,7 @@ test io-24.1 {Tcl_GetChannelType} {testchannel} { test io-25.1 {Tcl_GetChannelHandle, input} {testchannel} { set f [open $path(test1) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} puts $f "1234567890\n098765432" close $f set f [open $path(test1) r] @@ -1999,7 +1999,7 @@ test io-25.1 {Tcl_GetChannelHandle, input} {testchannel} { test io-25.2 {Tcl_GetChannelHandle, output} {testchannel} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts $f hello set l "" lappend l [testchannel outputbuffered $f] @@ -2034,7 +2034,7 @@ test io-27.1 {FlushChannel, no output buffered} { test io-27.2 {FlushChannel, some output buffered} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} set l "" puts $f hello lappend l [file size $path(test1)] @@ -2047,7 +2047,7 @@ test io-27.2 {FlushChannel, some output buffered} { test io-27.3 {FlushChannel, implicit flush on close} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} set l "" puts $f hello lappend l [file size $path(test1)] @@ -2058,8 +2058,8 @@ test io-27.3 {FlushChannel, implicit flush on close} { test io-27.4 {FlushChannel, implicit flush when buffer fills} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -eofchar {} - fconfigure $f -buffersize 60 + chan configure $f -translation lf -eofchar {} + chan configure $f -buffersize 60 set l "" lappend l [file size $path(test1)] for {set i 0} {$i < 12} {incr i} { @@ -2075,7 +2075,7 @@ test io-27.5 {FlushChannel, implicit flush when buffer fills and on close} \ {unixOrPc} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -buffersize 60 -eofchar {} + chan configure $f -translation lf -buffersize 60 -eofchar {} set l "" lappend l [file size $path(test1)] for {set i 0} {$i < 12} {incr i} { @@ -2097,7 +2097,7 @@ test io-27.6 {FlushChannel, async flushing, async close} \ set f [open $path(pipe) w] puts $f "set f \[[list open $path(output) w]]" puts $f { - fconfigure $f -translation lf -buffering none -eofchar {} + chan configure $f -translation lf -buffering none -eofchar {} while {![eof stdin]} { after 20 puts -nonewline $f [read stdin 1024] @@ -2112,7 +2112,7 @@ test io-27.6 {FlushChannel, async flushing, async close} \ set f [open $path(output) w] close $f set f [open "|[list [interpreter] $path(pipe)]" w] - fconfigure $f -blocking off + chan configure $f -blocking off puts -nonewline $f $x close $f set counter 0 @@ -2168,11 +2168,11 @@ test io-28.3 {CloseChannel, not called before output queue is empty} \ # side of the pipe already closed, so that writing would cause an # error "invalid file". - fconfigure stdout -eofchar {} - fconfigure stderr -eofchar {} + chan configure stdout -eofchar {} + chan configure stderr -eofchar {} set f [open $path(output) w] - fconfigure $f -translation lf -buffering none + chan configure $f -translation lf -buffering none for {set x 0} {$x < 20} {incr x} { after 20 puts -nonewline $f [read stdin 1024] @@ -2187,7 +2187,7 @@ test io-28.3 {CloseChannel, not called before output queue is empty} \ set f [open $path(output) w] close $f set f [open "|[list [interpreter] pipe]" r+] - fconfigure $f -blocking off -eofchar {} + chan configure $f -blocking off -eofchar {} puts -nonewline $f $x close $f @@ -2235,7 +2235,7 @@ test io-29.1 {Tcl_WriteChars, channel not writable} { test io-29.2 {Tcl_WriteChars, empty string} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -eofchar {} + chan configure $f -eofchar {} puts -nonewline $f "" close $f file size $path(test1) @@ -2243,7 +2243,7 @@ test io-29.2 {Tcl_WriteChars, empty string} { test io-29.3 {Tcl_WriteChars, nonempty string} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -eofchar {} + chan configure $f -eofchar {} puts -nonewline $f hello close $f file size $path(test1) @@ -2251,7 +2251,7 @@ test io-29.3 {Tcl_WriteChars, nonempty string} { test io-29.4 {Tcl_WriteChars, buffering in full buffering mode} {testchannel} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -buffering full -eofchar {} + chan configure $f -translation lf -buffering full -eofchar {} puts $f hello set l "" lappend l [testchannel outputbuffered $f] @@ -2265,7 +2265,7 @@ test io-29.4 {Tcl_WriteChars, buffering in full buffering mode} {testchannel} { test io-29.5 {Tcl_WriteChars, buffering in line buffering mode} {testchannel} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -buffering line -eofchar {} + chan configure $f -translation lf -buffering line -eofchar {} puts -nonewline $f hello set l "" lappend l [testchannel outputbuffered $f] @@ -2279,7 +2279,7 @@ test io-29.5 {Tcl_WriteChars, buffering in line buffering mode} {testchannel} { test io-29.6 {Tcl_WriteChars, buffering in no buffering mode} {testchannel} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -buffering none -eofchar {} + chan configure $f -translation lf -buffering none -eofchar {} puts -nonewline $f hello set l "" lappend l [testchannel outputbuffered $f] @@ -2293,7 +2293,7 @@ test io-29.6 {Tcl_WriteChars, buffering in no buffering mode} {testchannel} { test io-29.7 {Tcl_Flush, full buffering} {testchannel} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -buffering full -eofchar {} + chan configure $f -translation lf -buffering full -eofchar {} puts -nonewline $f hello set l "" lappend l [testchannel outputbuffered $f] @@ -2310,7 +2310,7 @@ test io-29.7 {Tcl_Flush, full buffering} {testchannel} { test io-29.8 {Tcl_Flush, full buffering} {testchannel} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -buffering line + chan configure $f -translation lf -buffering line puts -nonewline $f hello set l "" lappend l [testchannel outputbuffered $f] @@ -2333,7 +2333,7 @@ test io-29.9 {Tcl_Flush, channel not writable} { test io-29.10 {Tcl_WriteChars, looping and buffering} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -translation lf -eofchar {} + chan configure $f1 -translation lf -eofchar {} set f2 [open $path(longfile) r] for {set x 0} {$x < 10} {incr x} { puts $f1 [gets $f2] @@ -2345,7 +2345,7 @@ test io-29.10 {Tcl_WriteChars, looping and buffering} { test io-29.11 {Tcl_WriteChars, no newline, implicit flush} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -eofchar {} + chan configure $f1 -eofchar {} set f2 [open $path(longfile) r] for {set x 0} {$x < 10} {incr x} { puts -nonewline $f1 [gets $f2] @@ -2371,7 +2371,7 @@ test io-29.12 {Tcl_WriteChars on a pipe} {stdio openpipe} { for {set x 0} {$x < 10} {incr x} { set l1 [gets $f1] set l2 [gets $f2] - if {"$l1" != "$l2"} { + if {$l1 ne $l2} { set y broken } } @@ -2390,18 +2390,18 @@ test io-29.13 {Tcl_WriteChars to a pipe, line buffered} {stdio openpipe} { close $f1 set y ok set f1 [open "|[list [interpreter] $path(pipe)]" r+] - fconfigure $f1 -buffering line + chan configure $f1 -buffering line set f2 [open $path(longfile) r] set line [gets $f2] puts $f1 $line set backline [gets $f1] - if {"$line" != "$backline"} { + if {$line ne $backline} { set y broken } set line [gets $f2] puts $f1 $line set backline [gets $f1] - if {"$line" != "$backline"} { + if {$line ne $backline} { set y broken } close $f1 @@ -2440,7 +2440,7 @@ test io-29.16 {Tcl_Flush on pipe opened only for reading} {stdio openpipe} { test io-29.17 {Tcl_WriteChars buffers, then Tcl_Flush flushes} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -translation lf + chan configure $f1 -translation lf puts $f1 hello puts $f1 hello puts $f1 hello @@ -2453,7 +2453,7 @@ test io-29.18 {Tcl_WriteChars and Tcl_Flush intermixed} { file delete $path(test1) set x "" set f1 [open $path(test1) w] - fconfigure $f1 -translation lf + chan configure $f1 -translation lf puts $f1 hello puts $f1 hello puts $f1 hello @@ -2471,7 +2471,7 @@ test io-29.18 {Tcl_WriteChars and Tcl_Flush intermixed} { test io-29.19 {Explicit and implicit flushes} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -translation lf -eofchar {} + chan configure $f1 -translation lf -eofchar {} set x "" puts $f1 hello puts $f1 hello @@ -2489,7 +2489,7 @@ test io-29.19 {Explicit and implicit flushes} { test io-29.20 {Implicit flush when buffer is full} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -translation lf -eofchar {} + chan configure $f1 -translation lf -eofchar {} set line "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" for {set x 0} {$x < 100} {incr x} { puts $f1 $line @@ -2522,7 +2522,7 @@ test io-29.22 {Tcl_Flush called at other end of pipe} {stdio openpipe} { file delete $path(pipe) set f1 [open $path(pipe) w] puts $f1 { - fconfigure stdout -buffering full + chan configure stdout -buffering full puts hello puts hello flush stdout @@ -2576,7 +2576,7 @@ test io-29.24 {Tcl_WriteChars and Tcl_Flush move end of file} { close $f set x } "{} {Line 1\nLine 2}" -test io-29.25 {Implicit flush with Tcl_Flush to command pipelines} {stdio openpipe fileevent} { +test io-29.25 {Implicit flush with Tcl_Flush to command pipelines} {stdio openpipe chan event} { file delete $path(test3) set f [open "|[list [interpreter] $path(cat) | [interpreter] $path(cat) > $path(test3)]" w] puts $f "Line 1" @@ -2627,7 +2627,7 @@ test io-29.27 {Tcl_Flush on closed pipeline} {stdio openpipe} { test io-29.28 {Tcl_WriteChars, lf mode} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} puts $f hello\nthere\nand\nhere flush $f set s [file size $path(test1)] @@ -2637,7 +2637,7 @@ test io-29.28 {Tcl_WriteChars, lf mode} { test io-29.29 {Tcl_WriteChars, cr mode} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr -eofchar {} + chan configure $f -translation cr -eofchar {} puts $f hello\nthere\nand\nhere close $f file size $path(test1) @@ -2645,7 +2645,7 @@ test io-29.29 {Tcl_WriteChars, cr mode} { test io-29.30 {Tcl_WriteChars, crlf mode} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf -eofchar {} + chan configure $f -translation crlf -eofchar {} puts $f hello\nthere\nand\nhere close $f file size $path(test1) @@ -2657,7 +2657,7 @@ test io-29.31 {Tcl_WriteChars, background flush} {stdio openpipe} { file delete $path(output) set f [open $path(pipe) w] puts $f "set f \[[list open $path(output) w]]" - puts $f {fconfigure $f -translation lf} + puts $f {chan configure $f -translation lf} set x [list while {![eof stdin]}] set x "$x {" puts $f $x @@ -2673,7 +2673,7 @@ test io-29.31 {Tcl_WriteChars, background flush} {stdio openpipe} { set f [open $path(output) w] close $f set f [open "|[list [interpreter] $path(pipe)]" r+] - fconfigure $f -blocking off + chan configure $f -blocking off puts -nonewline $f $x close $f set counter 0 @@ -2700,7 +2700,7 @@ test io-29.32 {Tcl_WriteChars, background flush to slow reader} \ file delete $path(output) set f [open $path(pipe) w] puts $f "set f \[[list open $path(output) w]]" - puts $f {fconfigure $f -translation lf} + puts $f {chan configure $f -translation lf} set x [list while {![eof stdin]}] set x "$x \{" puts $f $x @@ -2717,7 +2717,7 @@ test io-29.32 {Tcl_WriteChars, background flush to slow reader} \ set f [open $path(output) w] close $f set f [open "|[list [interpreter] $path(pipe)]" r+] - fconfigure $f -blocking off + chan configure $f -blocking off puts -nonewline $f $x close $f set counter 0 @@ -2734,7 +2734,7 @@ test io-29.32 {Tcl_WriteChars, background flush to slow reader} \ test io-29.33 {Tcl_Flush, implicit flush on exit} {exec} { set f [open $path(script) w] puts $f "set f \[[list open $path(test1) w]]" - puts $f {fconfigure $f -translation lf + puts $f {chan configure $f -translation lf puts $f hello puts $f bye puts $f strange @@ -2750,7 +2750,7 @@ set path(script2) [makeFile {} script2] test io-29.33b {TIP#398, no implicit flush of nonblocking on exit} {exec} { set f [open $path(script) w] puts $f { - fconfigure stdout -blocking 0 + chan configure stdout -blocking 0 puts -nonewline stdout [string repeat A 655360] flush stdout } @@ -2760,13 +2760,13 @@ test io-29.33b {TIP#398, no implicit flush of nonblocking on exit} {exec} { close $f set t1 [clock milliseconds] set ff [open "|[list [interpreter] $path(script2)]" w] - catch {unset ::env(TCL_FLUSH_NONBLOCKING_ON_EXIT)} + unset -nocomplain ::env(TCL_FLUSH_NONBLOCKING_ON_EXIT) exec [interpreter] $path(script) >@ $ff set t2 [clock milliseconds] close $ff - expr {($t2-$t1)/2000 ? $t2-$t1 : 0} + expr {(($t2 - $t1) / 2000) ? ($t2 - $t1) : 0} } 0 -test io-29.34 {Tcl_Close, async flush on close, using sockets} {socket tempNotMac fileevent} { +test io-29.34 {Tcl_Close, async flush on close, using sockets} {socket tempNotMac chan event} { variable c 0 variable x running set l abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz @@ -2777,8 +2777,8 @@ test io-29.34 {Tcl_Close, async flush on close, using sockets} {socket tempNotMa } proc accept {s a p} { variable x - fileevent $s readable [namespace code [list readit $s]] - fconfigure $s -blocking off + chan event $s readable [namespace code [list readit $s]] + chan configure $s -blocking off set x accepted } proc readit {s} { @@ -2789,21 +2789,21 @@ test io-29.34 {Tcl_Close, async flush on close, using sockets} {socket tempNotMa if {[eof $s]} { close $s set x done - } elseif {([string length $l] > 0) || ![fblocked $s]} { + } elseif {([string length $l] > 0) || (![chan blocked $s])} { incr c } } set ss [socket -server [namespace code accept] -myaddr 127.0.0.1 0] - set cs [socket 127.0.0.1 [lindex [fconfigure $ss -sockname] 2]] + set cs [socket 127.0.0.1 [lindex [chan configure $ss -sockname] 2]] vwait [namespace which -variable x] - fconfigure $cs -blocking off + chan configure $cs -blocking off writelots $cs $l close $cs close $ss vwait [namespace which -variable x] set c } 2000 -test io-29.35 {Tcl_Close vs fileevent vs multiple interpreters} {socket tempNotMac fileevent} { +test io-29.35 {Tcl_Close vs chan event vs multiple interpreters} {socket tempNotMac fileevent} { # On Mac, this test screws up sockets such that subsequent tests using port 2828 # either cause errors or panic(). @@ -2816,7 +2816,7 @@ test io-29.35 {Tcl_Close vs fileevent vs multiple interpreters} {socket tempNotM puts $s hello close $s } - set c [socket 127.0.0.1 [lindex [fconfigure $s -sockname] 2]] + set c [socket 127.0.0.1 [lindex [chan configure $s -sockname] 2]] interp share {} $c x interp share {} $c y close $c @@ -2836,8 +2836,8 @@ test io-29.35 {Tcl_Close vs fileevent vs multiple interpreters} {socket tempNotM } } } - x eval "fileevent $c readable \{readit $c\}" - y eval "fileevent $c readable \{readit $c\}" + x eval "chan event $c readable \{readit $c\}" + y eval "chan event $c readable \{readit $c\}" y eval [list close $c] update close $s @@ -2850,11 +2850,11 @@ test io-29.35 {Tcl_Close vs fileevent vs multiple interpreters} {socket tempNotM test io-30.1 {Tcl_Write lf, Tcl_Read lf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation lf + chan configure $f -translation lf set x [read $f] close $f set x @@ -2862,11 +2862,11 @@ test io-30.1 {Tcl_Write lf, Tcl_Read lf} { test io-30.2 {Tcl_Write lf, Tcl_Read cr} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation cr + chan configure $f -translation cr set x [read $f] close $f set x @@ -2874,11 +2874,11 @@ test io-30.2 {Tcl_Write lf, Tcl_Read cr} { test io-30.3 {Tcl_Write lf, Tcl_Read crlf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation crlf + chan configure $f -translation crlf set x [read $f] close $f set x @@ -2886,11 +2886,11 @@ test io-30.3 {Tcl_Write lf, Tcl_Read crlf} { test io-30.4 {Tcl_Write cr, Tcl_Read cr} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr + chan configure $f -translation cr puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation cr + chan configure $f -translation cr set x [read $f] close $f set x @@ -2898,11 +2898,11 @@ test io-30.4 {Tcl_Write cr, Tcl_Read cr} { test io-30.5 {Tcl_Write cr, Tcl_Read lf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr + chan configure $f -translation cr puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation lf + chan configure $f -translation lf set x [read $f] close $f set x @@ -2910,11 +2910,11 @@ test io-30.5 {Tcl_Write cr, Tcl_Read lf} { test io-30.6 {Tcl_Write cr, Tcl_Read crlf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr + chan configure $f -translation cr puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation crlf + chan configure $f -translation crlf set x [read $f] close $f set x @@ -2922,11 +2922,11 @@ test io-30.6 {Tcl_Write cr, Tcl_Read crlf} { test io-30.7 {Tcl_Write crlf, Tcl_Read crlf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation crlf + chan configure $f -translation crlf set x [read $f] close $f set x @@ -2934,11 +2934,11 @@ test io-30.7 {Tcl_Write crlf, Tcl_Read crlf} { test io-30.8 {Tcl_Write crlf, Tcl_Read lf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation lf + chan configure $f -translation lf set x [read $f] close $f set x @@ -2946,11 +2946,11 @@ test io-30.8 {Tcl_Write crlf, Tcl_Read lf} { test io-30.9 {Tcl_Write crlf, Tcl_Read cr} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation cr + chan configure $f -translation cr set x [read $f] close $f set x @@ -2958,12 +2958,12 @@ test io-30.9 {Tcl_Write crlf, Tcl_Read cr} { test io-30.10 {Tcl_Write lf, Tcl_Read auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] set c [read $f] - set x [fconfigure $f -translation] + set x [chan configure $f -translation] close $f list $c $x } {{hello @@ -2974,12 +2974,12 @@ here test io-30.11 {Tcl_Write cr, Tcl_Read auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr + chan configure $f -translation cr puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] set c [read $f] - set x [fconfigure $f -translation] + set x [chan configure $f -translation] close $f list $c $x } {{hello @@ -2990,12 +2990,12 @@ here test io-30.12 {Tcl_Write crlf, Tcl_Read auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] set c [read $f] - set x [fconfigure $f -translation] + set x [chan configure $f -translation] close $f list $c $x } {{hello @@ -3006,7 +3006,7 @@ here test io-30.13 {Tcl_Write crlf on block boundary, Tcl_Read auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf set line "123456789ABCDE" ;# 14 char plus crlf puts -nonewline $f x ;# shift crlf across block boundary for {set i 0} {$i < 700} {incr i} { @@ -3014,15 +3014,15 @@ test io-30.13 {Tcl_Write crlf on block boundary, Tcl_Read auto} { } close $f set f [open $path(test1) r] - fconfigure $f -translation auto + chan configure $f -translation auto set c [read $f] close $f string length $c -} [expr 700*15+1] +} [expr {(700 * 15) + 1}] test io-30.14 {Tcl_Write crlf on block boundary, Tcl_Read crlf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf set line "123456789ABCDE" ;# 14 char plus crlf puts -nonewline $f x ;# shift crlf across block boundary for {set i 0} {$i < 700} {incr i} { @@ -3030,19 +3030,19 @@ test io-30.14 {Tcl_Write crlf on block boundary, Tcl_Read crlf} { } close $f set f [open $path(test1) r] - fconfigure $f -translation crlf + chan configure $f -translation crlf set c [read $f] close $f string length $c -} [expr 700*15+1] +} [expr {(700 * 15) + 1}] test io-30.15 {Tcl_Write mixed, Tcl_Read auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts $f hello\nthere\nand\rhere close $f set f [open $path(test1) r] - fconfigure $f -translation auto + chan configure $f -translation auto set c [read $f] close $f set c @@ -3054,11 +3054,11 @@ here test io-30.16 {Tcl_Write ^Z at end, Tcl_Read auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f hello\nthere\nand\rhere\n\x1a close $f set f [open $path(test1) r] - fconfigure $f -eofchar \x1a -translation auto + chan configure $f -eofchar \x1a -translation auto set c [read $f] close $f set c @@ -3070,11 +3070,11 @@ here test io-30.17 {Tcl_Write, implicit ^Z at end, Tcl_Read auto} {win} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -eofchar \x1a -translation lf + chan configure $f -eofchar \x1a -translation lf puts $f hello\nthere\nand\rhere close $f set f [open $path(test1) r] - fconfigure $f -eofchar \x1a -translation auto + chan configure $f -eofchar \x1a -translation auto set c [read $f] close $f set c @@ -3086,12 +3086,12 @@ here test io-30.18 {Tcl_Write, ^Z in middle, Tcl_Read auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf set s [format "abc\ndef\n%cghi\nqrs" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -eofchar \x1a -translation auto + chan configure $f -eofchar \x1a -translation auto set l "" lappend l [gets $f] lappend l [gets $f] @@ -3106,12 +3106,12 @@ test io-30.18 {Tcl_Write, ^Z in middle, Tcl_Read auto} { test io-30.19 {Tcl_Write, ^Z no newline in middle, Tcl_Read auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf set s [format "abc\ndef\n%cghi\nqrs" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -eofchar \x1a -translation auto + chan configure $f -eofchar \x1a -translation auto set l "" lappend l [gets $f] lappend l [gets $f] @@ -3126,12 +3126,12 @@ test io-30.19 {Tcl_Write, ^Z no newline in middle, Tcl_Read auto} { test io-30.20 {Tcl_Write, ^Z in middle ignored, Tcl_Read lf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} set s [format "abc\ndef\n%cghi\nqrs" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} set l "" lappend l [gets $f] lappend l [gets $f] @@ -3148,12 +3148,12 @@ test io-30.20 {Tcl_Write, ^Z in middle ignored, Tcl_Read lf} { test io-30.21 {Tcl_Write, ^Z in middle ignored, Tcl_Read cr} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} set s [format "abc\ndef\n%cghi\nqrs" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -translation cr -eofchar {} + chan configure $f -translation cr -eofchar {} set l "" set x [gets $f] lappend l [string compare $x "abc\ndef\n\x1aghi\nqrs\n"] @@ -3166,12 +3166,12 @@ test io-30.21 {Tcl_Write, ^Z in middle ignored, Tcl_Read cr} { test io-30.22 {Tcl_Write, ^Z in middle ignored, Tcl_Read crlf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} set s [format "abc\ndef\n%cghi\nqrs" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -translation crlf -eofchar {} + chan configure $f -translation crlf -eofchar {} set l "" set x [gets $f] lappend l [string compare $x "abc\ndef\n\x1aghi\nqrs\n"] @@ -3184,12 +3184,12 @@ test io-30.22 {Tcl_Write, ^Z in middle ignored, Tcl_Read crlf} { test io-30.23 {Tcl_Write lf, ^Z in middle, Tcl_Read auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf set c [format abc\ndef\n%cqrs\ntuv 26] puts $f $c close $f set f [open $path(test1) r] - fconfigure $f -translation auto -eofchar \x1a + chan configure $f -translation auto -eofchar \x1a set c [string length [read $f]] set e [eof $f] close $f @@ -3198,12 +3198,12 @@ test io-30.23 {Tcl_Write lf, ^Z in middle, Tcl_Read auto} { test io-30.24 {Tcl_Write lf, ^Z in middle, Tcl_Read lf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf set c [format abc\ndef\n%cqrs\ntuv 26] puts $f $c close $f set f [open $path(test1) r] - fconfigure $f -translation lf -eofchar \x1a + chan configure $f -translation lf -eofchar \x1a set c [string length [read $f]] set e [eof $f] close $f @@ -3212,12 +3212,12 @@ test io-30.24 {Tcl_Write lf, ^Z in middle, Tcl_Read lf} { test io-30.25 {Tcl_Write cr, ^Z in middle, Tcl_Read auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr + chan configure $f -translation cr set c [format abc\ndef\n%cqrs\ntuv 26] puts $f $c close $f set f [open $path(test1) r] - fconfigure $f -translation auto -eofchar \x1a + chan configure $f -translation auto -eofchar \x1a set c [string length [read $f]] set e [eof $f] close $f @@ -3226,12 +3226,12 @@ test io-30.25 {Tcl_Write cr, ^Z in middle, Tcl_Read auto} { test io-30.26 {Tcl_Write cr, ^Z in middle, Tcl_Read cr} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr + chan configure $f -translation cr set c [format abc\ndef\n%cqrs\ntuv 26] puts $f $c close $f set f [open $path(test1) r] - fconfigure $f -translation cr -eofchar \x1a + chan configure $f -translation cr -eofchar \x1a set c [string length [read $f]] set e [eof $f] close $f @@ -3240,12 +3240,12 @@ test io-30.26 {Tcl_Write cr, ^Z in middle, Tcl_Read cr} { test io-30.27 {Tcl_Write crlf, ^Z in middle, Tcl_Read auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf set c [format abc\ndef\n%cqrs\ntuv 26] puts $f $c close $f set f [open $path(test1) r] - fconfigure $f -translation auto -eofchar \x1a + chan configure $f -translation auto -eofchar \x1a set c [string length [read $f]] set e [eof $f] close $f @@ -3254,12 +3254,12 @@ test io-30.27 {Tcl_Write crlf, ^Z in middle, Tcl_Read auto} { test io-30.28 {Tcl_Write crlf, ^Z in middle, Tcl_Read crlf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf set c [format abc\ndef\n%cqrs\ntuv 26] puts $f $c close $f set f [open $path(test1) r] - fconfigure $f -translation crlf -eofchar \x1a + chan configure $f -translation crlf -eofchar \x1a set c [string length [read $f]] set e [eof $f] close $f @@ -3271,88 +3271,88 @@ test io-30.28 {Tcl_Write crlf, ^Z in middle, Tcl_Read crlf} { test io-31.1 {Tcl_Write lf, Tcl_Gets auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] set l "" lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] close $f set l } {hello 6 auto there 12 auto} test io-31.2 {Tcl_Write cr, Tcl_Gets auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr + chan configure $f -translation cr puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] set l "" lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] close $f set l } {hello 6 auto there 12 auto} test io-31.3 {Tcl_Write crlf, Tcl_Gets auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] set l "" lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] close $f set l } {hello 7 auto there 14 auto} test io-31.4 {Tcl_Write lf, Tcl_Gets lf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation lf + chan configure $f -translation lf set l "" lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] close $f set l } {hello 6 lf there 12 lf} test io-31.5 {Tcl_Write lf, Tcl_Gets cr} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation cr + chan configure $f -translation cr set l "" lappend l [string length [gets $f]] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] close $f set l @@ -3360,19 +3360,19 @@ test io-31.5 {Tcl_Write lf, Tcl_Gets cr} { test io-31.6 {Tcl_Write lf, Tcl_Gets crlf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation crlf + chan configure $f -translation crlf set l "" lappend l [string length [gets $f]] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] close $f set l @@ -3380,19 +3380,19 @@ test io-31.6 {Tcl_Write lf, Tcl_Gets crlf} { test io-31.7 {Tcl_Write cr, Tcl_Gets cr} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr + chan configure $f -translation cr puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation cr + chan configure $f -translation cr set l "" lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] close $f set l @@ -3400,19 +3400,19 @@ test io-31.7 {Tcl_Write cr, Tcl_Gets cr} { test io-31.8 {Tcl_Write cr, Tcl_Gets lf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr + chan configure $f -translation cr puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation lf + chan configure $f -translation lf set l "" lappend l [string length [gets $f]] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] close $f set l @@ -3420,19 +3420,19 @@ test io-31.8 {Tcl_Write cr, Tcl_Gets lf} { test io-31.9 {Tcl_Write cr, Tcl_Gets crlf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr + chan configure $f -translation cr puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation crlf + chan configure $f -translation crlf set l "" lappend l [string length [gets $f]] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] close $f set l @@ -3440,19 +3440,19 @@ test io-31.9 {Tcl_Write cr, Tcl_Gets crlf} { test io-31.10 {Tcl_Write crlf, Tcl_Gets crlf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation crlf + chan configure $f -translation crlf set l "" lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] close $f set l @@ -3460,19 +3460,19 @@ test io-31.10 {Tcl_Write crlf, Tcl_Gets crlf} { test io-31.11 {Tcl_Write crlf, Tcl_Gets cr} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation cr + chan configure $f -translation cr set l "" lappend l [gets $f] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] lappend l [string length [gets $f]] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] close $f set l @@ -3480,19 +3480,19 @@ test io-31.11 {Tcl_Write crlf, Tcl_Gets cr} { test io-31.12 {Tcl_Write crlf, Tcl_Gets lf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf puts $f hello\nthere\nand\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation lf + chan configure $f -translation lf set l "" lappend l [string length [gets $f]] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] lappend l [string length [gets $f]] lappend l [tell $f] - lappend l [fconfigure $f -translation] + lappend l [chan configure $f -translation] lappend l [eof $f] close $f set l @@ -3500,8 +3500,8 @@ test io-31.12 {Tcl_Write crlf, Tcl_Gets lf} { test io-31.13 {binary mode is synonym of lf mode} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation binary - set x [fconfigure $f -translation] + chan configure $f -translation binary + set x [chan configure $f -translation] close $f set x } lf @@ -3512,11 +3512,11 @@ test io-31.13 {binary mode is synonym of lf mode} { test io-31.14 {Tcl_Write mixed, Tcl_Gets auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts $f hello\nthere\rand\r\nhere close $f set f [open $path(test1) r] - fconfigure $f -translation auto + chan configure $f -translation auto set l "" lappend l [gets $f] lappend l [gets $f] @@ -3531,11 +3531,11 @@ test io-31.14 {Tcl_Write mixed, Tcl_Gets auto} { test io-31.15 {Tcl_Write mixed, Tcl_Gets auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f hello\nthere\rand\r\nhere\r close $f set f [open $path(test1) r] - fconfigure $f -translation auto + chan configure $f -translation auto set l "" lappend l [gets $f] lappend l [gets $f] @@ -3550,7 +3550,7 @@ test io-31.15 {Tcl_Write mixed, Tcl_Gets auto} { test io-31.16 {Tcl_Write mixed, Tcl_Gets auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f hello\nthere\rand\r\nhere\n close $f set f [open $path(test1) r] @@ -3568,11 +3568,11 @@ test io-31.16 {Tcl_Write mixed, Tcl_Gets auto} { test io-31.17 {Tcl_Write mixed, Tcl_Gets auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f hello\nthere\rand\r\nhere\r\n close $f set f [open $path(test1) r] - fconfigure $f -translation auto + chan configure $f -translation auto set l "" lappend l [gets $f] lappend l [gets $f] @@ -3587,12 +3587,12 @@ test io-31.17 {Tcl_Write mixed, Tcl_Gets auto} { test io-31.18 {Tcl_Write ^Z at end, Tcl_Gets auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf set s [format "hello\nthere\nand\rhere\n\%c" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -eofchar \x1a -translation auto + chan configure $f -eofchar \x1a -translation auto set l "" lappend l [gets $f] lappend l [gets $f] @@ -3607,11 +3607,11 @@ test io-31.18 {Tcl_Write ^Z at end, Tcl_Gets auto} { test io-31.19 {Tcl_Write, implicit ^Z at end, Tcl_Gets auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -eofchar \x1a -translation lf + chan configure $f -eofchar \x1a -translation lf puts $f hello\nthere\nand\rhere close $f set f [open $path(test1) r] - fconfigure $f -eofchar \x1a -translation auto + chan configure $f -eofchar \x1a -translation auto set l "" lappend l [gets $f] lappend l [gets $f] @@ -3626,13 +3626,13 @@ test io-31.19 {Tcl_Write, implicit ^Z at end, Tcl_Gets auto} { test io-31.20 {Tcl_Write, ^Z in middle, Tcl_Gets auto, eofChar} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf set s [format "abc\ndef\n%cqrs\ntuv" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -eofchar \x1a - fconfigure $f -translation auto + chan configure $f -eofchar \x1a + chan configure $f -translation auto set l "" lappend l [gets $f] lappend l [gets $f] @@ -3645,12 +3645,12 @@ test io-31.20 {Tcl_Write, ^Z in middle, Tcl_Gets auto, eofChar} { test io-31.21 {Tcl_Write, no newline ^Z in middle, Tcl_Gets auto, eofChar} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf set s [format "abc\ndef\n%cqrs\ntuv" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -eofchar \x1a -translation auto + chan configure $f -eofchar \x1a -translation auto set l "" lappend l [gets $f] lappend l [gets $f] @@ -3663,12 +3663,12 @@ test io-31.21 {Tcl_Write, no newline ^Z in middle, Tcl_Gets auto, eofChar} { test io-31.22 {Tcl_Write, ^Z in middle ignored, Tcl_Gets lf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} set s [format "abc\ndef\n%cqrs\ntuv" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} set l "" lappend l [gets $f] lappend l [gets $f] @@ -3685,12 +3685,12 @@ test io-31.22 {Tcl_Write, ^Z in middle ignored, Tcl_Gets lf} { test io-31.23 {Tcl_Write, ^Z in middle ignored, Tcl_Gets cr} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr -eofchar {} + chan configure $f -translation cr -eofchar {} set s [format "abc\ndef\n%cqrs\ntuv" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -translation cr -eofchar {} + chan configure $f -translation cr -eofchar {} set l "" lappend l [gets $f] lappend l [gets $f] @@ -3707,12 +3707,12 @@ test io-31.23 {Tcl_Write, ^Z in middle ignored, Tcl_Gets cr} { test io-31.24 {Tcl_Write, ^Z in middle ignored, Tcl_Gets crlf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf -eofchar {} + chan configure $f -translation crlf -eofchar {} set s [format "abc\ndef\n%cqrs\ntuv" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -translation crlf -eofchar {} + chan configure $f -translation crlf -eofchar {} set l "" lappend l [gets $f] lappend l [gets $f] @@ -3729,12 +3729,12 @@ test io-31.24 {Tcl_Write, ^Z in middle ignored, Tcl_Gets crlf} { test io-31.25 {Tcl_Write lf, ^Z in middle, Tcl_Gets auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf set s [format "abc\ndef\n%cqrs\ntuv" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -translation auto -eofchar \x1a + chan configure $f -translation auto -eofchar \x1a set l "" lappend l [gets $f] lappend l [gets $f] @@ -3747,12 +3747,12 @@ test io-31.25 {Tcl_Write lf, ^Z in middle, Tcl_Gets auto} { test io-31.26 {Tcl_Write lf, ^Z in middle, Tcl_Gets lf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf set s [format "abc\ndef\n%cqrs\ntuv" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -translation lf -eofchar \x1a + chan configure $f -translation lf -eofchar \x1a set l "" lappend l [gets $f] lappend l [gets $f] @@ -3765,12 +3765,12 @@ test io-31.26 {Tcl_Write lf, ^Z in middle, Tcl_Gets lf} { test io-31.27 {Tcl_Write cr, ^Z in middle, Tcl_Gets auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr -eofchar {} + chan configure $f -translation cr -eofchar {} set s [format "abc\ndef\n%cqrs\ntuv" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -translation auto -eofchar \x1a + chan configure $f -translation auto -eofchar \x1a set l "" lappend l [gets $f] lappend l [gets $f] @@ -3783,12 +3783,12 @@ test io-31.27 {Tcl_Write cr, ^Z in middle, Tcl_Gets auto} { test io-31.28 {Tcl_Write cr, ^Z in middle, Tcl_Gets cr} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr -eofchar {} + chan configure $f -translation cr -eofchar {} set s [format "abc\ndef\n%cqrs\ntuv" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -translation cr -eofchar \x1a + chan configure $f -translation cr -eofchar \x1a set l "" lappend l [gets $f] lappend l [gets $f] @@ -3801,12 +3801,12 @@ test io-31.28 {Tcl_Write cr, ^Z in middle, Tcl_Gets cr} { test io-31.29 {Tcl_Write crlf, ^Z in middle, Tcl_Gets auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf -eofchar {} + chan configure $f -translation crlf -eofchar {} set s [format "abc\ndef\n%cqrs\ntuv" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -translation auto -eofchar \x1a + chan configure $f -translation auto -eofchar \x1a set l "" lappend l [gets $f] lappend l [gets $f] @@ -3819,12 +3819,12 @@ test io-31.29 {Tcl_Write crlf, ^Z in middle, Tcl_Gets auto} { test io-31.30 {Tcl_Write crlf, ^Z in middle, Tcl_Gets crlf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf -eofchar {} + chan configure $f -translation crlf -eofchar {} set s [format "abc\ndef\n%cqrs\ntuv" 26] puts $f $s close $f set f [open $path(test1) r] - fconfigure $f -translation crlf -eofchar \x1a + chan configure $f -translation crlf -eofchar \x1a set l "" lappend l [gets $f] lappend l [gets $f] @@ -3837,7 +3837,7 @@ test io-31.30 {Tcl_Write crlf, ^Z in middle, Tcl_Gets crlf} { test io-31.31 {Tcl_Write crlf on block boundary, Tcl_Gets crlf} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf set line "123456789ABCDE" ;# 14 char plus crlf puts -nonewline $f x ;# shift crlf across block boundary for {set i 0} {$i < 700} {incr i} { @@ -3845,18 +3845,18 @@ test io-31.31 {Tcl_Write crlf on block boundary, Tcl_Gets crlf} { } close $f set f [open $path(test1) r] - fconfigure $f -translation crlf + chan configure $f -translation crlf set c "" while {[gets $f line] >= 0} { append c $line\n } close $f string length $c -} [expr 700*15+1] +} [expr {(700 * 15) + 1}] test io-31.32 {Tcl_Write crlf on block boundary, Tcl_Gets auto} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf set line "123456789ABCDE" ;# 14 char plus crlf puts -nonewline $f x ;# shift crlf across block boundary for {set i 0} {$i < 700} {incr i} { @@ -3864,14 +3864,14 @@ test io-31.32 {Tcl_Write crlf on block boundary, Tcl_Gets auto} { } close $f set f [open $path(test1) r] - fconfigure $f -translation auto + chan configure $f -translation auto set c "" while {[gets $f line] >= 0} { append c $line\n } close $f string length $c -} [expr 700*15+1] +} [expr {(700 * 15) + 1}] # Test Tcl_Read and buffering. @@ -3897,7 +3897,7 @@ test io-32.4 {Tcl_Read, positive byte count} { } 1024 test io-32.5 {Tcl_Read, multiple buffers} { set f [open $path(longfile) r] - fconfigure $f -buffersize 100 + chan configure $f -buffersize 100 set x [read $f 1024] set s [string length $x] unset x @@ -3918,7 +3918,7 @@ test io-32.6 {Tcl_Read, very large read} { } ok test io-32.7 {Tcl_Read, nonblocking, file} {nonBlockFiles} { set f1 [open $path(longfile) r] - fconfigure $f1 -blocking off + chan configure $f1 -blocking off set z [read $f1 20] close $f1 set l [string length $z] @@ -3930,7 +3930,7 @@ test io-32.7 {Tcl_Read, nonblocking, file} {nonBlockFiles} { } ok test io-32.8 {Tcl_Read, nonblocking, file} {nonBlockFiles} { set f1 [open $path(longfile) r] - fconfigure $f1 -blocking off + chan configure $f1 -blocking off set z [read $f1 1000000] close $f1 set x ok @@ -4058,7 +4058,7 @@ test io-33.1 {Tcl_Gets, reading what was written} { set f1 [open $path(test1) r] set x [gets $f1] set z ok - if {"$x" != "$y"} { + if {$x ne $y} { set z broken } close $f1 @@ -4086,7 +4086,7 @@ test io-33.3 {Tcl_Gets from pipe} {stdio openpipe} { set x [gets $f1] close $f1 set z ok - if {"$x" != "hello"} { + if {$x ne "hello"} { set z broken } set z @@ -4132,7 +4132,7 @@ test io-33.7 {Tcl_Gets and bad variable} { puts $f "Line 1" puts $f "Line 2" close $f - catch {unset x} + unset -nocomplain x set x 24 set f [open $path(test3) r] set result [list [catch {gets $f x(0)} msg] $msg] @@ -4141,39 +4141,39 @@ test io-33.7 {Tcl_Gets and bad variable} { } {1 {can't set "x(0)": variable isn't array}} test io-33.8 {Tcl_Gets, exercising double buffering} { set f [open $path(test3) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} set x "" for {set y 0} {$y < 99} {incr y} {set x "a$x"} for {set y 0} {$y < 100} {incr y} {puts $f $x} close $f set f [open $path(test3) r] - fconfigure $f -translation lf + chan configure $f -translation lf for {set y 0} {$y < 100} {incr y} {gets $f} close $f set y } 100 test io-33.9 {Tcl_Gets, exercising double buffering} { set f [open $path(test3) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} set x "" for {set y 0} {$y < 99} {incr y} {set x "a$x"} for {set y 0} {$y < 200} {incr y} {puts $f $x} close $f set f [open $path(test3) r] - fconfigure $f -translation lf + chan configure $f -translation lf for {set y 0} {$y < 200} {incr y} {gets $f} close $f set y } 200 test io-33.10 {Tcl_Gets, exercising double buffering} { set f [open $path(test3) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} set x "" for {set y 0} {$y < 99} {incr y} {set x "a$x"} for {set y 0} {$y < 300} {incr y} {puts $f $x} close $f set f [open $path(test3) r] - fconfigure $f -translation lf + chan configure $f -translation lf for {set y 0} {$y < 300} {incr y} {gets $f} close $f set y @@ -4191,7 +4191,7 @@ test io-34.1 {Tcl_Seek to current position at start of file} { test io-34.2 {Tcl_Seek to offset from start} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -translation lf -eofchar {} + chan configure $f1 -translation lf -eofchar {} puts $f1 "abcdefghijklmnopqrstuvwxyz" puts $f1 "abcdefghijklmnopqrstuvwxyz" close $f1 @@ -4204,7 +4204,7 @@ test io-34.2 {Tcl_Seek to offset from start} { test io-34.3 {Tcl_Seek to end of file} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -translation lf -eofchar {} + chan configure $f1 -translation lf -eofchar {} puts $f1 "abcdefghijklmnopqrstuvwxyz" puts $f1 "abcdefghijklmnopqrstuvwxyz" close $f1 @@ -4217,7 +4217,7 @@ test io-34.3 {Tcl_Seek to end of file} { test io-34.4 {Tcl_Seek to offset from end of file} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -translation lf -eofchar {} + chan configure $f1 -translation lf -eofchar {} puts $f1 "abcdefghijklmnopqrstuvwxyz" puts $f1 "abcdefghijklmnopqrstuvwxyz" close $f1 @@ -4230,7 +4230,7 @@ test io-34.4 {Tcl_Seek to offset from end of file} { test io-34.5 {Tcl_Seek to offset from current position} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -translation lf -eofchar {} + chan configure $f1 -translation lf -eofchar {} puts $f1 "abcdefghijklmnopqrstuvwxyz" puts $f1 "abcdefghijklmnopqrstuvwxyz" close $f1 @@ -4244,7 +4244,7 @@ test io-34.5 {Tcl_Seek to offset from current position} { test io-34.6 {Tcl_Seek to offset from end of file} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -translation lf -eofchar {} + chan configure $f1 -translation lf -eofchar {} puts $f1 "abcdefghijklmnopqrstuvwxyz" puts $f1 "abcdefghijklmnopqrstuvwxyz" close $f1 @@ -4259,7 +4259,7 @@ test io-34.6 {Tcl_Seek to offset from end of file} { test io-34.7 {Tcl_Seek to offset from end of file, then to current position} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -translation lf -eofchar {} + chan configure $f1 -translation lf -eofchar {} puts $f1 "abcdefghijklmnopqrstuvwxyz" puts $f1 "abcdefghijklmnopqrstuvwxyz" close $f1 @@ -4282,7 +4282,7 @@ test io-34.8 {Tcl_Seek on pipes: not supported} {stdio openpipe} { test io-34.9 {Tcl_Seek, testing buffered input flushing} { file delete $path(test3) set f [open $path(test3) w] - fconfigure $f -eofchar {} + chan configure $f -eofchar {} puts -nonewline $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" close $f set f [open $path(test3) RDWR] @@ -4305,11 +4305,11 @@ test io-34.9 {Tcl_Seek, testing buffered input flushing} { set path(test3) [makeFile {} test3] test io-34.10 {Tcl_Seek testing flushing of buffered input} { set f [open $path(test3) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts $f xyz\n123 close $f set f [open $path(test3) r+] - fconfigure $f -translation lf + chan configure $f -translation lf set x [gets $f] seek $f 0 current puts $f 456 @@ -4330,11 +4330,11 @@ test io-34.11 {Tcl_Seek testing flushing of buffered output} { } "zzy xyzzy" test io-34.12 {Tcl_Seek testing combination of write, seek back and read} { set f [open $path(test3) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} puts $f xyz\n123 close $f set f [open $path(test3) a+] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} puts $f xyzzy flush $f set x [tell $f] @@ -4355,7 +4355,7 @@ test io-34.13 {Tcl_Tell at start of file} { test io-34.14 {Tcl_Tell after seek to end of file} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -translation lf -eofchar {} + chan configure $f1 -translation lf -eofchar {} puts $f1 "abcdefghijklmnopqrstuvwxyz" puts $f1 "abcdefghijklmnopqrstuvwxyz" close $f1 @@ -4368,7 +4368,7 @@ test io-34.14 {Tcl_Tell after seek to end of file} { test io-34.15 {Tcl_Tell combined with seeking} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -translation lf -eofchar {} + chan configure $f1 -translation lf -eofchar {} puts $f1 "abcdefghijklmnopqrstuvwxyz" puts $f1 "abcdefghijklmnopqrstuvwxyz" close $f1 @@ -4398,11 +4398,11 @@ test io-34.17 {Tcl_Tell on pipe: always -1} {stdio openpipe} { test io-34.18 {Tcl_Tell combined with seeking and reading} { file delete $path(test2) set f [open $path(test2) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} puts -nonewline $f "line1\nline2\nline3\nline4\nline5\n" close $f set f [open $path(test2)] - fconfigure $f -translation lf + chan configure $f -translation lf set x [tell $f] read $f 3 lappend x [tell $f] @@ -4417,7 +4417,7 @@ test io-34.18 {Tcl_Tell combined with seeking and reading} { } {0 3 2 12 30} test io-34.19 {Tcl_Tell combined with opening in append mode} { set f [open $path(test3) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} puts $f "abcdefghijklmnopqrstuvwxyz" puts $f "abcdefghijklmnopqrstuvwxyz" close $f @@ -4444,7 +4444,7 @@ test io-34.20 {Tcl_Tell combined with writing} { test io-34.21 {Tcl_Seek and Tcl_Tell on large files} {largefileSupport} { file delete $path(test3) set f [open $path(test3) w] - fconfigure $f -encoding binary + chan configure $f -encoding binary set l "" lappend l [tell $f] puts -nonewline $f abcdef @@ -4530,7 +4530,7 @@ test io-35.4 {Tcl_Eof, eof detection on nonblocking file} {nonBlockFiles} { set f [open $path(test1) w] close $f set f [open $path(test1) r] - fconfigure $f -blocking off + chan configure $f -blocking off set l "" lappend l [gets $f] lappend l [eof $f] @@ -4554,12 +4554,12 @@ test io-35.5 {Tcl_Eof, eof detection on nonblocking pipe} {stdio openpipe} { test io-35.6 {Tcl_Eof, eof char, lf write, auto read} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -eofchar \x1a + chan configure $f -translation lf -eofchar \x1a puts $f abc\ndef close $f set s [file size $path(test1)] set f [open $path(test1) r] - fconfigure $f -translation auto -eofchar \x1a + chan configure $f -translation auto -eofchar \x1a set l [string length [read $f]] set e [eof $f] close $f @@ -4568,12 +4568,12 @@ test io-35.6 {Tcl_Eof, eof char, lf write, auto read} { test io-35.7 {Tcl_Eof, eof char, lf write, lf read} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -eofchar \x1a + chan configure $f -translation lf -eofchar \x1a puts $f abc\ndef close $f set s [file size $path(test1)] set f [open $path(test1) r] - fconfigure $f -translation lf -eofchar \x1a + chan configure $f -translation lf -eofchar \x1a set l [string length [read $f]] set e [eof $f] close $f @@ -4582,12 +4582,12 @@ test io-35.7 {Tcl_Eof, eof char, lf write, lf read} { test io-35.8 {Tcl_Eof, eof char, cr write, auto read} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr -eofchar \x1a + chan configure $f -translation cr -eofchar \x1a puts $f abc\ndef close $f set s [file size $path(test1)] set f [open $path(test1) r] - fconfigure $f -translation auto -eofchar \x1a + chan configure $f -translation auto -eofchar \x1a set l [string length [read $f]] set e [eof $f] close $f @@ -4596,12 +4596,12 @@ test io-35.8 {Tcl_Eof, eof char, cr write, auto read} { test io-35.9 {Tcl_Eof, eof char, cr write, cr read} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr -eofchar \x1a + chan configure $f -translation cr -eofchar \x1a puts $f abc\ndef close $f set s [file size $path(test1)] set f [open $path(test1) r] - fconfigure $f -translation cr -eofchar \x1a + chan configure $f -translation cr -eofchar \x1a set l [string length [read $f]] set e [eof $f] close $f @@ -4610,12 +4610,12 @@ test io-35.9 {Tcl_Eof, eof char, cr write, cr read} { test io-35.10 {Tcl_Eof, eof char, crlf write, auto read} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf -eofchar \x1a + chan configure $f -translation crlf -eofchar \x1a puts $f abc\ndef close $f set s [file size $path(test1)] set f [open $path(test1) r] - fconfigure $f -translation auto -eofchar \x1a + chan configure $f -translation auto -eofchar \x1a set l [string length [read $f]] set e [eof $f] close $f @@ -4624,12 +4624,12 @@ test io-35.10 {Tcl_Eof, eof char, crlf write, auto read} { test io-35.11 {Tcl_Eof, eof char, crlf write, crlf read} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf -eofchar \x1a + chan configure $f -translation crlf -eofchar \x1a puts $f abc\ndef close $f set s [file size $path(test1)] set f [open $path(test1) r] - fconfigure $f -translation crlf -eofchar \x1a + chan configure $f -translation crlf -eofchar \x1a set l [string length [read $f]] set e [eof $f] close $f @@ -4638,13 +4638,13 @@ test io-35.11 {Tcl_Eof, eof char, crlf write, crlf read} { test io-35.12 {Tcl_Eof, eof char in middle, lf write, auto read} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} set i [format abc\ndef\n%cqrs\nuvw 26] puts $f $i close $f set c [file size $path(test1)] set f [open $path(test1) r] - fconfigure $f -translation auto -eofchar \x1a + chan configure $f -translation auto -eofchar \x1a set l [string length [read $f]] set e [eof $f] close $f @@ -4653,13 +4653,13 @@ test io-35.12 {Tcl_Eof, eof char in middle, lf write, auto read} { test io-35.13 {Tcl_Eof, eof char in middle, lf write, lf read} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} set i [format abc\ndef\n%cqrs\nuvw 26] puts $f $i close $f set c [file size $path(test1)] set f [open $path(test1) r] - fconfigure $f -translation lf -eofchar \x1a + chan configure $f -translation lf -eofchar \x1a set l [string length [read $f]] set e [eof $f] close $f @@ -4668,13 +4668,13 @@ test io-35.13 {Tcl_Eof, eof char in middle, lf write, lf read} { test io-35.14 {Tcl_Eof, eof char in middle, cr write, auto read} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr -eofchar {} + chan configure $f -translation cr -eofchar {} set i [format abc\ndef\n%cqrs\nuvw 26] puts $f $i close $f set c [file size $path(test1)] set f [open $path(test1) r] - fconfigure $f -translation auto -eofchar \x1a + chan configure $f -translation auto -eofchar \x1a set l [string length [read $f]] set e [eof $f] close $f @@ -4683,13 +4683,13 @@ test io-35.14 {Tcl_Eof, eof char in middle, cr write, auto read} { test io-35.15 {Tcl_Eof, eof char in middle, cr write, cr read} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr -eofchar {} + chan configure $f -translation cr -eofchar {} set i [format abc\ndef\n%cqrs\nuvw 26] puts $f $i close $f set c [file size $path(test1)] set f [open $path(test1) r] - fconfigure $f -translation cr -eofchar \x1a + chan configure $f -translation cr -eofchar \x1a set l [string length [read $f]] set e [eof $f] close $f @@ -4698,13 +4698,13 @@ test io-35.15 {Tcl_Eof, eof char in middle, cr write, cr read} { test io-35.16 {Tcl_Eof, eof char in middle, crlf write, auto read} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf -eofchar {} + chan configure $f -translation crlf -eofchar {} set i [format abc\ndef\n%cqrs\nuvw 26] puts $f $i close $f set c [file size $path(test1)] set f [open $path(test1) r] - fconfigure $f -translation auto -eofchar \x1a + chan configure $f -translation auto -eofchar \x1a set l [string length [read $f]] set e [eof $f] close $f @@ -4713,13 +4713,13 @@ test io-35.16 {Tcl_Eof, eof char in middle, crlf write, auto read} { test io-35.17 {Tcl_Eof, eof char in middle, crlf write, crlf read} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf -eofchar {} + chan configure $f -translation crlf -eofchar {} set i [format abc\ndef\n%cqrs\nuvw 26] puts $f $i close $f set c [file size $path(test1)] set f [open $path(test1) r] - fconfigure $f -translation crlf -eofchar \x1a + chan configure $f -translation crlf -eofchar \x1a set l [string length [read $f]] set e [eof $f] close $f @@ -4733,30 +4733,30 @@ test io-36.1 {Tcl_InputBlocked on nonblocking pipe} {stdio openpipe} { puts $f1 {puts hello_from_pipe} flush $f1 gets $f1 - fconfigure $f1 -blocking off -buffering full + chan configure $f1 -blocking off -buffering full puts $f1 {puts hello} set x "" lappend x [gets $f1] - lappend x [fblocked $f1] + lappend x [chan blocked $f1] flush $f1 after 200 lappend x [gets $f1] - lappend x [fblocked $f1] + lappend x [chan blocked $f1] lappend x [gets $f1] - lappend x [fblocked $f1] + lappend x [chan blocked $f1] close $f1 set x } {{} 1 hello 0 {} 1} test io-36.2 {Tcl_InputBlocked on blocking pipe} {stdio openpipe} { set f1 [open "|[list [interpreter]]" r+] - fconfigure $f1 -buffering line + chan configure $f1 -buffering line puts $f1 {puts hello_from_pipe} set x "" lappend x [gets $f1] - lappend x [fblocked $f1] + lappend x [chan blocked $f1] puts $f1 {exit} lappend x [gets $f1] - lappend x [fblocked $f1] + lappend x [chan blocked $f1] lappend x [eof $f1] close $f1 set x @@ -4768,11 +4768,11 @@ test io-36.3 {Tcl_InputBlocked vs files, short read} { close $f set f [open $path(test1) r] set l "" - lappend l [fblocked $f] + lappend l [chan blocked $f] lappend l [read $f 3] - lappend l [fblocked $f] + lappend l [chan blocked $f] lappend l [read -nonewline $f] - lappend l [fblocked $f] + lappend l [chan blocked $f] lappend l [eof $f] close $f set l @@ -4790,7 +4790,7 @@ test io-36.4 {Tcl_InputBlocked vs files, event driven read} {fileevent} { close $f set f [open $path(test1) r] set l "" - fileevent $f readable [namespace code [list in $f]] + chan event $f readable [namespace code [list in $f]] variable x vwait [namespace which -variable x] set l @@ -4802,13 +4802,13 @@ test io-36.5 {Tcl_InputBlocked vs files, short read, nonblocking} {nonBlockFiles puts $f abcdefghijklmnop close $f set f [open $path(test1) r] - fconfigure $f -blocking off + chan configure $f -blocking off set l "" - lappend l [fblocked $f] + lappend l [chan blocked $f] lappend l [read $f 3] - lappend l [fblocked $f] + lappend l [chan blocked $f] lappend l [read -nonewline $f] - lappend l [fblocked $f] + lappend l [chan blocked $f] lappend l [eof $f] close $f set l @@ -4825,9 +4825,9 @@ test io-36.6 {Tcl_InputBlocked vs files, event driven read} {nonBlockFiles filee puts $f abcdefghijklmnop close $f set f [open $path(test1) r] - fconfigure $f -blocking off + chan configure $f -blocking off set l "" - fileevent $f readable [namespace code [list in $f]] + chan event $f readable [namespace code [list in $f]] variable x vwait [namespace which -variable x] set l @@ -4838,7 +4838,7 @@ test io-36.6 {Tcl_InputBlocked vs files, event driven read} {nonBlockFiles filee test io-37.1 {Tcl_InputBuffered} {testchannel} { set f [open $path(longfile) r] - fconfigure $f -buffersize 4096 + chan configure $f -buffersize 4096 read $f 3 set l "" lappend l [testchannel inputbuffered $f] @@ -4848,7 +4848,7 @@ test io-37.1 {Tcl_InputBuffered} {testchannel} { } {4093 3} test io-37.2 {Tcl_InputBuffered, test input flushing on seek} {testchannel} { set f [open $path(longfile) r] - fconfigure $f -buffersize 4096 + chan configure $f -buffersize 4096 read $f 3 set l "" lappend l [testchannel inputbuffered $f] @@ -4864,26 +4864,26 @@ test io-37.2 {Tcl_InputBuffered, test input flushing on seek} {testchannel} { test io-38.1 {Tcl_GetChannelBufferSize, default buffer size} { set f [open $path(longfile) r] - set s [fconfigure $f -buffersize] + set s [chan configure $f -buffersize] close $f set s } 4096 test io-38.2 {Tcl_SetChannelBufferSize, Tcl_GetChannelBufferSize} { set f [open $path(longfile) r] set l "" - lappend l [fconfigure $f -buffersize] - fconfigure $f -buffersize 10000 - lappend l [fconfigure $f -buffersize] - fconfigure $f -buffersize 1 - lappend l [fconfigure $f -buffersize] - fconfigure $f -buffersize -1 - lappend l [fconfigure $f -buffersize] - fconfigure $f -buffersize 0 - lappend l [fconfigure $f -buffersize] - fconfigure $f -buffersize 100000 - lappend l [fconfigure $f -buffersize] - fconfigure $f -buffersize 10000000 - lappend l [fconfigure $f -buffersize] + lappend l [chan configure $f -buffersize] + chan configure $f -buffersize 10000 + lappend l [chan configure $f -buffersize] + chan configure $f -buffersize 1 + lappend l [chan configure $f -buffersize] + chan configure $f -buffersize -1 + lappend l [chan configure $f -buffersize] + chan configure $f -buffersize 0 + lappend l [chan configure $f -buffersize] + chan configure $f -buffersize 100000 + lappend l [chan configure $f -buffersize] + chan configure $f -buffersize 10000000 + lappend l [chan configure $f -buffersize] close $f set l } {4096 10000 1 1 1 100000 1048576} @@ -4891,9 +4891,9 @@ test io-38.3 {Tcl_SetChannelBufferSize, changing buffersize between reads} { # This test crashes the interp if Bug #427196 is not fixed set chan [open [info script] r] - fconfigure $chan -buffersize 10 + chan configure $chan -buffersize 10 set var [read $chan 2] - fconfigure $chan -buffersize 32 + chan configure $chan -buffersize 32 append var [read $chan] close $chan } {} @@ -4903,7 +4903,7 @@ test io-38.3 {Tcl_SetChannelBufferSize, changing buffersize between reads} { test io-39.1 {Tcl_GetChannelOption} { file delete $path(test1) set f1 [open $path(test1) w] - set x [fconfigure $f1 -blocking] + set x [chan configure $f1 -blocking] close $f1 set x } 1 @@ -4913,15 +4913,15 @@ test io-39.1 {Tcl_GetChannelOption} { test io-39.2 {Tcl_GetChannelOption} { file delete $path(test1) set f1 [open $path(test1) w] - set x [fconfigure $f1 -buffering] + set x [chan configure $f1 -buffering] close $f1 set x } full test io-39.3 {Tcl_GetChannelOption} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -buffering line - set x [fconfigure $f1 -buffering] + chan configure $f1 -buffering line + set x [chan configure $f1 -buffering] close $f1 set x } line @@ -4929,15 +4929,15 @@ test io-39.4 {Tcl_GetChannelOption, Tcl_SetChannelOption} { file delete $path(test1) set f1 [open $path(test1) w] set l "" - lappend l [fconfigure $f1 -buffering] - fconfigure $f1 -buffering line - lappend l [fconfigure $f1 -buffering] - fconfigure $f1 -buffering none - lappend l [fconfigure $f1 -buffering] - fconfigure $f1 -buffering line - lappend l [fconfigure $f1 -buffering] - fconfigure $f1 -buffering full - lappend l [fconfigure $f1 -buffering] + lappend l [chan configure $f1 -buffering] + chan configure $f1 -buffering line + lappend l [chan configure $f1 -buffering] + chan configure $f1 -buffering none + lappend l [chan configure $f1 -buffering] + chan configure $f1 -buffering line + lappend l [chan configure $f1 -buffering] + chan configure $f1 -buffering full + lappend l [chan configure $f1 -buffering] close $f1 set l } {full line none line full} @@ -4945,16 +4945,16 @@ test io-39.5 {Tcl_GetChannelOption, invariance} { file delete $path(test1) set f1 [open $path(test1) w] set l "" - lappend l [fconfigure $f1 -buffering] - lappend l [list [catch {fconfigure $f1 -buffering green} msg] $msg] - lappend l [fconfigure $f1 -buffering] + lappend l [chan configure $f1 -buffering] + lappend l [list [catch {chan configure $f1 -buffering green} msg] $msg] + lappend l [chan configure $f1 -buffering] close $f1 set l } {full {1 {bad value for -buffering: must be one of full, line, or none}} full} test io-39.6 {Tcl_SetChannelOption, multiple options} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -translation lf -buffering line + chan configure $f1 -translation lf -buffering line puts $f1 hello puts $f1 bye set x [file size $path(test1)] @@ -4964,11 +4964,11 @@ test io-39.6 {Tcl_SetChannelOption, multiple options} { test io-39.7 {Tcl_SetChannelOption, buffering, translation} { file delete $path(test1) set f1 [open $path(test1) w] - fconfigure $f1 -translation lf + chan configure $f1 -translation lf puts $f1 hello puts $f1 bye set x "" - fconfigure $f1 -buffering line + chan configure $f1 -buffering line lappend x [file size $path(test1)] puts $f1 really_bye lappend x [file size $path(test1)] @@ -4979,15 +4979,15 @@ test io-39.8 {Tcl_SetChannelOption, different buffering options} { file delete $path(test1) set f1 [open $path(test1) w] set l "" - fconfigure $f1 -translation lf -buffering none -eofchar {} + chan configure $f1 -translation lf -buffering none -eofchar {} puts -nonewline $f1 hello lappend l [file size $path(test1)] puts -nonewline $f1 hello lappend l [file size $path(test1)] - fconfigure $f1 -buffering full + chan configure $f1 -buffering full puts -nonewline $f1 hello lappend l [file size $path(test1)] - fconfigure $f1 -buffering none + chan configure $f1 -buffering none lappend l [file size $path(test1)] puts -nonewline $f1 hello lappend l [file size $path(test1)] @@ -5001,12 +5001,12 @@ test io-39.9 {Tcl_SetChannelOption, blocking mode} {nonBlockFiles} { close $f1 set f1 [open $path(test1) r] set x "" - lappend x [fconfigure $f1 -blocking] - fconfigure $f1 -blocking off - lappend x [fconfigure $f1 -blocking] + lappend x [chan configure $f1 -blocking] + chan configure $f1 -blocking off + lappend x [chan configure $f1 -blocking] lappend x [gets $f1] lappend x [read $f1 1000] - lappend x [fblocked $f1] + lappend x [chan blocked $f1] lappend x [eof $f1] close $f1 set x @@ -5023,24 +5023,24 @@ test io-39.10 {Tcl_SetChannelOption, blocking mode} {stdio openpipe} { close $f1 set x "" set f1 [open "|[list [interpreter] $path(pipe)]" r+] - fconfigure $f1 -blocking off -buffering line - lappend x [fconfigure $f1 -blocking] + chan configure $f1 -blocking off -buffering line + lappend x [chan configure $f1 -blocking] lappend x [gets $f1] - lappend x [fblocked $f1] - fconfigure $f1 -blocking on + lappend x [chan blocked $f1] + chan configure $f1 -blocking on puts $f1 hello - fconfigure $f1 -blocking off + chan configure $f1 -blocking off lappend x [gets $f1] - lappend x [fblocked $f1] - fconfigure $f1 -blocking on + lappend x [chan blocked $f1] + chan configure $f1 -blocking on puts $f1 bye - fconfigure $f1 -blocking off + chan configure $f1 -blocking off lappend x [gets $f1] - lappend x [fblocked $f1] - fconfigure $f1 -blocking on - lappend x [fconfigure $f1 -blocking] + lappend x [chan blocked $f1] + chan configure $f1 -blocking on + lappend x [chan configure $f1 -blocking] lappend x [gets $f1] - lappend x [fblocked $f1] + lappend x [chan blocked $f1] lappend x [eof $f1] lappend x [gets $f1] lappend x [eof $f1] @@ -5050,35 +5050,35 @@ test io-39.10 {Tcl_SetChannelOption, blocking mode} {stdio openpipe} { test io-39.11 {Tcl_SetChannelOption, Tcl_GetChannelOption, buffer size clipped to lower bound} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -buffersize -10 - set x [fconfigure $f -buffersize] + chan configure $f -buffersize -10 + set x [chan configure $f -buffersize] close $f set x } 1 test io-39.12 {Tcl_SetChannelOption, Tcl_GetChannelOption buffer size clipped to upper bound} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -buffersize 10000000 - set x [fconfigure $f -buffersize] + chan configure $f -buffersize 10000000 + set x [chan configure $f -buffersize] close $f set x } 1048576 test io-39.13 {Tcl_SetChannelOption, Tcl_GetChannelOption, buffer size} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -buffersize 40000 - set x [fconfigure $f -buffersize] + chan configure $f -buffersize 40000 + set x [chan configure $f -buffersize] close $f set x } 40000 test io-39.14 {Tcl_SetChannelOption: -encoding, binary & utf-8} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -encoding {} + chan configure $f -encoding {} puts -nonewline $f \xe7\x89\xa6 close $f set f [open $path(test1) r] - fconfigure $f -encoding utf-8 + chan configure $f -encoding utf-8 set x [read $f] close $f set x @@ -5086,11 +5086,11 @@ test io-39.14 {Tcl_SetChannelOption: -encoding, binary & utf-8} { test io-39.15 {Tcl_SetChannelOption: -encoding, binary & utf-8} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -encoding binary + chan configure $f -encoding binary puts -nonewline $f \xe7\x89\xa6 close $f set f [open $path(test1) r] - fconfigure $f -encoding utf-8 + chan configure $f -encoding utf-8 set x [read $f] close $f set x @@ -5098,26 +5098,26 @@ test io-39.15 {Tcl_SetChannelOption: -encoding, binary & utf-8} { test io-39.16 {Tcl_SetChannelOption: -encoding, errors} { file delete $path(test1) set f [open $path(test1) w] - set result [list [catch {fconfigure $f -encoding foobar} msg] $msg] + set result [list [catch {chan configure $f -encoding foobar} msg] $msg] close $f set result } {1 {unknown encoding "foobar"}} test io-39.17 {Tcl_SetChannelOption: -encoding, clearing CHANNEL_NEED_MORE_DATA} {stdio openpipe fileevent} { set f [open "|[list [interpreter] $path(cat)]" r+] - fconfigure $f -encoding binary + chan configure $f -encoding binary puts -nonewline $f "\xe7" flush $f - fconfigure $f -encoding utf-8 -blocking 0 + chan configure $f -encoding utf-8 -blocking 0 variable x {} - fileevent $f readable [namespace code { lappend x [read $f] }] + chan event $f readable [namespace code { lappend x [read $f] }] vwait [namespace which -variable x] after 300 [namespace code { lappend x timeout }] vwait [namespace which -variable x] - fconfigure $f -encoding utf-8 + chan configure $f -encoding utf-8 vwait [namespace which -variable x] after 300 [namespace code { lappend x timeout }] vwait [namespace which -variable x] - fconfigure $f -encoding binary + chan configure $f -encoding binary vwait [namespace which -variable x] after 300 [namespace code { lappend x timeout }] vwait [namespace which -variable x] @@ -5128,11 +5128,11 @@ test io-39.18 {Tcl_SetChannelOption, setting read mode independently} \ {socket} { proc accept {s a p} {close $s} set s1 [socket -server [namespace code accept] -myaddr 127.0.0.1 0] - set port [lindex [fconfigure $s1 -sockname] 2] + set port [lindex [chan configure $s1 -sockname] 2] set s2 [socket 127.0.0.1 $port] update - fconfigure $s2 -translation {auto lf} - set modes [fconfigure $s2 -translation] + chan configure $s2 -translation {auto lf} + set modes [chan configure $s2 -translation] close $s1 close $s2 set modes @@ -5141,11 +5141,11 @@ test io-39.19 {Tcl_SetChannelOption, setting read mode independently} \ {socket} { proc accept {s a p} {close $s} set s1 [socket -server [namespace code accept] -myaddr 127.0.0.1 0] - set port [lindex [fconfigure $s1 -sockname] 2] + set port [lindex [chan configure $s1 -sockname] 2] set s2 [socket 127.0.0.1 $port] update - fconfigure $s2 -translation {auto crlf} - set modes [fconfigure $s2 -translation] + chan configure $s2 -translation {auto crlf} + set modes [chan configure $s2 -translation] close $s1 close $s2 set modes @@ -5154,11 +5154,11 @@ test io-39.20 {Tcl_SetChannelOption, setting read mode independently} \ {socket} { proc accept {s a p} {close $s} set s1 [socket -server [namespace code accept] -myaddr 127.0.0.1 0] - set port [lindex [fconfigure $s1 -sockname] 2] + set port [lindex [chan configure $s1 -sockname] 2] set s2 [socket 127.0.0.1 $port] update - fconfigure $s2 -translation {auto cr} - set modes [fconfigure $s2 -translation] + chan configure $s2 -translation {auto cr} + set modes [chan configure $s2 -translation] close $s1 close $s2 set modes @@ -5167,11 +5167,11 @@ test io-39.21 {Tcl_SetChannelOption, setting read mode independently} \ {socket} { proc accept {s a p} {close $s} set s1 [socket -server [namespace code accept] -myaddr 127.0.0.1 0] - set port [lindex [fconfigure $s1 -sockname] 2] + set port [lindex [chan configure $s1 -sockname] 2] set s2 [socket 127.0.0.1 $port] update - fconfigure $s2 -translation {auto auto} - set modes [fconfigure $s2 -translation] + chan configure $s2 -translation {auto auto} + set modes [chan configure $s2 -translation] close $s1 close $s2 set modes @@ -5180,11 +5180,11 @@ test io-39.22 {Tcl_SetChannelOption, invariance} {unix} { file delete $path(test1) set f1 [open $path(test1) w+] set l "" - lappend l [fconfigure $f1 -eofchar] - fconfigure $f1 -eofchar {ON GO} - lappend l [fconfigure $f1 -eofchar] - fconfigure $f1 -eofchar D - lappend l [fconfigure $f1 -eofchar] + lappend l [chan configure $f1 -eofchar] + chan configure $f1 -eofchar {ON GO} + lappend l [chan configure $f1 -eofchar] + chan configure $f1 -eofchar D + lappend l [chan configure $f1 -eofchar] close $f1 set l } {{{} {}} {O G} {D D}} @@ -5192,11 +5192,11 @@ test io-39.22a {Tcl_SetChannelOption, invariance} { file delete $path(test1) set f1 [open $path(test1) w+] set l [list] - fconfigure $f1 -eofchar {ON GO} - lappend l [fconfigure $f1 -eofchar] - fconfigure $f1 -eofchar D - lappend l [fconfigure $f1 -eofchar] - lappend l [list [catch {fconfigure $f1 -eofchar {1 2 3}} msg] $msg] + chan configure $f1 -eofchar {ON GO} + lappend l [chan configure $f1 -eofchar] + chan configure $f1 -eofchar D + lappend l [chan configure $f1 -eofchar] + lappend l [list [catch {chan configure $f1 -eofchar {1 2 3}} msg] $msg] close $f1 set l } {{O G} {D D} {1 {bad value for -eofchar: should be a list of zero, one, or two elements}}} @@ -5204,7 +5204,7 @@ test io-39.23 {Tcl_GetChannelOption, server socket is not readable or writeable, it should still have valid -eofchar and -translation options } { set l [list] set sock [socket -server [namespace code accept] -myaddr 127.0.0.1 0] - lappend l [fconfigure $sock -eofchar] [fconfigure $sock -translation] + lappend l [chan configure $sock -eofchar] [chan configure $sock -translation] close $sock set l } {{{}} auto} @@ -5212,8 +5212,8 @@ test io-39.24 {Tcl_SetChannelOption, server socket is not readable or writable so we can't change -eofchar or -translation } { set l [list] set sock [socket -server [namespace code accept] -myaddr 127.0.0.1 0] - fconfigure $sock -eofchar D -translation lf - lappend l [fconfigure $sock -eofchar] [fconfigure $sock -translation] + chan configure $sock -eofchar D -translation lf + lappend l [chan configure $sock -eofchar] [chan configure $sock -translation] close $sock set l } {{{}} auto} @@ -5252,15 +5252,15 @@ test io-40.3 {POSIX open access modes: CREAT} {unix umask} { close $f file stat $path(test3) stats format "0%o" [expr $stats(mode)&0o777] -} [format %04o [expr {0o666 & ~ $umaskValue}]] +} [format %04o [expr {0o666 & ( ~ $umaskValue )}]] test io-40.4 {POSIX open access modes: CREAT} { file delete $path(test3) set f [open $path(test3) w] - fconfigure $f -eofchar {} + chan configure $f -eofchar {} puts $f xyzzy close $f set f [open $path(test3) {WRONLY CREAT}] - fconfigure $f -eofchar {} + chan configure $f -eofchar {} puts -nonewline $f "ab" close $f set f [open $path(test3) r] @@ -5271,17 +5271,17 @@ test io-40.4 {POSIX open access modes: CREAT} { test io-40.5 {POSIX open access modes: APPEND} { file delete $path(test3) set f [open $path(test3) w] - fconfigure $f -translation lf -eofchar {} + chan configure $f -translation lf -eofchar {} puts $f xyzzy close $f set f [open $path(test3) {WRONLY APPEND}] - fconfigure $f -translation lf + chan configure $f -translation lf puts $f "new line" seek $f 0 puts $f "abc" close $f set f [open $path(test3) r] - fconfigure $f -translation lf + chan configure $f -translation lf set x "" seek $f 6 current lappend x [gets $f] @@ -5299,7 +5299,7 @@ test io-40.6 {POSIX open access modes: EXCL} -match regexp -body { test io-40.7 {POSIX open access modes: EXCL} { file delete $path(test3) set f [open $path(test3) {WRONLY CREAT EXCL}] - fconfigure $f -eofchar {} + chan configure $f -eofchar {} puts $f "A test line" close $f viewFile test3 @@ -5350,7 +5350,7 @@ test io-40.12 {POSIX open access modes: WRONLY} -match regexp -body { test io-40.13 {POSIX open access modes: WRONLY} { makeFile xyzzy test3 set f [open $path(test3) WRONLY] - fconfigure $f -eofchar {} + chan configure $f -eofchar {} puts -nonewline $f "ab" seek $f 0 current set x [list [catch {gets $f} msg] $msg] @@ -5388,82 +5388,81 @@ test io-40.17 {tilde substitution in open} { } {1 {couldn't find HOME environment variable to expand path}} test io-41.1 {Tcl_FileeventCmd: errors} {fileevent} { - list [catch {fileevent foo} msg] $msg -} {1 {wrong # args: should be "fileevent channelId event ?script?"}} + list [catch {chan event foo} msg] $msg +} {1 {wrong # args: should be "chan event channelId event ?script?"}} test io-41.2 {Tcl_FileeventCmd: errors} {fileevent} { - list [catch {fileevent foo bar baz q} msg] $msg -} {1 {wrong # args: should be "fileevent channelId event ?script?"}} + list [catch {chan event foo bar baz q} msg] $msg +} {1 {wrong # args: should be "chan event channelId event ?script?"}} test io-41.3 {Tcl_FileeventCmd: errors} {fileevent} { - list [catch {fileevent gorp readable} msg] $msg + list [catch {chan event gorp readable} msg] $msg } {1 {can not find channel named "gorp"}} test io-41.4 {Tcl_FileeventCmd: errors} {fileevent} { - list [catch {fileevent gorp writable} msg] $msg + list [catch {chan event gorp writable} msg] $msg } {1 {can not find channel named "gorp"}} test io-41.5 {Tcl_FileeventCmd: errors} {fileevent} { - list [catch {fileevent gorp who-knows} msg] $msg + list [catch {chan event gorp who-knows} msg] $msg } {1 {bad event name "who-knows": must be readable or writable}} # -# Test fileevent on a file +# Test chan event on a file # set path(foo) [makeFile {} foo] set f [open $path(foo) w+] test io-42.1 {Tcl_FileeventCmd: creating, deleting, querying} {fileevent} { - list [fileevent $f readable] [fileevent $f writable] + list [chan event $f readable] [chan event $f writable] } {{} {}} test io-42.2 {Tcl_FileeventCmd: replacing} {fileevent} { - set result {} - fileevent $f r "first script" - lappend result [fileevent $f readable] - fileevent $f r "new script" - lappend result [fileevent $f readable] - fileevent $f r "yet another" - lappend result [fileevent $f readable] - fileevent $f r "" - lappend result [fileevent $f readable] + set result [list] + chan event $f r "first script" + lappend result [chan event $f readable] + chan event $f r "new script" + lappend result [chan event $f readable] + chan event $f r "yet another" + lappend result [chan event $f readable] + chan event $f r "" + lappend result [chan event $f readable] } {{first script} {new script} {yet another} {}} test io-42.3 {Tcl_FileeventCmd: replacing, with NULL chars in script} {fileevent} { - set result {} - fileevent $f r "first scr\0ipt" - lappend result [string length [fileevent $f readable]] - fileevent $f r "new scr\0ipt" - lappend result [string length [fileevent $f readable]] - fileevent $f r "yet ano\0ther" - lappend result [string length [fileevent $f readable]] - fileevent $f r "" - lappend result [fileevent $f readable] + set result [list] + chan event $f r "first scr\0ipt" + lappend result [string length [chan event $f readable]] + chan event $f r "new scr\0ipt" + lappend result [string length [chan event $f readable]] + chan event $f r "yet ano\0ther" + lappend result [string length [chan event $f readable]] + chan event $f r "" + lappend result [chan event $f readable] } {13 11 12 {}} - test io-43.1 {Tcl_FileeventCmd: creating, deleting, querying} {stdio unixExecs fileevent} { - set result {} - fileevent $f readable "script 1" - lappend result [fileevent $f readable] [fileevent $f writable] - fileevent $f writable "write script" - lappend result [fileevent $f readable] [fileevent $f writable] - fileevent $f readable {} - lappend result [fileevent $f readable] [fileevent $f writable] - fileevent $f writable {} - lappend result [fileevent $f readable] [fileevent $f writable] + set result [list] + chan event $f readable "script 1" + lappend result [chan event $f readable] [chan event $f writable] + chan event $f writable "write script" + lappend result [chan event $f readable] [chan event $f writable] + chan event $f readable {} + lappend result [chan event $f readable] [chan event $f writable] + chan event $f writable {} + lappend result [chan event $f readable] [chan event $f writable] } {{script 1} {} {script 1} {write script} {} {write script} {} {}} test io-43.2 {Tcl_FileeventCmd: deleting when many present} -setup { set f2 [open "|[list cat -u]" r+] set f3 [open "|[list cat -u]" r+] } -constraints {stdio unixExecs fileevent openpipe} -body { - set result {} - lappend result [fileevent $f r] [fileevent $f2 r] [fileevent $f3 r] - fileevent $f r "read f" - fileevent $f2 r "read f2" - fileevent $f3 r "read f3" - lappend result [fileevent $f r] [fileevent $f2 r] [fileevent $f3 r] - fileevent $f2 r {} - lappend result [fileevent $f r] [fileevent $f2 r] [fileevent $f3 r] - fileevent $f3 r {} - lappend result [fileevent $f r] [fileevent $f2 r] [fileevent $f3 r] - fileevent $f r {} - lappend result [fileevent $f r] [fileevent $f2 r] [fileevent $f3 r] + set result [list] + lappend result [chan event $f r] [chan event $f2 r] [chan event $f3 r] + chan event $f r "read f" + chan event $f2 r "read f2" + chan event $f3 r "read f3" + lappend result [chan event $f r] [chan event $f2 r] [chan event $f3 r] + chan event $f2 r {} + lappend result [chan event $f r] [chan event $f2 r] [chan event $f3 r] + chan event $f3 r {} + lappend result [chan event $f r] [chan event $f2 r] [chan event $f3 r] + chan event $f r {} + lappend result [chan event $f r] [chan event $f2 r] [chan event $f3 r] } -cleanup { catch {close $f2} catch {close $f3} @@ -5473,8 +5472,8 @@ test io-44.1 {FileEventProc procedure: normal read event} -setup { set f2 [open "|[list cat -u]" r+] set f3 [open "|[list cat -u]" r+] } -constraints {stdio unixExecs fileevent openpipe} -body { - fileevent $f2 readable [namespace code { - set x [gets $f2]; fileevent $f2 readable {} + chan event $f2 readable [namespace code { + set x [gets $f2]; chan event $f2 readable {} }] puts $f2 text; flush $f2 variable x initial @@ -5495,11 +5494,11 @@ test io-44.2 {FileEventProc procedure: error in read event} -constraints { set handler [interp bgerror {}] interp bgerror {} [namespace which myHandler] } -body { - fileevent $f2 readable {error bogus} + chan event $f2 readable {error bogus} puts $f2 text; flush $f2 variable x initial vwait [namespace which -variable x] - list $x [fileevent $f2 readable] + list $x [chan event $f2 readable] } -cleanup { interp bgerror {} $handler catch {close $f2} @@ -5509,11 +5508,11 @@ test io-44.3 {FileEventProc procedure: normal write event} -setup { set f2 [open "|[list cat -u]" r+] set f3 [open "|[list cat -u]" r+] } -constraints {stdio unixExecs fileevent openpipe} -body { - fileevent $f2 writable [namespace code { + chan event $f2 writable [namespace code { lappend x "triggered" incr count -1 if {$count <= 0} { - fileevent $f2 writable {} + chan event $f2 writable {} } }] variable x initial @@ -5537,10 +5536,10 @@ test io-44.4 {FileEventProc procedure: eror in write event} -constraints { set handler [interp bgerror {}] interp bgerror {} [namespace which myHandler] } -body { - fileevent $f2 writable {error bad-write} + chan event $f2 writable {error bad-write} variable x initial vwait [namespace which -variable x] - list $x [fileevent $f2 writable] + list $x [chan event $f2 writable] } -cleanup { interp bgerror {} $handler catch {close $f2} @@ -5548,10 +5547,10 @@ test io-44.4 {FileEventProc procedure: eror in write event} -constraints { } -result {bad-write {}} test io-44.5 {FileEventProc procedure: end of file} {stdio unixExecs openpipe fileevent} { set f4 [open "|[list [interpreter] $path(cat) << foo]" r] - fileevent $f4 readable [namespace code { + chan event $f4 readable [namespace code { if {[gets $f4 line] < 0} { lappend x eof - fileevent $f4 readable {} + chan event $f4 readable {} } else { lappend x $line } @@ -5568,9 +5567,9 @@ makeFile "foo bar" foo test io-45.1 {DeleteFileEvent, cleanup on close} {fileevent} { set f [open $path(foo) r] - fileevent $f readable [namespace code { + chan event $f readable [namespace code { lappend x "binding triggered: \"[gets $f]\"" - fileevent $f readable {} + chan event $f readable {} }] close $f set x initial @@ -5582,13 +5581,13 @@ test io-45.1 {DeleteFileEvent, cleanup on close} {fileevent} { test io-45.2 {DeleteFileEvent, cleanup on close} {fileevent} { set f [open $path(foo) r] set f2 [open $path(foo) r] - fileevent $f readable [namespace code { + chan event $f readable [namespace code { lappend x "f triggered: \"[gets $f]\"" - fileevent $f readable {} + chan event $f readable {} }] - fileevent $f2 readable [namespace code { + chan event $f2 readable [namespace code { lappend x "f2 triggered: \"[gets $f2]\"" - fileevent $f2 readable {} + chan event $f2 readable {} }] close $f variable x initial @@ -5600,22 +5599,22 @@ test io-45.3 {DeleteFileEvent, cleanup on close} {fileevent} { set f [open $path(foo) r] set f2 [open $path(foo) r] set f3 [open $path(foo) r] - fileevent $f readable {f script} - fileevent $f2 readable {f2 script} - fileevent $f3 readable {f3 script} + chan event $f readable {f script} + chan event $f2 readable {f2 script} + chan event $f3 readable {f3 script} set x {} close $f2 - lappend x [catch {fileevent $f readable} msg] $msg \ - [catch {fileevent $f2 readable}] \ - [catch {fileevent $f3 readable} msg] $msg + lappend x [catch {chan event $f readable} msg] $msg \ + [catch {chan event $f2 readable}] \ + [catch {chan event $f3 readable} msg] $msg close $f3 - lappend x [catch {fileevent $f readable} msg] $msg \ - [catch {fileevent $f2 readable}] \ - [catch {fileevent $f3 readable}] + lappend x [catch {chan event $f readable} msg] $msg \ + [catch {chan event $f2 readable}] \ + [catch {chan event $f3 readable}] close $f - lappend x [catch {fileevent $f readable}] \ - [catch {fileevent $f2 readable}] \ - [catch {fileevent $f3 readable}] + lappend x [catch {chan event $f readable}] \ + [catch {chan event $f2 readable}] \ + [catch {chan event $f3 readable}] } {0 {f script} 1 0 {f3 script} 0 {f script} 1 1 1 1 1} # Execute these tests only if the "testfevent" command is present. @@ -5625,9 +5624,9 @@ test io-46.1 {Tcl event loop vs multiple interpreters} {testfevent fileevent} { set script "set f \[[list open $path(foo) r]]\n" append script { set x "no event" - fileevent $f readable [namespace code { + chan event $f readable [namespace code { set x "f triggered: [gets $f]" - fileevent $f readable {} + chan event $f readable {} }] } testfevent cmd $script @@ -5663,36 +5662,36 @@ test io-47.1 {fileevent vs multiple interpreters} {testfevent fileevent} { set f [open $path(foo) r] set f2 [open $path(foo) r] set f3 [open $path(foo) r] - fileevent $f readable {script 1} + chan event $f readable {script 1} testfevent create testfevent share $f2 - testfevent cmd "fileevent $f2 readable {script 2}" - fileevent $f3 readable {sript 3} + testfevent cmd "chan event $f2 readable {script 2}" + chan event $f3 readable {sript 3} set x {} - lappend x [fileevent $f2 readable] + lappend x [chan event $f2 readable] testfevent delete - lappend x [fileevent $f readable] [fileevent $f2 readable] \ - [fileevent $f3 readable] + lappend x [chan event $f readable] [chan event $f2 readable] \ + [chan event $f3 readable] close $f close $f2 close $f3 set x } {{} {script 1} {} {sript 3}} -test io-47.2 {deleting fileevent on interpreter delete} {testfevent fileevent} { +test io-47.2 {deleting chan event on interpreter delete} {testfevent fileevent} { set f [open $path(foo) r] set f2 [open $path(foo) r] set f3 [open $path(foo) r] set f4 [open $path(foo) r] - fileevent $f readable {script 1} + chan event $f readable {script 1} testfevent create testfevent share $f2 testfevent share $f3 - testfevent cmd "fileevent $f2 readable {script 2} - fileevent $f3 readable {script 3}" - fileevent $f4 readable {script 4} + testfevent cmd "chan event $f2 readable {script 2} + chan event $f3 readable {script 3}" + chan event $f4 readable {script 4} testfevent delete - set x [list [fileevent $f readable] [fileevent $f2 readable] \ - [fileevent $f3 readable] [fileevent $f4 readable]] + set x [list [chan event $f readable] [chan event $f2 readable] \ + [chan event $f3 readable] [chan event $f4 readable]] close $f close $f2 close $f3 @@ -5707,13 +5706,13 @@ test io-47.3 {deleting fileevent on interpreter delete} {testfevent fileevent} { testfevent create testfevent share $f3 testfevent share $f4 - fileevent $f readable {script 1} - fileevent $f2 readable {script 2} - testfevent cmd "fileevent $f3 readable {script 3} - fileevent $f4 readable {script 4}" + chan event $f readable {script 1} + chan event $f2 readable {script 2} + testfevent cmd "chan event $f3 readable {script 3} + chan event $f4 readable {script 4}" testfevent delete - set x [list [fileevent $f readable] [fileevent $f2 readable] \ - [fileevent $f3 readable] [fileevent $f4 readable]] + set x [list [chan event $f readable] [chan event $f2 readable] \ + [chan event $f3 readable] [chan event $f4 readable]] close $f close $f2 close $f3 @@ -5725,12 +5724,12 @@ test io-47.4 {file events on shared files and multiple interpreters} {testfevent set f2 [open $path(foo) r] testfevent create testfevent share $f - testfevent cmd "fileevent $f readable {script 1}" - fileevent $f readable {script 2} - fileevent $f2 readable {script 3} - set x [list [fileevent $f2 readable] \ - [testfevent cmd "fileevent $f readable"] \ - [fileevent $f readable]] + testfevent cmd "chan event $f readable {script 1}" + chan event $f readable {script 2} + chan event $f2 readable {script 3} + set x [list [chan event $f2 readable] \ + [testfevent cmd "chan event $f readable"] \ + [chan event $f readable]] testfevent delete close $f close $f2 @@ -5740,11 +5739,11 @@ test io-47.5 {file events on shared files, deleting file events} {testfevent fil set f [open $path(foo) r] testfevent create testfevent share $f - testfevent cmd "fileevent $f readable {script 1}" - fileevent $f readable {script 2} - testfevent cmd "fileevent $f readable {}" - set x [list [testfevent cmd "fileevent $f readable"] \ - [fileevent $f readable]] + testfevent cmd "chan event $f readable {script 1}" + chan event $f readable {script 2} + testfevent cmd "chan event $f readable {}" + set x [list [testfevent cmd "chan event $f readable"] \ + [chan event $f readable]] testfevent delete close $f set x @@ -5753,11 +5752,11 @@ test io-47.6 {file events on shared files, deleting file events} {testfevent fil set f [open $path(foo) r] testfevent create testfevent share $f - testfevent cmd "fileevent $f readable {script 1}" - fileevent $f readable {script 2} - fileevent $f readable {} - set x [list [testfevent cmd "fileevent $f readable"] \ - [fileevent $f readable]] + testfevent cmd "chan event $f readable {script 1}" + chan event $f readable {script 2} + chan event $f readable {} + set x [list [testfevent cmd "chan event $f readable"] \ + [chan event $f readable]] testfevent delete close $f set x @@ -5774,7 +5773,7 @@ test io-48.1 {testing readability conditions} {fileevent} { puts $f abcdefg close $f set f [open $path(bar) r] - fileevent $f readable [namespace code [list consume $f]] + chan event $f readable [namespace code [list consume $f]] proc consume {f} { variable l variable x @@ -5800,8 +5799,8 @@ test io-48.2 {testing readability conditions} {nonBlockFiles fileevent} { puts $f abcdefg close $f set f [open $path(bar) r] - fileevent $f readable [namespace code [list consume $f]] - fconfigure $f -blocking off + chan event $f readable [namespace code [list consume $f]] + chan configure $f -blocking off proc consume {f} { variable x variable l @@ -5839,9 +5838,9 @@ test io-48.3 {testing readability conditions} {stdio unix nonBlockFiles openpipe } close $f set f [open "|[list [interpreter]]" r+] - fileevent $f readable [namespace code [list consume $f]] - fconfigure $f -buffering line - fconfigure $f -blocking off + chan event $f readable [namespace code [list consume $f]] + chan configure $f -buffering line + chan configure $f -blocking off proc consume {f} { variable l variable x @@ -5849,9 +5848,9 @@ test io-48.3 {testing readability conditions} {stdio unix nonBlockFiles openpipe set x done } else { gets $f - lappend l [fblocked $f] + lappend l [chan blocked $f] gets $f - lappend l [fblocked $f] + lappend l [chan blocked $f] } } set l "" @@ -5867,7 +5866,7 @@ test io-48.3 {testing readability conditions} {stdio unix nonBlockFiles openpipe test io-48.4 {lf write, testing readability, ^Z termination, auto read mode} {fileevent} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf variable c [format "abc\ndef\n%c" 26] puts -nonewline $f $c close $f @@ -5886,8 +5885,8 @@ test io-48.4 {lf write, testing readability, ^Z termination, auto read mode} {fi set c 0 set l "" set f [open $path(test1) r] - fconfigure $f -translation auto -eofchar \x1a - fileevent $f readable [namespace code [list consume $f]] + chan configure $f -translation auto -eofchar \x1a + chan event $f readable [namespace code [list consume $f]] variable x vwait [namespace which -variable x] list $c $l @@ -5895,7 +5894,7 @@ test io-48.4 {lf write, testing readability, ^Z termination, auto read mode} {fi test io-48.5 {lf write, testing readability, ^Z in middle, auto read mode} {fileevent} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf set c [format "abc\ndef\n%cfoo\nbar\n" 26] puts -nonewline $f $c close $f @@ -5914,8 +5913,8 @@ test io-48.5 {lf write, testing readability, ^Z in middle, auto read mode} {file set c 0 set l "" set f [open $path(test1) r] - fconfigure $f -eofchar \x1a -translation auto - fileevent $f readable [namespace code [list consume $f]] + chan configure $f -eofchar \x1a -translation auto + chan event $f readable [namespace code [list consume $f]] variable x vwait [namespace which -variable x] list $c $l @@ -5923,7 +5922,7 @@ test io-48.5 {lf write, testing readability, ^Z in middle, auto read mode} {file test io-48.6 {cr write, testing readability, ^Z termination, auto read mode} {fileevent} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr + chan configure $f -translation cr set c [format "abc\ndef\n%c" 26] puts -nonewline $f $c close $f @@ -5942,8 +5941,8 @@ test io-48.6 {cr write, testing readability, ^Z termination, auto read mode} {fi set c 0 set l "" set f [open $path(test1) r] - fconfigure $f -translation auto -eofchar \x1a - fileevent $f readable [namespace code [list consume $f]] + chan configure $f -translation auto -eofchar \x1a + chan event $f readable [namespace code [list consume $f]] variable x vwait [namespace which -variable x] list $c $l @@ -5951,7 +5950,7 @@ test io-48.6 {cr write, testing readability, ^Z termination, auto read mode} {fi test io-48.7 {cr write, testing readability, ^Z in middle, auto read mode} {fileevent} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr + chan configure $f -translation cr set c [format "abc\ndef\n%cfoo\nbar\n" 26] puts -nonewline $f $c close $f @@ -5970,8 +5969,8 @@ test io-48.7 {cr write, testing readability, ^Z in middle, auto read mode} {file set c 0 set l "" set f [open $path(test1) r] - fconfigure $f -eofchar \x1a -translation auto - fileevent $f readable [namespace code [list consume $f]] + chan configure $f -eofchar \x1a -translation auto + chan event $f readable [namespace code [list consume $f]] variable x vwait [namespace which -variable x] list $c $l @@ -5979,7 +5978,7 @@ test io-48.7 {cr write, testing readability, ^Z in middle, auto read mode} {file test io-48.8 {crlf write, testing readability, ^Z termination, auto read mode} {fileevent} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf set c [format "abc\ndef\n%c" 26] puts -nonewline $f $c close $f @@ -5998,8 +5997,8 @@ test io-48.8 {crlf write, testing readability, ^Z termination, auto read mode} { set c 0 set l "" set f [open $path(test1) r] - fconfigure $f -translation auto -eofchar \x1a - fileevent $f readable [namespace code [list consume $f]] + chan configure $f -translation auto -eofchar \x1a + chan event $f readable [namespace code [list consume $f]] variable x vwait [namespace which -variable x] list $c $l @@ -6007,7 +6006,7 @@ test io-48.8 {crlf write, testing readability, ^Z termination, auto read mode} { test io-48.9 {crlf write, testing readability, ^Z in middle, auto read mode} {fileevent} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf set c [format "abc\ndef\n%cfoo\nbar\n" 26] puts -nonewline $f $c close $f @@ -6026,8 +6025,8 @@ test io-48.9 {crlf write, testing readability, ^Z in middle, auto read mode} {fi set c 0 set l "" set f [open $path(test1) r] - fconfigure $f -eofchar \x1a -translation auto - fileevent $f readable [namespace code [list consume $f]] + chan configure $f -eofchar \x1a -translation auto + chan event $f readable [namespace code [list consume $f]] variable x vwait [namespace which -variable x] list $c $l @@ -6035,7 +6034,7 @@ test io-48.9 {crlf write, testing readability, ^Z in middle, auto read mode} {fi test io-48.10 {lf write, testing readability, ^Z in middle, lf read mode} {fileevent} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf set c [format "abc\ndef\n%cfoo\nbar\n" 26] puts -nonewline $f $c close $f @@ -6054,8 +6053,8 @@ test io-48.10 {lf write, testing readability, ^Z in middle, lf read mode} {filee set c 0 set l "" set f [open $path(test1) r] - fconfigure $f -eofchar \x1a -translation lf - fileevent $f readable [namespace code [list consume $f]] + chan configure $f -eofchar \x1a -translation lf + chan event $f readable [namespace code [list consume $f]] variable x vwait [namespace which -variable x] list $c $l @@ -6063,7 +6062,7 @@ test io-48.10 {lf write, testing readability, ^Z in middle, lf read mode} {filee test io-48.11 {lf write, testing readability, ^Z termination, lf read mode} {fileevent} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf set c [format "abc\ndef\n%c" 26] puts -nonewline $f $c close $f @@ -6082,8 +6081,8 @@ test io-48.11 {lf write, testing readability, ^Z termination, lf read mode} {fil set c 0 set l "" set f [open $path(test1) r] - fconfigure $f -translation lf -eofchar \x1a - fileevent $f readable [namespace code [list consume $f]] + chan configure $f -translation lf -eofchar \x1a + chan event $f readable [namespace code [list consume $f]] variable x vwait [namespace which -variable x] list $c $l @@ -6091,7 +6090,7 @@ test io-48.11 {lf write, testing readability, ^Z termination, lf read mode} {fil test io-48.12 {cr write, testing readability, ^Z in middle, cr read mode} {fileevent} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr + chan configure $f -translation cr set c [format "abc\ndef\n%cfoo\nbar\n" 26] puts -nonewline $f $c close $f @@ -6110,8 +6109,8 @@ test io-48.12 {cr write, testing readability, ^Z in middle, cr read mode} {filee set c 0 set l "" set f [open $path(test1) r] - fconfigure $f -eofchar \x1a -translation cr - fileevent $f readable [namespace code [list consume $f]] + chan configure $f -eofchar \x1a -translation cr + chan event $f readable [namespace code [list consume $f]] variable x vwait [namespace which -variable x] list $c $l @@ -6119,7 +6118,7 @@ test io-48.12 {cr write, testing readability, ^Z in middle, cr read mode} {filee test io-48.13 {cr write, testing readability, ^Z termination, cr read mode} {fileevent} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation cr + chan configure $f -translation cr set c [format "abc\ndef\n%c" 26] puts -nonewline $f $c close $f @@ -6138,8 +6137,8 @@ test io-48.13 {cr write, testing readability, ^Z termination, cr read mode} {fil set c 0 set l "" set f [open $path(test1) r] - fconfigure $f -translation cr -eofchar \x1a - fileevent $f readable [namespace code [list consume $f]] + chan configure $f -translation cr -eofchar \x1a + chan event $f readable [namespace code [list consume $f]] variable x vwait [namespace which -variable x] list $c $l @@ -6147,7 +6146,7 @@ test io-48.13 {cr write, testing readability, ^Z termination, cr read mode} {fil test io-48.14 {crlf write, testing readability, ^Z in middle, crlf read mode} {fileevent} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf set c [format "abc\ndef\n%cfoo\nbar\n" 26] puts -nonewline $f $c close $f @@ -6166,8 +6165,8 @@ test io-48.14 {crlf write, testing readability, ^Z in middle, crlf read mode} {f set c 0 set l "" set f [open $path(test1) r] - fconfigure $f -eofchar \x1a -translation crlf - fileevent $f readable [namespace code [list consume $f]] + chan configure $f -eofchar \x1a -translation crlf + chan event $f readable [namespace code [list consume $f]] variable x vwait [namespace which -variable x] list $c $l @@ -6175,7 +6174,7 @@ test io-48.14 {crlf write, testing readability, ^Z in middle, crlf read mode} {f test io-48.15 {crlf write, testing readability, ^Z termi, crlf read mode} {fileevent} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation crlf + chan configure $f -translation crlf set c [format "abc\ndef\n%c" 26] puts -nonewline $f $c close $f @@ -6194,8 +6193,8 @@ test io-48.15 {crlf write, testing readability, ^Z termi, crlf read mode} {filee set c 0 set l "" set f [open $path(test1) r] - fconfigure $f -translation crlf -eofchar \x1a - fileevent $f readable [namespace code [list consume $f]] + chan configure $f -translation crlf -eofchar \x1a + chan event $f readable [namespace code [list consume $f]] variable x vwait [namespace which -variable x] list $c $l @@ -6204,13 +6203,13 @@ test io-48.15 {crlf write, testing readability, ^Z termi, crlf read mode} {filee test io-49.1 {testing crlf reading, leftover cr disgorgment} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "a\rb\rc\r\n" close $f set f [open $path(test1) r] set l "" lappend l [file size $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf lappend l [read $f 1] lappend l [tell $f] lappend l [read $f 1] @@ -6233,13 +6232,13 @@ test io-49.1 {testing crlf reading, leftover cr disgorgment} { test io-49.2 {testing crlf reading, leftover cr disgorgment} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "a\rb\rc\r\n" close $f set f [open $path(test1) r] set l "" lappend l [file size $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf lappend l [read $f 2] lappend l [tell $f] lappend l [read $f 2] @@ -6256,13 +6255,13 @@ test io-49.2 {testing crlf reading, leftover cr disgorgment} { test io-49.3 {testing crlf reading, leftover cr disgorgment} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "a\rb\rc\r\n" close $f set f [open $path(test1) r] set l "" lappend l [file size $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf lappend l [read $f 3] lappend l [tell $f] lappend l [read $f 3] @@ -6277,13 +6276,13 @@ test io-49.3 {testing crlf reading, leftover cr disgorgment} { test io-49.4 {testing crlf reading, leftover cr disgorgment} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "a\rb\rc\r\n" close $f set f [open $path(test1) r] set l "" lappend l [file size $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf lappend l [read $f 3] lappend l [tell $f] lappend l [gets $f] @@ -6298,13 +6297,13 @@ test io-49.4 {testing crlf reading, leftover cr disgorgment} { test io-49.5 {testing crlf reading, leftover cr disgorgment} { file delete $path(test1) set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts -nonewline $f "a\rb\rc\r\n" close $f set f [open $path(test1) r] set l "" lappend l [file size $path(test1)] - fconfigure $f -translation crlf + chan configure $f -translation crlf lappend l [set x [gets $f]] lappend l [tell $f] lappend l [gets $f] @@ -6383,7 +6382,7 @@ test io-50.4 {testing handler deletion vs reentrant calls} {testchannelevent} { proc delrecursive {f} { variable z variable u - if {"$u" == "recursive"} { + if {$u eq "recursive"} { testchannelevent $f delete 0 lappend z "delrecursive deleting recursive" } else { @@ -6413,7 +6412,7 @@ test io-50.5 {testing handler deletion vs reentrant calls} {testchannelevent} { proc del {f} { variable u variable z - if {"$u" == "recursive"} { + if {$u eq "recursive"} { testchannelevent $f delete 1 testchannelevent $f delete 0 lappend z "del deleted notcalled" @@ -6443,7 +6442,7 @@ test io-50.6 {testing handler deletion vs reentrant calls} {testchannelevent} { proc first {f} { variable u variable z - if {"$u" == "toplevel"} { + if {$u eq "toplevel"} { lappend z "first called" set u first update @@ -6455,11 +6454,11 @@ test io-50.6 {testing handler deletion vs reentrant calls} {testchannelevent} { proc second {f} { variable u variable z - if {"$u" == "first"} { + if {$u eq "first"} { lappend z "second called, first time" set u second testchannelevent $f delete 0 - } elseif {"$u" == "second"} { + } elseif {$u eq "second"} { lappend z "second called, second time" testchannelevent $f delete 0 } else { @@ -6483,13 +6482,13 @@ test io-51.1 {Test old socket deletion on Macintosh} {socket} { proc accept {s a p} { variable x variable wait - fconfigure $s -blocking off + chan configure $s -blocking off puts $s "sock[incr x]" close $s set wait done } set ss [socket -server [namespace code accept] -myaddr 127.0.0.1 0] - set port [lindex [fconfigure $ss -sockname] 2] + set port [lindex [chan configure $ss -sockname] 2] variable wait "" set cs [socket 127.0.0.1 $port] @@ -6522,8 +6521,8 @@ test io-52.1 {TclCopyChannel} {fcopy} { file delete $path(test1) set f1 [open $thisScript] set f2 [open $path(test1) w] - fcopy $f1 $f2 -command { # } - catch { fcopy $f1 $f2 } msg + chan copy $f1 $f2 -command { # } + catch { chan copy $f1 $f2 } msg close $f1 close $f2 string compare $msg "channel \"$f1\" is busy" @@ -6533,8 +6532,8 @@ test io-52.2 {TclCopyChannel} {fcopy} { set f1 [open $thisScript] set f2 [open $path(test1) w] set f3 [open $thisScript] - fcopy $f1 $f2 -command { # } - catch { fcopy $f3 $f2 } msg + chan copy $f1 $f2 -command { # } + catch { chan copy $f3 $f2 } msg close $f1 close $f2 close $f3 @@ -6544,15 +6543,15 @@ test io-52.3 {TclCopyChannel} {fcopy} { file delete $path(test1) set f1 [open $thisScript] set f2 [open $path(test1) w] - fconfigure $f1 -translation lf -blocking 0 - fconfigure $f2 -translation cr -blocking 0 - set s0 [fcopy $f1 $f2] - set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]] + chan configure $f1 -translation lf -blocking 0 + chan configure $f2 -translation cr -blocking 0 + set s0 [chan copy $f1 $f2] + set result [list [chan configure $f1 -blocking] [chan configure $f2 -blocking]] close $f1 close $f2 set s1 [file size $thisScript] set s2 [file size $path(test1)] - if {("$s1" == "$s2") && ($s0 == $s1)} { + if {($s1 == $s2) && ($s0 == $s1)} { lappend result ok } set result @@ -6561,10 +6560,10 @@ test io-52.4 {TclCopyChannel} {fcopy} { file delete $path(test1) set f1 [open $thisScript] set f2 [open $path(test1) w] - fconfigure $f1 -translation lf -blocking 0 - fconfigure $f2 -translation cr -blocking 0 - fcopy $f1 $f2 -size 40 - set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]] + chan configure $f1 -translation lf -blocking 0 + chan configure $f2 -translation cr -blocking 0 + chan copy $f1 $f2 -size 40 + set result [list [chan configure $f1 -blocking] [chan configure $f2 -blocking]] close $f1 close $f2 lappend result [file size $path(test1)] @@ -6573,15 +6572,15 @@ test io-52.5 {TclCopyChannel, all} {fcopy} { file delete $path(test1) set f1 [open $thisScript] set f2 [open $path(test1) w] - fconfigure $f1 -translation lf -blocking 0 - fconfigure $f2 -translation lf -blocking 0 - fcopy $f1 $f2 -size -1 ;# -1 means 'copy all', same as if no -size specified. - set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]] + chan configure $f1 -translation lf -blocking 0 + chan configure $f2 -translation lf -blocking 0 + chan copy $f1 $f2 -size -1 ;# -1 means 'copy all', same as if no -size specified. + set result [list [chan configure $f1 -blocking] [chan configure $f2 -blocking]] close $f1 close $f2 set s1 [file size $thisScript] set s2 [file size $path(test1)] - if {"$s1" == "$s2"} { + if {$s1 == $s2} { lappend result ok } set result @@ -6590,15 +6589,15 @@ test io-52.5a {TclCopyChannel, all, other negative value} {fcopy} { file delete $path(test1) set f1 [open $thisScript] set f2 [open $path(test1) w] - fconfigure $f1 -translation lf -blocking 0 - fconfigure $f2 -translation lf -blocking 0 - fcopy $f1 $f2 -size -2 ;# < 0 behaves like -1, copy all - set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]] + chan configure $f1 -translation lf -blocking 0 + chan configure $f2 -translation lf -blocking 0 + chan copy $f1 $f2 -size -2 ;# < 0 behaves like -1, copy all + set result [list [chan configure $f1 -blocking] [chan configure $f2 -blocking]] close $f1 close $f2 set s1 [file size $thisScript] set s2 [file size $path(test1)] - if {"$s1" == "$s2"} { + if {$s1 == $s2} { lappend result ok } set result @@ -6607,15 +6606,15 @@ test io-52.5b {TclCopyChannel, all, wrap to negative value} {fcopy} { file delete $path(test1) set f1 [open $thisScript] set f2 [open $path(test1) w] - fconfigure $f1 -translation lf -blocking 0 - fconfigure $f2 -translation lf -blocking 0 - fcopy $f1 $f2 -size 3221176172 ;# Wrapped to < 0, behaves like -1, copy all - set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]] + chan configure $f1 -translation lf -blocking 0 + chan configure $f2 -translation lf -blocking 0 + chan copy $f1 $f2 -size 3221176172 ;# Wrapped to < 0, behaves like -1, copy all + set result [list [chan configure $f1 -blocking] [chan configure $f2 -blocking]] close $f1 close $f2 set s1 [file size $thisScript] set s2 [file size $path(test1)] - if {"$s1" == "$s2"} { + if {$s1 == $s2} { lappend result ok } set result @@ -6624,15 +6623,15 @@ test io-52.6 {TclCopyChannel} {fcopy} { file delete $path(test1) set f1 [open $thisScript] set f2 [open $path(test1) w] - fconfigure $f1 -translation lf -blocking 0 - fconfigure $f2 -translation lf -blocking 0 - set s0 [fcopy $f1 $f2 -size [expr [file size $thisScript] + 5]] - set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]] + chan configure $f1 -translation lf -blocking 0 + chan configure $f2 -translation lf -blocking 0 + set s0 [chan copy $f1 $f2 -size [expr [file size $thisScript] + 5]] + set result [list [chan configure $f1 -blocking] [chan configure $f2 -blocking]] close $f1 close $f2 set s1 [file size $thisScript] set s2 [file size $path(test1)] - if {("$s1" == "$s2") && ($s0 == $s1)} { + if {($s1 == $s2) && ($s0 == $s1)} { lappend result ok } set result @@ -6641,15 +6640,15 @@ test io-52.7 {TclCopyChannel} {fcopy} { file delete $path(test1) set f1 [open $thisScript] set f2 [open $path(test1) w] - fconfigure $f1 -translation lf -blocking 0 - fconfigure $f2 -translation lf -blocking 0 - fcopy $f1 $f2 - set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]] + chan configure $f1 -translation lf -blocking 0 + chan configure $f2 -translation lf -blocking 0 + chan copy $f1 $f2 + set result [list [chan configure $f1 -blocking] [chan configure $f2 -blocking]] set s1 [file size $thisScript] set s2 [file size $path(test1)] close $f1 close $f2 - if {"$s1" == "$s2"} { + if {$s1 == $s2} { lappend result ok } set result @@ -6658,24 +6657,24 @@ test io-52.8 {TclCopyChannel} {stdio openpipe fcopy} { file delete $path(test1) file delete $path(pipe) set f1 [open $path(pipe) w] - fconfigure $f1 -translation lf + chan configure $f1 -translation lf puts $f1 " puts ready gets stdin set f1 \[open [list $thisScript] r\] - fconfigure \$f1 -translation lf + chan configure \$f1 -translation lf puts \[read \$f1 100\] close \$f1 " close $f1 set f1 [open "|[list [interpreter] $path(pipe)]" r+] - fconfigure $f1 -translation lf + chan configure $f1 -translation lf gets $f1 puts $f1 ready flush $f1 set f2 [open $path(test1) w] - fconfigure $f2 -translation lf - set s0 [fcopy $f1 $f2 -size 40] + chan configure $f2 -translation lf + set s0 [chan copy $f1 $f2 -size 40] catch {close $f1} close $f2 list $s0 [file size $path(test1)] @@ -6686,33 +6685,33 @@ set path(utf8-fcopy.txt) [makeFile {} utf8-fcopy.txt] set path(utf8-rp.txt) [makeFile {} utf8-rp.txt] # Create kyrillic file, use lf translation to avoid os eol issues set out [open $path(kyrillic.txt) w] -fconfigure $out -encoding koi8-r -translation lf -puts $out "\u0410\u0410" -close $out +chan configure $out -encoding koi8-r -translation lf +chan puts $out "\u0410\u0410" +chan close $out test io-52.9 {TclCopyChannel & encodings} {fcopy} { - # Copy kyrillic to UTF-8, using fcopy. + # Copy kyrillic to UTF-8, using chan copy. set in [open $path(kyrillic.txt) r] set out [open $path(utf8-fcopy.txt) w] - fconfigure $in -encoding koi8-r -translation lf - fconfigure $out -encoding utf-8 -translation lf + chan configure $in -encoding koi8-r -translation lf + chan configure $out -encoding utf-8 -translation lf - fcopy $in $out - close $in - close $out + chan copy $in $out + chan close $in + chan close $out # Do the same again, but differently (read/puts). set in [open $path(kyrillic.txt) r] set out [open $path(utf8-rp.txt) w] - fconfigure $in -encoding koi8-r -translation lf - fconfigure $out -encoding utf-8 -translation lf + chan configure $in -encoding koi8-r -translation lf + chan configure $out -encoding utf-8 -translation lf - puts -nonewline $out [read $in] + chan puts -nonewline $out [read $in] - close $in + chan close $in close $out list [file size $path(kyrillic.txt)] \ @@ -6726,11 +6725,11 @@ test io-52.10 {TclCopyChannel & encodings} {fcopy} { set in [open $path(kyrillic.txt) r] set out [open $path(utf8-fcopy.txt) w] - fconfigure $in -encoding koi8-r -translation lf + chan configure $in -encoding koi8-r -translation lf # -translation binary is also -encoding binary - fconfigure $out -translation binary + chan configure $out -translation binary - fcopy $in $out + chan copy $in $out close $in close $out @@ -6744,10 +6743,10 @@ test io-52.11 {TclCopyChannel & encodings} {fcopy} { set out [open $path(kyrillic.txt) w] # -translation binary is also -encoding binary - fconfigure $in -translation binary - fconfigure $out -encoding koi8-r -translation lf + chan configure $in -translation binary + chan configure $out -encoding koi8-r -translation lf - fcopy $in $out + chan copy $in $out close $in close $out @@ -6758,10 +6757,10 @@ test io-53.1 {CopyData} {fcopy} { file delete $path(test1) set f1 [open $thisScript] set f2 [open $path(test1) w] - fconfigure $f1 -translation lf -blocking 0 - fconfigure $f2 -translation cr -blocking 0 - fcopy $f1 $f2 -size 0 - set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]] + chan configure $f1 -translation lf -blocking 0 + chan configure $f2 -translation cr -blocking 0 + chan copy $f1 $f2 -size 0 + set result [list [chan configure $f1 -blocking] [chan configure $f2 -blocking]] close $f1 close $f2 lappend result [file size $path(test1)] @@ -6770,17 +6769,17 @@ test io-53.2 {CopyData} {fcopy} { file delete $path(test1) set f1 [open $thisScript] set f2 [open $path(test1) w] - fconfigure $f1 -translation lf -blocking 0 - fconfigure $f2 -translation cr -blocking 0 - fcopy $f1 $f2 -command [namespace code {set s0}] - set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]] + chan configure $f1 -translation lf -blocking 0 + chan configure $f2 -translation cr -blocking 0 + chan copy $f1 $f2 -command [namespace code {set s0}] + set result [list [chan configure $f1 -blocking] [chan configure $f2 -blocking]] variable s0 vwait [namespace which -variable s0] close $f1 close $f2 set s1 [file size $thisScript] set s2 [file size $path(test1)] - if {("$s1" == "$s2") && ($s0 == $s1)} { + if {($s1 == $s2) && ($s0 == $s1)} { lappend result ok } set result @@ -6792,12 +6791,12 @@ test io-53.3 {CopyData: background read underflow} {stdio unix openpipe fcopy} { puts -nonewline $f1 { puts ready flush stdout ;# Don't assume line buffered! - fcopy stdin stdout -command { set x } + chan copy stdin stdout -command { set x } vwait x set f [} puts $f1 [list open $path(test1) w]] puts $f1 { - fconfigure $f -translation lf + chan configure $f -translation lf puts $f "done" close $f } @@ -6828,22 +6827,22 @@ test io-53.4 {CopyData: background write overflow} {stdio unix openpipe fileeven set f1 [open $path(pipe) w] puts $f1 { puts ready - fcopy stdin stdout -command { set x } + chan copy stdin stdout -command { set x } vwait x set f [open $path(test1) w] - fconfigure $f -translation lf + chan configure $f -translation lf puts $f "done" close $f } close $f1 set f1 [open "|[list [interpreter] $path(pipe)]" r+] set result [gets $f1] - fconfigure $f1 -blocking 0 + chan configure $f1 -blocking 0 puts $f1 $big flush $f1 after 500 set result "" - fileevent $f1 read [namespace code { + chan event $f1 read [namespace code { append result [read $f1 1024] if {[string length $result] >= [string length $big]} { set x done @@ -6851,10 +6850,10 @@ test io-53.4 {CopyData: background write overflow} {stdio unix openpipe fileeven }] vwait [namespace which -variable x] close $f1 - set big {} + set big "" set x } done -set result {} +set result "" proc FcopyTestAccept {sock args} { after 1000 "close $sock" } @@ -6866,14 +6865,14 @@ proc FcopyTestDone {bytes {error {}}} { set fcopyTestDone 0 } } -test io-53.5 {CopyData: error during fcopy} {socket fcopy} { +test io-53.5 {CopyData: error during chan copy} {socket fcopy} { variable fcopyTestDone set listen [socket -server [namespace code FcopyTestAccept] -myaddr 127.0.0.1 0] set in [open $thisScript] ;# 126 K - set out [socket 127.0.0.1 [lindex [fconfigure $listen -sockname] 2]] - catch {unset fcopyTestDone} + set out [socket 127.0.0.1 [lindex [chan configure $listen -sockname] 2]] + unset -nocomplain fcopyTestDone close $listen ;# This means the socket open never really succeeds - fcopy $in $out -command [namespace code FcopyTestDone] + chan copy $in $out -command [namespace code FcopyTestDone] variable fcopyTestDone if ![info exists fcopyTestDone] { vwait [namespace which -variable fcopyTestDone] ;# The error occurs here in the b.g. @@ -6882,17 +6881,17 @@ test io-53.5 {CopyData: error during fcopy} {socket fcopy} { close $out set fcopyTestDone ;# 1 for error condition } 1 -test io-53.6 {CopyData: error during fcopy} {stdio openpipe fcopy} { +test io-53.6 {CopyData: error during chan copy} {stdio openpipe fcopy} { variable fcopyTestDone file delete $path(pipe) file delete $path(test1) - catch {unset fcopyTestDone} + unset -nocomplain fcopyTestDone set f1 [open $path(pipe) w] puts $f1 "exit 1" close $f1 set in [open "|[list [interpreter] $path(pipe)]" r+] set out [open $path(test1) w] - fcopy $in $out -command [namespace code FcopyTestDone] + chan copy $in $out -command [namespace code FcopyTestDone] variable fcopyTestDone if ![info exists fcopyTestDone] { vwait [namespace which -variable fcopyTestDone] @@ -6910,15 +6909,15 @@ proc doFcopy {in out {bytes 0} {error {}}} { } elseif {[eof $in]} { set fcopyTestDone 0 } else { - # Delay next fcopy to wait for size>0 input bytes - after 100 [list fcopy $in $out -size 1000 \ + # Delay next chan copy to wait for size>0 input bytes + after 100 [list chan copy $in $out -size 1000 \ -command [namespace code [list doFcopy $in $out]]] } } -test io-53.7 {CopyData: Flooding fcopy from pipe} {stdio openpipe fcopy} { +test io-53.7 {CopyData: Flooding chan copy from pipe} {stdio openpipe fcopy} { variable fcopyTestDone file delete $path(pipe) - catch {unset fcopyTestDone} + unset -nocomplain fcopyTestDone set fcopyTestCount 0 set f1 [open $path(pipe) w] puts $f1 { @@ -6931,7 +6930,7 @@ test io-53.7 {CopyData: Flooding fcopy from pipe} {stdio openpipe fcopy} { set ::ready 1 } } - fconfigure stdout -buffering none + chan configure stdout -buffering none Write 345 ;# 3450 bytes ~3.45 sec vwait ready exit 0 @@ -6965,13 +6964,13 @@ test io-53.8 {CopyData: async callback and error handling, Bug 1932639} -setup { set foo [makeFile ashgdfashdgfasdhgfasdhgf foo] set bar [makeFile {} bar] # Channels to copy between - set f [open $foo r] ; fconfigure $f -translation binary - set g [open $bar w] ; fconfigure $g -translation binary -buffering none + set f [open $foo r] ; chan configure $f -translation binary + set g [open $bar w] ; chan configure $g -translation binary -buffering none } -constraints {stdio openpipe fcopy} -body { # Record input size, so that result is always defined lappend ::RES [file size $bar] # Run the copy. Should not invoke -command now. - fcopy $f $g -size 2 -command ::cmd + chan copy $f $g -size 2 -command ::cmd # Check that -command was not called synchronously set sbs [file size $bar] lappend ::RES [expr {($sbs > 0) ? "sync/FAIL" : "sync/OK"}] $sbs @@ -6988,10 +6987,9 @@ test io-53.8 {CopyData: async callback and error handling, Bug 1932639} -setup { } -cleanup { close $f close $g - catch {unset ::RES} - catch {unset ::forever} - rename ::cmd {} - rename ::bgerror {} + unset -nocomplain ::RES ::forever + rename ::cmd "" + rename ::bgerror "" removeFile foo removeFile bar } -result {0 sync/OK 0 {CMD 2} {bgerror/OK !STOP}} @@ -7006,14 +7004,14 @@ test io-53.8a {CopyData: async callback and error handling, Bug 1932639, at eof} set foo [makeFile ashgdfashdgfasdhgfasdhgf foo] set bar [makeFile {} bar] # Channels to copy between - set f [open $foo r] ; fconfigure $f -translation binary - set g [open $bar w] ; fconfigure $g -translation binary -buffering none + set f [open $foo r] ; chan configure $f -translation binary + set g [open $bar w] ; chan configure $g -translation binary -buffering none } -constraints {stdio openpipe fcopy} -body { # Initialize and force eof on the input. seek $f 0 end ; read $f 1 set ::RES [eof $f] # Run the copy. Should not invoke -command now. - fcopy $f $g -size 2 -command ::cmd + chan copy $f $g -size 2 -command ::cmd # Check that -command was not called synchronously lappend ::RES [expr {([llength $::RES] > 1) ? "sync/FAIL" : "sync/OK"}] # Now let the async part happen. Should capture the eof in cmd @@ -7029,8 +7027,7 @@ test io-53.8a {CopyData: async callback and error handling, Bug 1932639, at eof} } -cleanup { close $f close $g - catch {unset ::RES} - catch {unset ::forever} + unset -nocomplain ::RES ::forever rename ::cmd {} removeFile foo removeFile bar @@ -7046,12 +7043,12 @@ test io-53.8b {CopyData: async callback and -size 0} -setup { set foo [makeFile ashgdfashdgfasdhgfasdhgf foo] set bar [makeFile {} bar] # Channels to copy between - set f [open $foo r] ; fconfigure $f -translation binary - set g [open $bar w] ; fconfigure $g -translation binary -buffering none + set f [open $foo r] ; chan configure $f -translation binary + set g [open $bar w] ; chan configure $g -translation binary -buffering none } -constraints {stdio openpipe fcopy} -body { set ::RES {} # Run the copy. Should not invoke -command now. - fcopy $f $g -size 0 -command ::cmd + chan copy $f $g -size 0 -command ::cmd # Check that -command was not called synchronously lappend ::RES [expr {([llength $::RES] > 1) ? "sync/FAIL" : "sync/OK"}] # Now let the async part happen. Should capture the eof in cmd @@ -7067,8 +7064,7 @@ test io-53.8b {CopyData: async callback and -size 0} -setup { } -cleanup { close $f close $g - catch {unset ::RES} - catch {unset ::forever} + unset -nocomplain ::RES ::forever rename ::cmd {} removeFile foo removeFile bar @@ -7077,9 +7073,9 @@ test io-53.9 {CopyData: -size and event interaction, Bug 780533} -setup { set out [makeFile {} out] set err [makeFile {} err] set pipe [open "|[list [info nameofexecutable] 2> $err]" r+] - fconfigure $pipe -translation binary -buffering line + chan configure $pipe -translation binary -buffering line puts $pipe { - fconfigure stdout -translation binary -buffering line + chan configure stdout -translation binary -buffering line puts stderr Waiting... after 1000 foreach x {a b c} { @@ -7096,7 +7092,7 @@ test io-53.9 {CopyData: -size and event interaction, Bug 780533} -setup { } } puts stderr Now-sleeping-forever - fileevent stdin readable bye + chan event stdin readable bye vwait forever } proc ::done args { @@ -7106,9 +7102,9 @@ test io-53.9 {CopyData: -size and event interaction, Bug 780533} -setup { set ::forever {} set out [open $out w] } -constraints {stdio openpipe fcopy} -body { - fcopy $pipe $out -size 6 -command ::done + chan copy $pipe $out -size 6 -command ::done set token [after 5000 { - set ::forever {fcopy hangs} + set ::forever {chan copy hangs} }] vwait ::forever catch {after cancel $token} @@ -7120,14 +7116,14 @@ test io-53.9 {CopyData: -size and event interaction, Bug 780533} -setup { catch {close $out} catch {removeFile out} catch {removeFile err} - catch {unset ::forever} + unset -nocomplain ::forever } -result OK -test io-53.10 {Bug 1350564, multi-directional fcopy} -setup { +test io-53.10 {Bug 1350564, multi-directional chan copy} -setup { set err [makeFile {} err] set pipe [open "|[list [info nameofexecutable] 2> $err]" r+] - fconfigure $pipe -translation binary -buffering line + chan configure $pipe -translation binary -buffering line puts $pipe { - fconfigure stderr -buffering line + chan configure stderr -buffering line # Kill server when pipe closed by invoker. proc bye args { if {![eof stdin]} { gets stdin ; return } @@ -7142,13 +7138,13 @@ test io-53.10 {Bug 1350564, multi-directional fcopy} -setup { proc new {sok args} { puts stderr NEW/$sok global l srv - fconfigure $sok -translation binary -buffering none + chan configure $sok -translation binary -buffering none lappend l $sok - if {[llength $l]==2} { + if {[llength $l] == 2} { close $srv - foreach {a b} $l break - fcopy $a $b -command [list geof $a] - fcopy $b $a -command [list geof $b] + lassign $l a b + chan copy $a $b -command [list geof $a] + chan copy $b $a -command [list geof $b] puts stderr 2COPY } puts stderr ... @@ -7157,7 +7153,7 @@ test io-53.10 {Bug 1350564, multi-directional fcopy} -setup { set l {} set srv [socket -server new 9999] puts stderr WAITING - fileevent stdin readable bye + chan event stdin readable bye puts OK vwait forever } @@ -7171,10 +7167,10 @@ test io-53.10 {Bug 1350564, multi-directional fcopy} -setup { } set a [socket 127.0.0.1 9999] set b [socket 127.0.0.1 9999] - fconfigure $a -translation binary -buffering none - fconfigure $b -translation binary -buffering none - fileevent $a readable [list ::done $a] - fileevent $b readable [list ::done $b] + chan configure $a -translation binary -buffering none + chan configure $b -translation binary -buffering none + chan event $a readable [list ::done $a] + chan event $b readable [list ::done $b] } -constraints {stdio openpipe fcopy} -body { # Now pass data through the server in both directions. set ::forever {} @@ -7190,19 +7186,19 @@ test io-53.10 {Bug 1350564, multi-directional fcopy} -setup { rename ::done {} after 1000 ;# Give Windows time to kill the process removeFile err - catch {unset ::forever} + unset -nocomplain ::forever } -result {AB BA} test io-53.11 {Bug 2895565} -setup { set in [makeFile {} in] set f [open $in w] - fconfigure $f -encoding utf-8 -translation binary + chan configure $f -encoding utf-8 -translation binary puts -nonewline $f [string repeat "Ho hum\n" 11] close $f set inChan [open $in r] - fconfigure $inChan -translation binary + chan configure $inChan -translation binary set out [makeFile {} out] set outChan [open $out w] - fconfigure $outChan -encoding cp1252 -translation crlf + chan configure $outChan -encoding cp1252 -translation crlf proc CopyDone {bytes args} { variable done if {[llength $args]} { @@ -7214,7 +7210,7 @@ test io-53.11 {Bug 2895565} -setup { } -body { variable done after 2000 [list set [namespace which -variable done] timeout] - fcopy $inChan $outChan -size 40 -command [namespace which CopyDone] + chan copy $inChan $outChan -size 40 -command [namespace which CopyDone] vwait [namespace which -variable done] set done } -cleanup { @@ -7230,7 +7226,7 @@ test io-54.1 {Recursive channel events} {socket fileevent} { proc accept {s a p} { variable as - fconfigure $s -translation lf + chan configure $s -translation lf puts $s "line 1\nline2\nline3" flush $s set as $s @@ -7240,7 +7236,7 @@ test io-54.1 {Recursive channel events} {socket fileevent} { variable result lappend result $next if {$next == 1} { - fileevent $s readable [namespace code [list readit $s 2]] + chan event $s readable [namespace code [list readit $s 2]] vwait [namespace which -variable x] } incr x @@ -7252,7 +7248,7 @@ test io-54.1 {Recursive channel events} {socket fileevent} { set done 0 for {set i 0} {$i < 10} {incr i} { - if {![catch {set cs [socket 127.0.0.1 [lindex [fconfigure $ss -sockname] 2]]}]} { + if {![catch {set cs [socket 127.0.0.1 [lindex [chan configure $ss -sockname] 2]]}]} { set done 1 break } @@ -7266,10 +7262,10 @@ test io-54.1 {Recursive channel events} {socket fileevent} { variable x 0 variable as vwait [namespace which -variable as] - fconfigure $cs -translation lf + chan configure $cs -translation lf lappend result [gets $cs] - fconfigure $cs -blocking off - fileevent $cs readable [namespace code [list readit $cs 1]] + chan configure $cs -blocking off + chan event $cs readable [namespace code [list readit $cs 1]] set a [after 2000 [namespace code { set x failure }]] vwait [namespace which -variable x] after cancel $a @@ -7288,8 +7284,8 @@ test io-54.2 {Testing for busy-wait in recursive channel events} {socket fileeve set accept $s set counter 0 - fconfigure $s -blocking off -buffering line -translation lf - fileevent $s readable [namespace code "doit $s"] + chan configure $s -blocking off -buffering line -translation lf + chan event $s readable [namespace code "doit $s"] } proc doit {s} { variable counter @@ -7297,8 +7293,8 @@ test io-54.2 {Testing for busy-wait in recursive channel events} {socket fileeve incr counter set l [gets $s] - if {"$l" == ""} { - fileevent $s readable [namespace code "doit1 $s"] + if {$l eq ""} { + chan event $s readable [namespace code "doit1 $s"] set after [after 1000 [namespace code newline]] } } @@ -7309,14 +7305,14 @@ test io-54.2 {Testing for busy-wait in recursive channel events} {socket fileeve incr counter set l [gets $s] close $s - set accept {} + set accept "" } proc producer {} { variable s variable writer - set writer [socket 127.0.0.1 [lindex [fconfigure $s -sockname] 2]] - fconfigure $writer -buffering line + set writer [socket 127.0.0.1 [lindex [chan configure $s -sockname] 2]] + chan configure $writer -buffering line puts -nonewline $writer hello flush $writer } @@ -7357,7 +7353,7 @@ test io-55.1 {ChannelEventScriptInvoker: deletion} -constraints { interp bgerror {} [namespace which myHandler] } -body { set f [open $path(fooBar) w] - fileevent $f writable [namespace code [list eventScript $f]] + chan event $f writable [namespace code [list eventScript $f]] variable x not_done vwait [namespace which -variable x] set x @@ -7392,11 +7388,11 @@ test io-57.1 {buffered data and file events, gets} {fileevent} { set s2 $sock } set server [socket -server [namespace code accept] -myaddr 127.0.0.1 0] - set s [socket 127.0.0.1 [lindex [fconfigure $server -sockname] 2]] + set s [socket 127.0.0.1 [lindex [chan configure $server -sockname] 2]] variable s2 vwait [namespace which -variable s2] update - fileevent $s2 readable [namespace code {lappend result readable}] + chan event $s2 readable [namespace code {lappend result readable}] puts $s "12\n34567890" flush $s variable result [gets $s2] @@ -7415,11 +7411,11 @@ test io-57.2 {buffered data and file events, read} {fileevent} { set s2 $sock } set server [socket -server [namespace code accept] -myaddr 127.0.0.1 0] - set s [socket 127.0.0.1 [lindex [fconfigure $server -sockname] 2]] + set s [socket 127.0.0.1 [lindex [chan configure $server -sockname] 2]] variable s2 vwait [namespace which -variable s2] update - fileevent $s2 readable [namespace code {lappend result readable}] + chan event $s2 readable [namespace code {lappend result readable}] puts -nonewline $s "1234567890" flush $s variable result [read $s2 1] @@ -7453,7 +7449,7 @@ test io-58.1 {Tcl_NotifyChannel and error when closing} {stdio unixOrPc openpipe } close $out set pipe [open "|[list [interpreter] $path(script)]" r] - fileevent $pipe readable [namespace code [list readit $pipe]] + chan event $pipe readable [namespace code [list readit $pipe]] variable x "" set result "" vwait [namespace which -variable x] @@ -7494,7 +7490,7 @@ test io-60.1 {writing illegal utf sequences} {openpipe fileevent} { } close $out set pipe [open "|[list [interpreter] $path(script)]" r] - fileevent $pipe readable [namespace code [list readit $pipe]] + chan event $pipe readable [namespace code [list readit $pipe]] variable x "" set result "" vwait [namespace which -variable x] @@ -7507,7 +7503,7 @@ test io-60.1 {writing illegal utf sequences} {openpipe fileevent} { test io-61.1 {Reset eof state after changing the eof char} -setup { set datafile [makeFile {} eofchar] set f [open $datafile w] - fconfigure $f -translation binary + chan configure $f -translation binary puts -nonewline $f [string repeat "Ho hum\n" 11] puts $f = set line [string repeat "Ge gla " 4] @@ -7515,10 +7511,10 @@ test io-61.1 {Reset eof state after changing the eof char} -setup { close $f } -body { set f [open $datafile r] - fconfigure $f -eofchar = + chan configure $f -eofchar = set res {} lappend res [read $f; tell $f] - fconfigure $f -eofchar {} + chan configure $f -eofchar {} lappend res [read $f 1] lappend res [read $f; tell $f] # Any seek zaps the internals into a good state. @@ -7556,12 +7552,11 @@ test io-70.0 {Cutting & Splicing channels} {testchannel} { set res } {0 1 0} - test io-70.1 {Transfer channel} {testchannel thread} { set f [makeFile {... dummy ...} cutsplice] set c [open $f r] - set res {} + set res [list] lappend res [catch {seek $c 0 start}] testchannel cut $c lappend res [catch {seek $c 0 start}] |