[hackers] [scc] [libc] Fix isblank || Quentin Rameau

From: <git_AT_suckless.org>
Date: Thu, 2 Mar 2017 15:23:32 +0100 (CET)

commit bf1bd2628aecda8c84a777936d3531bc8292d22b
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Thu Mar 2 15:11:17 2017 +0100
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Thu Mar 2 15:15:54 2017 +0100

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

diff --git a/libc/include/ctype.h b/libc/include/ctype.h
index ef9cc06..1a8bd6e 100644
--- a/libc/include/ctype.h
+++ b/libc/include/ctype.h
_AT_@ -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
index a4b7846..aca14bc 100644
--- a/libc/src/ctype.c
+++ b/libc/src/ctype.c
_AT_@ -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
index 9247201..2db5bd3 100644
--- a/libc/src/isblank.c
+++ b/libc/src/isblank.c
_AT_@ -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');
 }
Received on Thu Mar 02 2017 - 15:23:32 CET

This archive was generated by hypermail 2.3.0 : Thu Mar 02 2017 - 15:24:19 CET