Mail Archives: djgpp-workers/1998/02/02/11:58:00
On Sun, 1 Feb 1998, DJ Delorie wrote:
> > #define isalnum(c) (__dj_ctype_flags[((c)&0xff)+1] & __dj_ISALNUM)
> >
> > That "+1" is designed to make EOF be 0, and the zeroth element of
> > __dj_ctype_flags[] array should be set appropriately. Doesn't this
> > work?
>
> Given -1, you end up with (-1 & 0xff) + 1, which is 256. You get the
> same results for 0xff. Unfortunately, you can't tell the difference
> between -1 meaning EOF and -1 meaning signed character 0xff
> sign-extended and stored in a signed int variable (0xffffffff).
Will the following solve the problem?
#define isalnum(c) (__dj_ctype_flags[((c)+1)&0xff] & __dj_ISALNUM)
- Raw text -