Re: Glasgow Haskell on different versions of Linux

Christian Maeder 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.

In local.glasgow-haskell-users, you wrote:
Christian Maeder 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. -- http://www-i2.informatik.rwth-aachen.de/stolz/ *** PGP *** S/MIME Neu! Ändern Sie den Anfangstag Ihrer Woche

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

Volker Stolz wrote (snipped):
The functions are C89, so they should be present *somewhere* in libc anywhere.
Yes, you're right. Normally isspace and friends are used as macros, but ANSI C requires them to be also available as functions so they must be exported that way. Therefore if you don't import ctype.h, what happens is that (isspace) is implicitly assumed to be a function of type Int -> Int, which (in this case) happens to work. The reason for the incompatibility is (see comments in ctype.h) something to do with locales now being thread specific.
participants (3)
-
George Russell
-
Glynn Clements
-
Volker Stolz