"Gary E. Miller" <[email protected]> writes:

> 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.

That's not ok, because if you go down the locale path, what's space,
etc. should all be locale specific.  I think it's asking for massive
trouble to reimplement this.   Plus I think isspace is true for TAB,
which is easy to fix but the point remains that a reimplementation will
have bugs, and be inefficient.

If you must mess it it, I would suggest something that bounds checks and
casts.

But really, once cast to unsigned char, it can't crash, because...  all
the values that  an unsigned char can hold are representable by unsigned
char.  It really is the right answer when using values stored as char.


There's a far larger issue, which is how to deal with UTF-8, wide
character representations, but that's not about gpsd, and not causing us
problems.

So I think it's clear that the only reasonable approach is just cast to
unsigned char before invoking, and a wrapper macro like I suggested is
fine.

Reply via email to