aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authornoname <noname@inventati.org>2014-04-23 00:26:07 +0400
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2014-04-23 20:31:45 +0200
commitf9dc374ea01c2921ec3bd1214f292a7036d069ae (patch)
tree55e08f8425b5b1108d9454b845182e3207383f98 /st.c
parentfa19f241a34deddf6e089ab462cbd9cb02f61b3d (diff)
downloadst-f9dc374ea01c2921ec3bd1214f292a7036d069ae.tar.gz
st-f9dc374ea01c2921ec3bd1214f292a7036d069ae.zip
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 (limited to 'st.c')
-rw-r--r--st.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/st.c b/st.c
index aba034f..b66791a 100644
--- a/st.c
+++ b/st.c
@@ -2308,9 +2308,9 @@ techo(char *buf, int len) {
2308 for(; len > 0; buf++, len--) { 2308 for(; len > 0; buf++, len--) {
2309 char c = *buf; 2309 char c = *buf;
2310 2310
2311 if(c < '\x20') { /* control code */ 2311 if(c < 0x20 || c == 0177) { /* control code */
2312 if(c != '\n' && c != '\r' && c != '\t') { 2312 if(c != '\n' && c != '\r' && c != '\t') {
2313 c |= '\x40'; 2313 c ^= '\x40';
2314 tputc("^", 1); 2314 tputc("^", 1);
2315 } 2315 }
2316 tputc(&c, 1); 2316 tputc(&c, 1);