[hackers] [st] Fix portability problem in techo() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 15 Aug 2014 14:53:07 +0200

commit 6530025bcaf3a65083667a93ae50035bd7137bae
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Fri Aug 15 14:48:16 2014 +0200

    Fix portability problem in techo()
    
    ISCONTROL chechks if a value is between 0 and 0x1f or
    between 0x80 and 0x9f. Char signess depends of architecture
    and compiler, so in some environment the second case is
    always false (and wrong), Techo() calls ISCONTROL with a
    char variable, whose type cannot be changed because tpuc()
    expects a pointer to char, so the solution is to insert a
    cast in the call to ISCONTROL.

diff --git a/st.c b/st.c
index 814f3f5..d8ff30b 100644
--- a/st.c
+++ b/st.c
_AT_@ -2311,13 +2311,13 @@ techo(char *buf, int len) {
         for(; len > 0; buf++, len--) {
                 char c = *buf;
 
- if(ISCONTROL(c)) { /* control code */
+ if(ISCONTROL((uchar) c)) { /* control code */
                         if(c & 0x80) {
                                 c &= 0x7f;
                                 tputc("^", 1);
                                 tputc("[", 1);
                         } else if(c != '
' && c != ' ' && c != ' ') {
- c ^= '\x40';
+ c ^= 0x40;
                                 tputc("^", 1);
                         }
                         tputc(&c, 1);
Received on Fri Aug 15 2014 - 14:53:07 CEST

This archive was generated by hypermail 2.3.0 : Fri Aug 15 2014 - 15:00:14 CEST