diff options
author | dgp <dgp@users.sourceforge.net> | 2014-06-05 15:17:29 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2014-06-05 15:17:29 (GMT) |
commit | 3eb959fc935f4f1a92c7527be675245c0def5dfd (patch) | |
tree | ac34e58ae45bc9c662b94326b71d2b603b0c753d /tests/io.test | |
parent | 3189f48d19ee5fe595f856ca7d755f61414cfbef (diff) | |
download | tcl-3eb959fc935f4f1a92c7527be675245c0def5dfd.zip tcl-3eb959fc935f4f1a92c7527be675245c0def5dfd.tar.gz tcl-3eb959fc935f4f1a92c7527be675245c0def5dfd.tar.bz2 |
When too many chars are read by ReadChars() and we trim the limits to
get it right on the next pass, don't forget the TCL_UTF_MAX padding
demanded by Tcl_ExternalToUtf(). (Thanks for finding that, aku!)
Fix the factorPtr management. It was just totaly wrong. The factor should
be a ratio of the record of bytes read to the record of chars read.
With those fixes, new test io-12.6 covers the "too many chars" code.
Diffstat (limited to 'tests/io.test')
-rw-r--r-- | tests/io.test | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/io.test b/tests/io.test index f1248b9..a1625ba 100644 --- a/tests/io.test +++ b/tests/io.test @@ -1445,6 +1445,39 @@ test io-12.5 {ReadChars: fileevents on partial characters} {stdio openpipe filee lappend x [catch {close $f} msg] $msg set x } "{} timeout {} timeout \u7266 {} eof 0 {}" +test io-12.6 {ReadChars: too many chars read} { + proc driver {cmd args} { + variable buffer + variable index + set chan [lindex $args 0] + switch -- $cmd { + initialize { + set index($chan) 0 + set buffer($chan) [encoding convertto utf-8 \ + [string repeat \uBEEF 20][string repeat . 20]] + return {initialize finalize watch read} + } + finalize { + unset index($chan) buffer($chan) + return + } + watch {} + read { + set n [lindex $args 1] + set new [expr {$index($chan) + $n}] + set result [string range $buffer($chan) $index($chan) $new-1] + set index($chan) $new + return $result + } + } + } + set c [chan create read [namespace which driver]] + chan configure $c -encoding utf-8 + while {![eof $c]} { + read $c 15 + } + close $c +} {} test io-13.1 {TranslateInputEOL: cr mode} {} { set f [open $path(test1) w] |