summaryrefslogtreecommitdiff
path: root/sys/src/ape/lib/ap/gen
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2020-08-29 11:09:20 -0700
committerOri Bernstein <ori@eigenstate.org>2020-08-29 11:09:20 -0700
commitec533a1ad8403ae94db37774e78d5b371b8fecfc (patch)
tree45488e7cf77a079d680ffc9e73e1219bfdf9e5fa /sys/src/ape/lib/ap/gen
parent74bf624055abda1d4f6dfb986b0188a4102024f0 (diff)
ape/ctype.h: add isblank, fix functions (thanks staalmannen)
Our ctype.h mistakenly ommitted isblank. Add it in. While we're here, the make the 'isfoo()' functions are broken: they're offsetting into the array, and don't work with negative character values. Sync the function bodies with the macros, and make them produce correct results.
Diffstat (limited to 'sys/src/ape/lib/ap/gen')
-rw-r--r--sys/src/ape/lib/ap/gen/isalnum.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/sys/src/ape/lib/ap/gen/isalnum.c b/sys/src/ape/lib/ap/gen/isalnum.c
index e1ab47cde..0cca9948b 100644
--- a/sys/src/ape/lib/ap/gen/isalnum.c
+++ b/sys/src/ape/lib/ap/gen/isalnum.c
@@ -2,6 +2,7 @@
#undef isalnum
#undef isalpha
+#undef isblank
#undef iscntrl
#undef isdigit
#undef isgraph
@@ -11,14 +12,16 @@
#undef isspace
#undef isupper
#undef isxdigit
-int isalnum(int c){ return (_ctype+1)[c]&(_ISupper|_ISlower|_ISdigit); }
-int isalpha(int c){ return (_ctype+1)[c]&(_ISupper|_ISlower); }
-int iscntrl(int c){ return (_ctype+1)[c]&_IScntrl; }
-int isdigit(int c){ return (_ctype+1)[c]&_ISdigit; }
-int isgraph(int c){ return (_ctype+1)[c]&(_ISpunct|_ISupper|_ISlower|_ISdigit); }
-int islower(int c){ return (_ctype+1)[c]&_ISlower; }
-int isprint(int c){ return (_ctype+1)[c]&(_ISpunct|_ISupper|_ISlower|_ISdigit|_ISblank); }
-int ispunct(int c){ return (_ctype+1)[c]&_ISpunct; }
-int isspace(int c){ return (_ctype+1)[c]&_ISspace; }
-int isupper(int c){ return (_ctype+1)[c]&_ISupper; }
-int isxdigit(int c){ return (_ctype+1)[c]&_ISxdigit; }
+
+int isalnum(int c) {return _ctype[(unsigned char)(c)]&(_ISupper|_ISlower|_ISdigit);}
+int isalpha(int c) {return _ctype[(unsigned char)(c)]&(_ISupper|_ISlower);}
+int isblank(int c) {return _ctype[(unsigned char)(c)]&_ISblank;}
+int iscntrl(int c) {return _ctype[(unsigned char)(c)]&_IScntrl;}
+int isdigit(int c) {return _ctype[(unsigned char)(c)]&_ISdigit;}
+int isgraph(int c) {return _ctype[(unsigned char)(c)]&(_ISpunct|_ISupper|_ISlower|_ISdigit);}
+int islower(int c) {return _ctype[(unsigned char)(c)]&_ISlower;}
+int isprint(int c) {return _ctype[(unsigned char)(c)]&(_ISpunct|_ISupper|_ISlower|_ISdigit|_ISblank);}
+int ispunct(int c) {return _ctype[(unsigned char)(c)]&_ISpunct;}
+int isspace(int c) {return _ctype[(unsigned char)(c)]&_ISspace;}
+int isupper(int c) {return _ctype[(unsigned char)(c)]&_ISupper;}
+int isxdigit(int c) {return _ctype[(unsigned char)(c)]&_ISxdigit;}