Fix techo handling of control and multibyte characters. - st - simple terminal (HTM) git clone https://git.parazyd.org/st (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit f9dc374ea01c2921ec3bd1214f292a7036d069ae (DIR) parent fa19f241a34deddf6e089ab462cbd9cb02f61b3d (HTM) Author: noname <noname@inventati.org> Date: Wed, 23 Apr 2014 00:26:07 +0400 Fix techo handling of control and multibyte characters. techo compares signed char to '\x20'. Any character with code less then '\x20' is treated as control character. This way characters with MSB set to 1 are considered control characters too. Also this patch makes techo display DEL character as ^?. To reprocuce the bug, enable echo mode using printf '\e[12l', then type DEL character or any non-ASCII character. Diffstat: M st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- (DIR) diff --git a/st.c b/st.c @@ -2308,9 +2308,9 @@ techo(char *buf, int len) { for(; len > 0; buf++, len--) { char c = *buf; - if(c < '\x20') { /* control code */ + if(c < 0x20 || c == 0177) { /* control code */ if(c != '\n' && c != '\r' && c != '\t') { - c |= '\x40'; + c ^= '\x40'; tputc("^", 1); } tputc(&c, 1);