
Volker Stolz wrote:
What is "ctype.h" good for?
A good question. Its only use seems to be in ghc/rts/RtsFlags.c where it is used for functions like isdigit and isspace for decoding the RTS flags. Maybe it should be retired altogether.
I'm rather puzzled how this works if ctype.h isn't there at all, as it seems to.
The functions are C89, so they should be present *somewhere* in libc anywhere.
Actually, in GNU libc, isspace, isdigit etc are usually macros which
read a flag word from the __ctype_b array then "and" it with the
corresponding attribute mask.
extern __const unsigned short int *__ctype_b; /* Characteristics. */
...
#define __isctype(c, type) \
(__ctype_b[(int) (c)] & (unsigned short int) type)
...
# define isdigit(c) __isctype((c), _ISdigit)
...
# define isspace(c) __isctype((c), _ISspace)
However, glibc does export functions with those names, and you can
disable the macros by defining the __NO_CTYPE macro, with the result
that the binary depends upon isspace, isdigit etc rather than
__ctype_b.
I don't have glibc 2.3 here, but presumably __ctype_b has changed in
an incompatible manner (maybe there are more than 16 flags in 2.3, in
which case an unsigned short would no longer be sufficient).
--
Glynn Clements