diff options
| author | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2014-08-15 14:48:16 +0200 |
|---|---|---|
| committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2014-08-15 14:48:16 +0200 |
| commit | 6530025bcaf3a65083667a93ae50035bd7137bae (patch) | |
| tree | f0cef72fd0b335c8f36939aac3c03b812c668975 | |
| parent | d4a17316d33f3c5a0017d7fe6e7e174883ccaa97 (diff) | |
| download | st-6530025bcaf3a65083667a93ae50035bd7137bae.tar.gz st-6530025bcaf3a65083667a93ae50035bd7137bae.zip | |
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.
| -rw-r--r-- | st.c | 4 |
1 files changed, 2 insertions, 2 deletions
| @@ -2311,13 +2311,13 @@ techo(char *buf, int len) { | |||
| 2311 | for(; len > 0; buf++, len--) { | 2311 | for(; len > 0; buf++, len--) { |
| 2312 | char c = *buf; | 2312 | char c = *buf; |
| 2313 | 2313 | ||
| 2314 | if(ISCONTROL(c)) { /* control code */ | 2314 | if(ISCONTROL((uchar) c)) { /* control code */ |
| 2315 | if(c & 0x80) { | 2315 | if(c & 0x80) { |
| 2316 | c &= 0x7f; | 2316 | c &= 0x7f; |
| 2317 | tputc("^", 1); | 2317 | tputc("^", 1); |
| 2318 | tputc("[", 1); | 2318 | tputc("[", 1); |
| 2319 | } else if(c != '\n' && c != '\r' && c != '\t') { | 2319 | } else if(c != '\n' && c != '\r' && c != '\t') { |
| 2320 | c ^= '\x40'; | 2320 | c ^= 0x40; |
| 2321 | tputc("^", 1); | 2321 | tputc("^", 1); |
| 2322 | } | 2322 | } |
| 2323 | tputc(&c, 1); | 2323 | tputc(&c, 1); |
