Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: isspace() behaviour



On Thu, Dec 19, 2024 at 08:18:38AM +0700, Robert Elz wrote:
>     Date:        Wed, 18 Dec 2024 19:45:36 +0100
>     From:        Roland Illig <roland.illig%gmx.de@localhost>
>     Message-ID:  <c9cd653a-3ece-4cdb-a5dc-7e380db1f942%gmx.de@localhost>
> 
>   | > 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:
> 
> 
> Yes, passing EOF (as an int) to these macros/functions is permitted, there
> is no need to test for it as Martin's sample code did.
> 
> The problem case is when the return from [f]getc() is stored into a
> char type variable, and then that variable is passed to the <ctype.h>
> macros/functions - that doesn't work.   As long as only int variables
> are used, it is all OK.

The problem was that it was stored in an unsigned int.

uint32_t c = EOF;
isspace(c); -> segmentation fault on nbsd


Cheers,

Patrick


Home | Main Index | Thread Index | Old Index