This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: some unusual errors


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".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]