summaryrefslogtreecommitdiffstats
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
commit189cb7c58619d1897190e8da4e8d9e3652d8c3f6 (patch)
treec25c70094ecbfc2bc95d00bbe78df289d93e58cc
parente467d124fafee8acf3321a2a9808cb200c1c172e (diff)
downloadtxr-189cb7c58619d1897190e8da4e8d9e3652d8c3f6.tar.gz
txr-189cb7c58619d1897190e8da4e8d9e3652d8c3f6.tar.bz2
txr-189cb7c58619d1897190e8da4e8d9e3652d8c3f6.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.
-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++ = '^';