isascii(3) macros and casts

Alejandro Colomar alx@kernel.org
Wed Dec 11 20:50:26 GMT 2024


On Wed, Dec 11, 2024 at 12:42:13PM -0800, Paul Eggert wrote:
> On 2024-12-11 12:38, Paul Eggert wrote:
> >    #define isdigit(x) ((int) {x} - '0' <= 9u)
> 
> Oh, that should be
> 
>   #define isdigit(x) ((unsigned int) (int) {x} - '0' <= 9)

LGTM.

> 
> to avoid problems with signed integer overflow.

-- 
<https://www.alejandro-colomar.es/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20241211/cb5c8925/attachment.sig>


More information about the Libc-alpha mailing list