This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH/RFA] Distinguish between EOF and character with value 0xff


On Apr 21 14:46, Jeff Johnston wrote:
> Corinna Vinschen wrote:
>> Hi,
>>
>>
>> There's a bug in the new character class tables for Windows and ISO
>> charsets.
>>
>> To support signed chars, the tables for the negative values -128..-1 are
>> identical to the values of the positive values 128..255.  Many of these
>> character sets have a valid character at the position 255.  So some
>> functions return a non-0 value not only for the unsigned char value 255,
>> but also for the equivalent signed char value -1.  Unfortunately this
>> potentially breaks applications which use the EOF value as argument to
>> the ctype functions.  They expect that the functions always return 0,
>> but in the current implementation they don't.
>>
>> The below patch fixes that.  It splits off the value for char 255 from the
>> rest of the definition, so that the actual character class tables can
>> return another value for the unsigned char value 255 than for -1.
>>
>> For instance, the former definition for the ISO-8859-1 table looked
>> like this:
>>
>>     { _CTYPE_ISO_8859_1_128_256,
>>       _CTYPE_DATA_0_127,
>>       _CTYPE_ISO_8859_1_128_256
>>     },
>>
>> The new definition now looks like this:
>>
>>     { _CTYPE_ISO_8859_1_128_254,
>>       0,
>>       _CTYPE_DATA_0_127,
>>       _CTYPE_ISO_8859_1_128_254,
>>       _CTYPE_ISO_8859_1_255
>>     },
>>
>> While I was at it I also took the liberty to rename _CTYPE_DATA_128_256
>> to _CTYPE_DATA_128_255, which is more correct since the definitions contains
>> the character values 128..255, not 128..256.
>>
>> Ok the apply?
>>
>>
>>   
> Yes, please go ahead.

Thanks, checked in.


Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


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