[hackers] [st] Fix techo handling of control and multibyte characters. || noname

From: <git_AT_suckless.org>
Date: Wed, 23 Apr 2014 20:25:43 +0200

commit 53c494b23f4cefdb19b23cde34f3304f2a2e5cd0
Author: noname <noname_AT_inventati.org>
Date: Wed Apr 23 00:26:07 2014 +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.

diff --git a/st.c b/st.c
index aba034f..c091f72 100644
--- a/st.c
+++ b/st.c
_AT_@ -2306,11 +2306,11 @@ tputtab(bool forward) {
 void
 techo(char *buf, int len) {
         for(; len > 0; buf++, len--) {
- char c = *buf;
+ uchar c = *buf;
 
- if(c < '\x20') { /* control code */
+ if(c < 0x20 || c == 0177) { /* control code */
                         if(c != '
' && c != ' ' && c != ' ') {
- c |= '\x40';
+ c ^= '\x40';
                                 tputc("^", 1);
                         }
                         tputc(&c, 1);
Received on Wed Apr 23 2014 - 20:25:43 CEST

This archive was generated by hypermail 2.3.0 : Wed Apr 23 2014 - 20:36:15 CEST