commit 0f98deff32570e2c79e77dad7344298253b15db9
Author:     Quentin Rameau <[email protected]>
AuthorDate: Sat Feb 18 14:42:42 2017 +0100
Commit:     Quentin Rameau <[email protected]>
CommitDate: Sat Feb 18 18:38:48 2017 +0100

    [libc] Add isblank

diff --git a/libc/include/ctype.h b/libc/include/ctype.h
index e7b9d83..ef9cc06 100644
--- a/libc/include/ctype.h
+++ b/libc/include/ctype.h
@@ -17,7 +17,7 @@ extern int ispunct(int c);
 extern int tolower(int c);
 extern int toupper(int c);
 
-#ifdef __USE_MACROS 
+#ifdef __USE_MACROS
 
 #define _U     0x01    /* upper */
 #define _L     0x02    /* lower */
@@ -25,13 +25,15 @@ extern int toupper(int c);
 #define _C     0x08    /* cntrl */
 #define _P     0x10    /* punct */
 #define _S     0x20    /* white space (space/lf/tab) */
-#define _X     0x40    /* hex digit */
+#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))
@@ -46,5 +48,4 @@ extern unsigned char _ctype[];
 
 #endif
 
-
 #endif
diff --git a/libc/src/Makefile b/libc/src/Makefile
index a156e60..555d4cb 100644
--- a/libc/src/Makefile
+++ b/libc/src/Makefile
@@ -4,10 +4,9 @@
 LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o \
           strrchr.o strcat.o strncpy.o strncat.o strcoll.o \
           memset.o memcpy.o memmove.o memcmp.o memchr.o \
-          isalnum.o isalpha.o isascii.o iscntrl.o isdigit.o isgraph.o \
-          islower.o isprint.o ispunct.o isspace.o isupper.o isxdigit.o \
-          toupper.o tolower.o \
-          setlocale.o
+          isalnum.o isalpha.o isascii.o isblank.o iscntrl.o isdigit.o \
+          isgraph.o islower.o isprint.o ispunct.o isspace.o isupper.o \
+          isxdigit.o toupper.o tolower.o setlocale.o
 
 all: libc.a
 
diff --git a/libc/src/ctype.c b/libc/src/ctype.c
index 2ee3e94..b45d51c 100644
--- a/libc/src/ctype.c
+++ b/libc/src/ctype.c
@@ -1,9 +1,8 @@
-
 #include <ctype.h>
 
 unsigned char _ctype[255] = {
        _C,_C,_C,_C,_C,_C,_C,_C,                        /* 0-7 */
-       _C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C,         /* 8-15 */
+       _C,_C|_S|_TB,_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
new file mode 100644
index 0000000..9247201
--- /dev/null
+++ b/libc/src/isblank.c
@@ -0,0 +1,11 @@
+/* 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);
+}

Reply via email to