What is the general approach for translating glibc ctype.h
into JavaScript? I think I could do it, but I am not finding the tables and bitshifting that implements these in the C source code. What is the most optimal techniques here?
isalnum(c)
isalpha(c)
iscntrl(c)
isdigit(c)
islower(c)
isgraph(c)
isprint(c)
ispunct(c)
isspace(c)
isupper(c)
isxdigit(c)
isblank(c)
It appears they are using all sorts of techniques to generate these functions depending on architecture perhaps. But what is the gist of what needs to be done to translate this manually to JavaScript? It appears they are using tables of some sort, but I can’t seem to also find those in the source either.
Looking at the openbsd ctype.h source gets me a little closer, but still missing the tables, and not sure if that’s the most optimized approach to use for JavaScript. For example:
__only_inline int isdigit(int _c)
{
return (_c == -1 ? 0 : ((_ctype_ + 1)[(unsigned char)_c] & _N));
}
I don’t see where they get the & _N
from, and what the (_ctype_ + 1)[index]
means or comes from.