From 5df2f8a4c30866e140b609733b79eb3832b5bd37 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 5 Feb 2019 08:10:17 -0800 Subject: 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. --- linenoise/linenoise.c | 4 ++-- 1 file 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++ = '^'; -- cgit v1.2.3