Yo Greg! On Mon, 02 Nov 2026 20:58:20 -0500 Greg Troxel <[email protected]> wrote:
> "Gary E. Miller" <[email protected]> writes: > > >> I have tested, and on NetBSD 11 amd64 get no build warnings at > >> all! > > > > Good news. > > > > I don't like the solution of just casting to (unsigned char). Too > > brittle. I'm going to add ISXXXXX() macros that ex explicity valid > > for all (int) and ASCII. The existing isXXXXX() are locale > > specific, and that could byte us some time. > > I don't think that's really sound in general. The functions are > defined on values that fit in unsigned char, and EOF. Given the > cast, it's not like EOF can be used. But EOF aliases to 255. You yourself found a crash bug with the existing calls. Way too easy to misuse. Plusm the whole locale thing is also a tcking time bomb. > Any particular use of an unsigned char cast is stable and safe. But neglecting to add the cast is, as you showed, a potential crash bug. With no beneifit of compiler or Coverity warnings. > So if there is an ISALPHA() macro: > > #define ISALPHA(c) isalpha((unsigned char) c) > > then that's a good way to encapsulate the plan and increase the odds > that the next newly-added ctype call will be ok. But that still leaves the locale problem. I was thinking more like: #define ISSPACE(c) ((c) == 0x20) #define ISASCII(c) ((c) >= 0 && (c) <= 127) No casts, no locale issues, no compiler warnings, no UB. Side effects could be an ussue, but I see no gpsd code using isXXXXX() that also uses side effects (++, --, etc.). > > Lookg forward to the results. > > No build wanrings, regression tests pass. Good! RGDS GARY --------------------------------------------------------------------------- Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703 [email protected] Tel:+1 541 382 8588 Veritas liberabit vos. -- Quid est veritas? "If you can't measure it, you can't improve it." - Lord Kelvin
pgpBZ_wn5NWwm.pgp
Description: OpenPGP digital signature
