This is the mail archive of the
mailing list for the Cygwin project.
Re: Interesting discovery in the C library that Cygwin uses
Am 09.07.2010, 01:34 Uhr, schrieb Gregg Levine:
(warnings about char subscripts)
Basically the program supporter there wants the people here for Cygwin
to, ah, fix their C library. I'm not convinced that's necessary, but
which C library is used here? And what could be fixed?
The C library (newlib) is fine, it is actually helpful here by emitting
warnings for actual program defects.
The supporter should be sold a clue, in the form of a copy of IEEE
Standard 1003.1 or a deep link to the opengroup.org website.
The urjtag source however should be fixed. It abuses the ctype.h
interfaces. Arguments to the tolower() and other to*() and isspace() and
other is*() functions MUST be cast to unsigned char (unless they are
already unsigned char). Background is that these functions need to support
the usual 8bit character range plus the 257th "character" EOF (-1). So
the is*() functions will have to use a wider type than char, and now sign
extension matters. If you don't cast the input to unsigned char, an
argument of 0xff will alias EOF although it is not the same, and
0x80...0xfe will lead to undefined behaviour, possibly even crashes.
Note: the warning may be specific to Cygwin, but the underlying program
will show on more systems with input outside ASCII. I recall that at
least some versions of Solaris would misbehave if you passed non-ASCII
characters (think umlauts or accented characters, or Asian/Cyrillic/other
national scripts) to these ctype.h functions. There are probably more...
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple