Re: yucky patch

From: David Luyer <luyer@dont-contact.us>
Date: Thu, 11 Feb 1999 12:46:49 +0800

> > gcc -g -O2 -Wall -I. -I../include -I../include -c cf_gen.c
> > cf_gen.c: In function `main':
> > cf_gen.c:180: warning: subscript has type `char'
> > cf_gen.c:185: warning: subscript has type `char'
> > cf_gen.c:190: warning: subscript has type `char'

/usr/include/ctype.h on a glibc linux system may be useful reading for
something similar to how the OS you're looking at is doing things, only
glibc puts typecasts all over the place to get rid of warnings. SunOS 4
does things with arrays too from memory, and probably doesn't do them
so carefully.

glibc guards better than old OS's by making the array 384 bytes in size:

/* These are defined in ctype-info.c.
   The declarations here must match those in localeinfo.h.

   These point into arrays of 384, so they can be indexed by any `unsigned
   char' value [0,255]; by EOF (-1); or by any `signed char' value
   [-128,-1). ISO C requires that the ctype functions work for `unsigned
   char' values and for EOF; we also support negative `signed char' values
   for broken old programs. The case conversion arrays are of `int's
   rather than `unsigned char's because tolower (EOF) must be EOF, which
   doesn't fit into an `unsigned char'. But today more important is that
   the arrays are also used for multi-byte character sets. */

you shouldn't assume this luxury though.

Basically, from this comment, it looks like you should force it to
(unsigned char).

David.
Received on Tue Jul 29 2003 - 13:15:57 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:04 MST