On Jan 12, 2012, at 6:14 AM, Andy Polyakov via RT wrote:

>> ***************************************************
>> issue:
>> extra warnings in compilation of ca.c and gost_pmeth
>> 
>> solution:
>> convert the type to unsigned int before "uppering"
> 
> This actually goes beyond just warning. toupper accepts 'int' as
> argument and if you pass 'char' from upper half of ASCII table, it will
> be passed sign-expanded, and if you pass 'unsigned char', then it will
> be passed zero-expanded. What it right? Solaris manual page says:
> 
> The  toupper() function has as a domain a type int, the value of which
> is representable as an unsigned char or the value of EOF.
> 
> Same wording can be found in earlier Linux. Later Linux says "if c is
> not an unsigned char value or EOF, the behaviour is undefined." I don't
> really understand what does "having as a domain a type int" mean
> exactly, but char's sign expansion can be significant. And it seems that
> it's not possibility, but a fact. At the very least Solaris *fails* to
> convert sign-extended chars to upper case, but manages to convert
> zero-extended chars, i.e. characters from upper half of ASCII table
> valid in current locale context.


It's not just Linux.

        The C99 standard says (Section 7.4/1): "The header <ctype.h> declares 
several functions useful for classifying and mapping characters. In all cases 
the argument is an int, the value of which shall be representable as an 
unsigned char or shall equal the value of the macro EOF. If the argument has 
any other value, the behavior is undefined."

To me, that says 0 … 255 is good, (-128 … 0) is bad.

See also http://msdn.microsoft.com/en-us/library/ms245348.aspx

-- Marshall

Marshall Clow     Idio Software   <mailto:[email protected]>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly 
moderated down to (-1, Flamebait).
        -- Yu Suzuki

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [email protected]

Reply via email to