delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/02/01/13:18:17

Date: Sun, 1 Feb 1998 19:51:48 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Vik Heyndrickx <Vik DOT Heyndrickx AT rug DOT ac DOT be>
cc: djgpp-workers AT delorie DOT com
Subject: Re: char != unsigned char... sometimes, sigh
In-Reply-To: <34D185D3.302@rug.ac.be>
Message-ID: <Pine.SUN.3.91.980201195130.16390L-100000@is>
MIME-Version: 1.0

On Fri, 30 Jan 1998, Vik Heyndrickx wrote:

> Another thought to support the idea for changing the 'char' default from
> 'signed char' to 'unsigned char' is that the is* macros from <ctype.h>
> are ALL buggy because they do not select the proper array element for
> the argument being EOF.

Are you sure?  Unless I'm missing something, the ctype macros should
work for -1:

  #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?

> Because a LOT of programs actually rely on the fact that the is* macros
> should work on a 'char', someone made this macro cast the 'c' argument
> to an 'unsigned char' (i.e. ANDs it with 0xff), and this works of course
> well for any 'signed char' and 'unsigned char', but not for EOF.

Please explain why do you think this doesn't work for EOF.

- Raw text -


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