Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: isspace() behaviour
Am 18.12.2024 um 12:52 schrieb Martin Husemann:
> See ctype(3) and search for CAVEATS:
>
> Clearly casting EOF to unsigned char will give an invalid input value to
> any ctype function.
To clarify, the input value will be in the correct range, but the return
value will not be the expected one, as (unsigned char)EOF will be
interpreted as a character number, so the function may return a nonzero
value.
> You need to first test for EOF but then cast any non-EOF characters to
> unsigned char to be portable:
That's wrong. The CAVEATS section explicit allows character I/O operations:
> Values of type int that were returned by getc(3), fgetc(3), and similar
> functions or macros are already in the correct range, and may be safely
> passed to these ctype functions without any casts.
Roland
Home |
Main Index |
Thread Index |
Old Index