summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-03-13 01:11:02 -0700
committerKaz Kylheku <kaz@kylheku.com>2012-03-13 01:11:02 -0700
commitaa62864118b755f10b30fd58a3b7fd8407ce8c6c (patch)
tree99cc198b03dec38dcc8f7d38577ae014fdd3806c /tests
parent502ec6b0929f31fa60e3c8ecea36338ffcea207c (diff)
downloadtxr-aa62864118b755f10b30fd58a3b7fd8407ce8c6c.tar.gz
txr-aa62864118b755f10b30fd58a3b7fd8407ce8c6c.tar.bz2
txr-aa62864118b755f10b30fd58a3b7fd8407ce8c6c.zip
* stream.c (string_out_byte_flush): Bugfix. Do not loop inside this
function. This must not flush out more than one character out of this small buffer, except when we are flushing out the last data. The correct operation is predicated on the assumption that a complete character can be pulled out. That's why we move the buffer to the front after consuming it, and do not automatically flush until there are four bytes. (string_out_put_string): We loop the call to string_out_byte_flush here because when a request comes in to write a Unicode character, we flush all the bytes, even if the tail of those bytes forms an incomplete sequence that turns into U+DCxx codes. (get_string_from_stream): Use the same loop termination test as in string_out_put_string, for consistency. In that function it is needed to prevent infinite looping in the case when the string_out_put_string is being called from string_out_byte_flush and is thus re-entering it. * tests/010/strstream.expected: New file. * tests/010/strstream.txr: New file.
Diffstat (limited to 'tests')
-rw-r--r--tests/010/strstream.expected1
-rw-r--r--tests/010/strstream.txr11
2 files changed, 12 insertions, 0 deletions
diff --git a/tests/010/strstream.expected b/tests/010/strstream.expected
new file mode 100644
index 00000000..7e9cc628
--- /dev/null
+++ b/tests/010/strstream.expected
@@ -0,0 +1 @@
+"春が来た (Haru-ga Kita/Spring has Come)"
diff --git a/tests/010/strstream.txr b/tests/010/strstream.txr
new file mode 100644
index 00000000..5800172e
--- /dev/null
+++ b/tests/010/strstream.txr
@@ -0,0 +1,11 @@
+@(do
+ (defun lazy-byte-stream (s)
+ (let (ch) (gen (set ch (get-byte s)) ch)))
+
+ (let* ((data "春が来た (Haru-ga Kita/Spring has Come)")
+ (in-byte (make-string-byte-input-stream data))
+ (out-byte (make-string-output-stream)))
+ (each ((b (lazy-byte-stream in-byte)))
+ (put-byte b out-byte))
+ (print (get-string-from-stream out-byte))
+ (pprint "\n")))