summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorandreas_kupries <akupries@shaw.ca>2007-02-12 19:25:39 (GMT)
committerandreas_kupries <akupries@shaw.ca>2007-02-12 19:25:39 (GMT)
commit8dc5bc8beb82143f5ea0bc0bbdd609a699cf46c6 (patch)
treeae387602def649b2b3678c1bbbd5900c5a27b068 /tests
parentbaa5c737e07f4e6a6b343b7fe731da0ae38fdacc (diff)
downloadtcl-8dc5bc8beb82143f5ea0bc0bbdd609a699cf46c6.zip
tcl-8dc5bc8beb82143f5ea0bc0bbdd609a699cf46c6.tar.gz
tcl-8dc5bc8beb82143f5ea0bc0bbdd609a699cf46c6.tar.bz2
* generic/tclEncoding.c (EscapeFromUtfProc): Applied patch
supplied by Mo DeJong to fix [Bug 1516109]. Backport from Tcl 8.5. Mo's description: Clear the TCL_ENCODING_END flag when end bytes are written. This fix keep this method from writing escape bytes for an encoding like iso2022-jp multiple times when the escape byte overlap with the end of the IO buffer. * tests/io.test: Add test case for escape byte overlap case.
Diffstat (limited to 'tests')
-rw-r--r--tests/io.test62
1 files changed, 61 insertions, 1 deletions
diff --git a/tests/io.test b/tests/io.test
index 4e782f7..85fe437 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -13,7 +13,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: io.test,v 1.40.2.11 2006/03/16 19:12:32 andreas_kupries Exp $
+# RCS: @(#) $Id: io.test,v 1.40.2.12 2007/02/12 19:25:42 andreas_kupries Exp $
if {[catch {package require tcltest 2}]} {
puts stderr "Skipping tests in [info script]. tcltest 2 required."
@@ -117,6 +117,66 @@ test io-1.8 {Tcl_WriteChars: WriteChars} {
contents $path(test2)
} " \x1b\$B\$O\x1b(B"
+test io-1.9 {Tcl_WriteChars: WriteChars} {
+ # When closing a channel with an encoding that appends
+ # escape bytes, check for the case where the escape
+ # bytes overflow the current IO buffer. The bytes
+ # should be moved into a new buffer.
+
+ set data "1234567890 [format %c 12399]"
+
+ set sizes [list]
+
+ # With default buffer size
+ set f [open $path(test2) w]
+ fconfigure $f -encoding iso2022-jp
+ puts -nonewline $f $data
+ close $f
+ lappend sizes [file size $path(test2)]
+
+ # With buffer size equal to the length
+ # of the data, the escape bytes would
+ # go into the next buffer.
+
+ set f [open $path(test2) w]
+ fconfigure $f -encoding iso2022-jp -buffersize 16
+ puts -nonewline $f $data
+ close $f
+ lappend sizes [file size $path(test2)]
+
+ # With buffer size that is large enough
+ # to hold 1 byte of escaped data, but
+ # not all 3. This should not write
+ # the escape bytes to the first buffer
+ # and then again to the second buffer.
+
+ set f [open $path(test2) w]
+ fconfigure $f -encoding iso2022-jp -buffersize 17
+ puts -nonewline $f $data
+ close $f
+ lappend sizes [file size $path(test2)]
+
+ # With buffer size that can hold 2 out of
+ # 3 bytes of escaped data.
+
+ set f [open $path(test2) w]
+ fconfigure $f -encoding iso2022-jp -buffersize 18
+ puts -nonewline $f $data
+ close $f
+ lappend sizes [file size $path(test2)]
+
+ # With buffer size that can hold all the
+ # data and escape bytes.
+
+ set f [open $path(test2) w]
+ fconfigure $f -encoding iso2022-jp -buffersize 19
+ puts -nonewline $f $data
+ close $f
+ lappend sizes [file size $path(test2)]
+
+ set sizes
+} {19 19 19 19 19}
+
test io-2.1 {WriteBytes} {
# loop until all bytes are written