This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Re: some unusual errors
- To: gnu-win32 at cygnus dot com
- Subject: Re: some unusual errors
- From: DJ Delorie <dj at delorie dot com>
- Date: Tue, 22 Sep 1998 16:13:54 -0400
- Newsgroups: cygnus.gnu-win32
- Organization: delorie software
- References: <9809211418.AA12875@vviuh221.vvi.com>, <199809212009.NAA00026.cygnus.gnu-win32@aleph.ssd.hal.com>
- Stamped: newsgate-cygnus
J. J. Farrell wrote:
> isspace() is prototyped as isspace(int); if the caller
> were using the function version, then the prototype would
> be effective, and the char would have been silently and
> correctly widened to an int.
No, the char would have been silently and INcorrectly
widened to a *signed* int, resulting in a range of values of
-128..127. That is not the legal range of values for the
is*() functions.
The legal range of values for is*() is 0..255 and EOF. The
automatic widening of a [default signed] char results in
signed int values in the range -128..127. You cannot rely
on the automatic widening to give correct results.
On a side note, using a signed char as the input makes it
impossible to tell the difference between character 255 and
the traditional EOF value of -1, as both have the same bit
pattern (0xff) when stored in a signed char variable.
Because there are 257 legal parameter values for is*(), an
8-bit variable is simply too small to represent them without
loss or inaccuracy.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".