Date: Mon, 2 Feb 1998 18:56:40 +0200 (IST) From: Eli Zaretskii To: DJ Delorie 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: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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)