scc

suckless C compiler
git clone git://git.suckless.org/scc
Log | Files | Refs | README | LICENSE

commit bf1bd2628aecda8c84a777936d3531bc8292d22b
parent 4fff993de65740c25530b94a9f75d7b951f13f73
Author: Quentin Rameau <quinq@fifth.space>
Date:   Thu,  2 Mar 2017 15:11:17 +0100

[libc] Fix isblank

Obviously adding _TP was too much for a char, the solution is to have
isblank as a function only.

Diffstat:
libc/include/ctype.h | 2--
libc/src/ctype.c | 2+-
libc/src/isblank.c | 6+-----
3 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/libc/include/ctype.h b/libc/include/ctype.h @@ -27,13 +27,11 @@ extern int toupper(int c); #define _S 0x20 /* white space (space/lf/tab) */ #define _X 0x40 /* hex char */ #define _SP 0x80 /* hard space (0x20) */ -#define _TB 0x100 /* tabulation */ extern unsigned char _ctype[]; #define isalnum(c) (_ctype[(unsigned char) c] & (_U|_L|_D)) #define isalpha(c) (_ctype[(unsigned char) c] & (_U|_L)) -#define isblank(c) (_ctype[(unsigned char) c] & (_SP|_TB)) #define iscntrl(c) (_ctype[(unsigned char) c] & (_C)) #define isdigit(c) (_ctype[(unsigned char) c] & (_D)) #define isgraph(c) (_ctype[(unsigned char) c] & (_P|_U|_L|_D)) diff --git a/libc/src/ctype.c b/libc/src/ctype.c @@ -5,7 +5,7 @@ unsigned char _ctype[255] = { _C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */ - _C,_C|_S|_TB,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */ + _C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */ _C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */ _C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */ _S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */ diff --git a/libc/src/isblank.c b/libc/src/isblank.c @@ -1,11 +1,7 @@ /* See LICENSE file for copyright and license details. */ -#define __USE_MACROS -#include <ctype.h> -#undef isblank - int isblank(int c) { - return _ctype[(unsigned char) c] & (_SP|_TB); + return (c == ' ') || (c == '\t'); }