On Fri, Dec 27, 2024 at 05:30:23PM +0000, Lupien, John wrote:
> I have corrected these build errors and gotten a clean build, here is the 
> diff.

Casting to int is not good when char is unisnged on a platform.
The correct way to call the ctype predicates on elements of a char* buffer
is like this:

        isprint((int)(unsigned char)*argv[1])

that way the char value is made unsigned explicitly, then converted to int
and then passed to isprint. Usually the (int) cast is optional (if isprint
is a function, argument promotion rules will imply the (int), if it is a
macro it usually is written in a way to allow the (unsigned char) argument).

If your platform uses signed chars your patch does not change anything
(but eroneously supress the warnings).

See the CAVEATS section here for a reasonable good explanation:

        https://man.netbsd.org/ctype.3

Martin

Reply via email to