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.
dev
Roberto E. Vargas Caballero 2014-08-15 14:48:16 +02:00
parent d4a17316d3
commit 6530025bca
1 changed files with 2 additions and 2 deletions

4
st.c
View File

@ -2311,13 +2311,13 @@ techo(char *buf, int len) {
for(; len > 0; buf++, len--) { for(; len > 0; buf++, len--) {
char c = *buf; char c = *buf;
if(ISCONTROL(c)) { /* control code */ if(ISCONTROL((uchar) c)) { /* control code */
if(c & 0x80) { if(c & 0x80) {
c &= 0x7f; c &= 0x7f;
tputc("^", 1); tputc("^", 1);
tputc("[", 1); tputc("[", 1);
} else if(c != '\n' && c != '\r' && c != '\t') { } else if(c != '\n' && c != '\r' && c != '\t') {
c ^= '\x40'; c ^= 0x40;
tputc("^", 1); tputc("^", 1);
} }
tputc(&c, 1); tputc(&c, 1);