delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/02/02/11:58:00

Date: Mon, 2 Feb 1998 18:56:40 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: DJ Delorie <dj AT delorie DOT com>
cc: Vik DOT Heyndrickx AT rug DOT ac DOT be, djgpp-workers AT delorie DOT com
Subject: Re: char != unsigned char... sometimes, sigh
In-Reply-To: <199802011914.OAA20468@delorie.com>
Message-ID: <Pine.SUN.3.91.980202185623.19322E-100000@is>
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019