Browse Source

Support isblank()

Eric Andersen 23 years ago
parent
commit
e306be411d
4 changed files with 23 additions and 3 deletions
  1. 2 0
      include/ctype.h
  2. 1 1
      libc/misc/ctype/Makefile
  3. 18 0
      libc/misc/ctype/ctype.c
  4. 2 2
      libc/misc/ctype/ctype_C.c

+ 2 - 0
include/ctype.h

@@ -34,6 +34,7 @@ __BEGIN_DECLS
 extern int isalnum(int c);
 extern int isalpha(int c);
 extern int isascii(int c);
+extern int isblank(int c);
 extern int iscntrl(int c);
 extern int isdigit(int c);
 extern int isgraph(int c);
@@ -57,6 +58,7 @@ extern int toupper(int c);
 #define isalnum(c)  (isalpha(c) || isdigit(c))
 #define isalpha(c)  (isupper(c) || islower(c))
 #define isascii(c)  (c > 0 && c <= 0x7f)
+#define isblank(c)  (c == ' ' || c == '\t')
 #define iscntrl(c)  ((c >= 0) && ((c <= 0x1F) || (c == 0x7f)))
 #define isdigit(c)  (c >= '0' && c <= '9')
 #define isgraph(c)  (c != ' ' && isprint(c))

+ 1 - 1
libc/misc/ctype/Makefile

@@ -27,7 +27,7 @@ include $(TOPDIR)Rules.mak
 MSRC=ctype.c
 MOBJ= isalnum.o isalpha.o isascii.o iscntrl.o isdigit.o isgraph.o \
 	islower.o isprint.o ispunct.o isspace.o isupper.o isxdigit.o \
-	isxlower.o isxupper.o toascii.o tolower.o toupper.o
+	isxlower.o isxupper.o toascii.o tolower.o toupper.o isblank.o
 
 ifeq ($(HAS_LOCALE),true)
 	MOBJ += ctype_C.o

+ 18 - 0
libc/misc/ctype/ctype.c

@@ -118,6 +118,15 @@ isspace( int c )
 }
 #endif
 
+#ifdef L_isblank
+#undef isblank
+int
+isblank( int c )
+{
+    return (c == ' ' || c == '\t');
+}
+#endif
+
 #ifdef L_isupper
 #undef isupper
 int
@@ -266,6 +275,15 @@ isspace( int c )
 }
 #endif
 
+#ifdef L_isblank
+#undef isblank
+int
+isblank( int c )
+{
+    return _UC_ISCTYPE(c, ISblank);
+}
+#endif
+
 #ifdef L_isupper
 #undef isupper
 int

+ 2 - 2
libc/misc/ctype/ctype_C.c

@@ -8,7 +8,7 @@ const unsigned char _uc_ctype_b_C[LOCALE_BUF_SIZE] = {
 	/* 0x06, 6, 06 */	IScntrl,
 	/* 0x07, 7, 07 */	IScntrl,
 	/* 0x08, 8, 010 */	IScntrl,
-	/* 0x09, 9, 011 */	IScntrl|ISspace,
+	/* 0x09, 9, 011 */	IScntrl|ISspace|ISblank,
 	/* 0x0a, 10, 012 */	IScntrl|ISspace,
 	/* 0x0b, 11, 013 */	IScntrl|ISspace,
 	/* 0x0c, 12, 014 */	IScntrl|ISspace,
@@ -31,7 +31,7 @@ const unsigned char _uc_ctype_b_C[LOCALE_BUF_SIZE] = {
 	/* 0x1d, 29, 035 */	IScntrl,
 	/* 0x1e, 30, 036 */	IScntrl,
 	/* 0x1f, 31, 037 */	IScntrl,
-	/* 0x20, 32, 040 */	ISprint|ISspace,
+	/* 0x20, 32, 040 */	ISprint|ISspace|ISblank,
 	/* 0x21, 33, 041 */	ISprint|ISpunct,
 	/* 0x22, 34, 042 */	ISprint|ISpunct,
 	/* 0x23, 35, 043 */	ISprint|ISpunct,