<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH] warning cleared



On Tue, Sep 20, 2005 at 12:40:24AM -0500, David Champion wrote:
>         n = atoi(++p);                        /* find pmatch index */
> -       while (isdigit(*p))
> +       while (isdigit((int)*p))

Use strtoul() instead of either....

That (int) cast has actually caused 2 programs I know of to fail.
Causing us to remove it from NetBSD's ctype.h (where is was mistakenly
added a few years ago) and add several hundred (unsigned char) casts
to get code to clean compile again.  Of course this doesn't find
all the bugs, but is a start.

Since isdigit() is locale dependent, it does rather beg the question
as to what code like:
        if (isdigit(x)) n = n * 10 + (x - '0');
if a locale defines anything other than '0'..'9' as digits!
Code using isxdigit() is often worse!

        David

-- 
David Laight: david@xxxxxxxxx