Subject: Re: ctype "(int)" casting (Re: pkg_select upgrade)
To: Martin S. Weber <Ephaeton@gmx.net>
From: Jachym Holecek <freza@liberouter.org>
List: tech-pkg
Date: 03/17/2005 08:23:18
> > > Option #1 would be like this:
> > > In ftpio.c file,
> > > - if (ftprc && isdigit(buf[match.rm_so+1]))
> > > + if (ftprc && isdigit((int)buf[match.rm_so+1]))
> > >
> > > And here is option #2:
> > > In /usr/src/include/ctype.h file,
> > > -#define isdigit(c) ((int)((_ctype_ + 1)[(c)] & _N))
> > > +#define isdigit(c) ((int)((_ctype_ + 1)[(int)(c)] & _N))
> >
> > isdigit(3) says the prototype is "int isdigit(int c);", so #1 would seem
> > correct.
> >
>
> True, and thus, was it a function, C would do the cast (int promotion
> as in #2) for us. That's something I wanted to ask about on userlevel
> for quite some time already... Same applies to the to* functions
> of ctype, too.
>
> Is relying on C to make
>
> char c = <whatever>, tolower(c)
>
> work w/o complaint a user error ?
This has been brought up in the past, see:
http://mail-index.netbsd.org/tech-userlevel/2004/10/28/0010.html
http://mail-index.netbsd.org/tech-userlevel/2004/10/28/0008.html
Regards,
-- Jachym Holecek