isascii(3) macros and casts

Paul Eggert eggert@cs.ucla.edu
Wed Dec 11 17:05:02 GMT 2024


On 2024-12-11 05:42, Alejandro Colomar wrote:
> I was checking some code that calls isdigit(3) without the proper casts,
> and wondered about how to better fix that code.

In my experience, often a better fix is to not call isdigit. This is why 
Gnulib has c_isdigit, a variant of isdigit for the C locale. Similarly 
for c_isalpha, etc.

A lot of isdigit calls incorrectly assume that '0' through '9' are the 
only digits. Plus, isdigit is not fully thread-safe. And of course 
isdigit, like c_isdigit, assumes a single-byte locale.

There is a lot not to like about isdigit.


More information about the Libc-alpha mailing list