Subject: Re: some unusual errors
From: [email-masked] (Benjamin Riefenstahl)

19 Sep 1998 23:08:41 -0700
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
To: [email-masked]

Hi Michael,

Michael Richardson wrote:
> I get a lot of warnings like this:
> 
> strtod.c:1239: warning: subscript has type `char'
> 
>   This line of code is actually:
> 
>         for(s = s00; isspace(*s); s++)
> 
>   which confuses me. What, if not "char" should isspace() take???

Several issues here.

a) Specification: The <ctype.h> functions all take "int"s in the range 0
to UCHAR_MAX plus EOF. This is the same range that getc() returns. It is
*not* the same range as "char", but OTOH "unsigned char" is a subset of
this range, so with regular strings one usually should cast like this

        for(s = s00; isspace((unsigned char)*s); s++)

b) The <ctype.h> functions are usually implemented as macros which look
up the answers in a static array. I think what the compiler complains
about is, that you use a (signed) "char" to index into an array where of
course no negative values are allowed for indexing. This is actually the
same issue as a), just some corners of the actual implementation later.

so long, benny
======================================
Benjamin Riefenstahl ([email-masked])
Crocodial Communications EntwicklungsGmbH
Ruhrstraße 61, D-22761 Hamburg, Germany
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".