Mail Archives: djgpp-workers/1999/06/14/11:20:43
On Mon, 14 Jun 1999, Hans-Bernhard Broeker wrote:
> It may work, but it's a bit unclear. The cast to (unsigned char) would be
> cleaner, I think. Or, for that matter, defining c as an unsigned char
> variable straight away.
Thanks for the feedback.
I agree that these might be cleaner, but as we are (I hope) very close to
releasing v2.03, I wanted a change that was as local as possible. The
cast is impossible to do without non-trivial changes to the code (it
assigns to c once and then uses c throughout), and declaring c unsigned
char instead of int can have unexpected results elsewhere in the code,
since c participates in integer computations of the return value.
> The rule is simple: a char that is to be passed to a <ctype.h> functions
> must either already *be* a unsigned char, or be casted into one.
Where is this rule spelled out? ANSI says that ctype functions accept an
int, including EOF (which cannot be casted to unsigned char; fixing that
in v2.02 was the reason these bugs came into existence in the first
place).
- Raw text -