mirror of
https://github.com/LukeSmithxyz/st.git
synced 2024-11-25 08:25:47 +01:00
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.
This commit is contained in:
parent
fa19f241a3
commit
f9dc374ea0
1 changed files with 2 additions and 2 deletions
4
st.c
4
st.c
|
@ -2308,9 +2308,9 @@ techo(char *buf, int len) {
|
||||||
for(; len > 0; buf++, len--) {
|
for(; len > 0; buf++, len--) {
|
||||||
char c = *buf;
|
char c = *buf;
|
||||||
|
|
||||||
if(c < '\x20') { /* control code */
|
if(c < 0x20 || c == 0177) { /* control code */
|
||||||
if(c != '\n' && c != '\r' && c != '\t') {
|
if(c != '\n' && c != '\r' && c != '\t') {
|
||||||
c |= '\x40';
|
c ^= '\x40';
|
||||||
tputc("^", 1);
|
tputc("^", 1);
|
||||||
}
|
}
|
||||||
tputc(&c, 1);
|
tputc(&c, 1);
|
||||||
|
|
Loading…
Reference in a new issue