[m-dev.] diff: fix more isalnum() cast problems

Tyson Dowd trd at stimpy.cs.mu.oz.au
Tue Jul 28 15:00:00 AEST 1998


On 28-Jul-1998, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Estimated hours taken: 0.5
> 
> Fix a portability problem: mkinit.c and mdemangle.c were not casting
> the arguments of isdigit() and isalnum() to unsigned char.
> 

> +
> +/*
> +** The ANSI C isalnum(), etc. macros require that the argument be cast to
> +** `unsigned char'; if you pass a signed char, the behaviour is undefined.
> +** Hence we define `MR_' versions of these that do the cast -- you should
> +** make sure to always use the `MR_' versions rather than the standard ones.
> +*/
> +#define	MR_isalnum(c)	isdigit((unsigned char) (c))
> +#define	MR_isdigit(c)	isdigit((unsigned char) (c))
> +#define	MR_isspace(c)	isspace((unsigned char) (c))

I would suggest implementing MR_isalnum in terms of "isalnum" instead
of "isdigit" for increased correctness.

(I've committed this already, because it was causing mkinit to generate
rather incorrect initialization code).

-- 
       Tyson Dowd           # "Bill Gates is a white persian cat and a monocle
                            # away from becoming another James Bond villan."
     trd at cs.mu.oz.au        # "No Mr Bond, I expect you to upgrade."
http://www.cs.mu.oz.au/~trd #                -- Dennis Miller and Terri Branch



More information about the developers mailing list