[PATCH/RFA] Fix ctype table and isblank
Corinna Vinschen
vinschen@redhat.com
Wed Apr 8 20:03:00 GMT 2009
Hi guys,
On Apr 8 15:22, Jeff Johnston wrote:
> Wizards' Guild wrote:
>> sFolks,
>>
>> Here's my lunch hour thought... to avoid widening the ctype table:
>>
>> For those characters that are alpha but not upper- or lowercase, mark them in the new tables both _U|_L. Existing code will continue to work because nothing in the 00..7F range is marked like this. Then, if the extended tables are supported, modify isupper and islower to do a more specific check:
>>
>> #define isalpha(c) ((__ctype_ptr__)[(unsigned)((c)+1)]&(_U|_L))
>> #define isupper(c) (((__ctype_ptr__)[(unsigned)((c)+1)]&(_U|_L))==_U)
>> #define islower(c) (((__ctype_ptr__)[(unsigned)((c)+1)]&(_U|_L))==_L)
>>
>> The penalty for this extra check should be very small; it can often be absorbed into the branch test in practical usage. If the extended tables are not supported, the extra test is unnecessary but functionally harmless.
>>
>> After studying the iswXX behavior some more, I am convinced that Corinna's revised isblank (with the hardcoded tab test) proposal is indeed correct. Of course it must go in a gcc-specific macro; other compilers would presumably get the library version always.
>
> Thanks Mike. I prefer this to my suggestion. Corinna, if you're ok
> with this and use an intermediate for the isblank macro with your tab
> test, it can be checked in.
Yes, I'm fine with that idea. I'll implement that in the next couple
of days. I have to revisit the ISO and Windows tables. AFAICS, only
the Arabic and Hebrew tables should be affected by the upper/lowercase
problem but I'm not quite sure.
Corinna
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat
More information about the Newlib
mailing list