summaryrefslogtreecommitdiffstats
path: root/linenoise
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-02-05 08:10:17 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-02-05 08:10:17 -0800
commit5df2f8a4c30866e140b609733b79eb3832b5bd37 (patch)
treec25c70094ecbfc2bc95d00bbe78df289d93e58cc /linenoise
parent2bc4df81e615f31a3ae8e8e81a439ce66d176c3e (diff)
downloadtxr-5df2f8a4c30866e140b609733b79eb3832b5bd37.tar.gz
txr-5df2f8a4c30866e140b609733b79eb3832b5bd37.tar.bz2
txr-5df2f8a4c30866e140b609733b79eb3832b5bd37.zip
linenoise: bugfix: caret notation for NUL.
* linenoise/linenoise.c (sync_data_to_buf): The null character appears from the stream as 0xDC00. We must test for that and render it as ^@, counting a a width of two, rather than sending it to the terminal, counting as width of 1.
Diffstat (limited to 'linenoise')
-rw-r--r--linenoise/linenoise.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c
index 49b1faec..f409c98f 100644
--- a/linenoise/linenoise.c
+++ b/linenoise/linenoise.c
@@ -976,9 +976,9 @@ static void sync_data_to_buf(lino_t *l)
*bptr++ = '\r';
*bptr++ = '\n';
col = 0;
- } else if (ch < ' ') {
+ } else if (ch < ' ' || ch == 0xDC00) {
*bptr++ = '^';
- *bptr++ = '@' + ch;
+ *bptr++ = '@' + (ch & 0xff);
col += 2;
} else if (ch == 127) {
*bptr++ = '^';