[PATCH/RFA] Fix ctype table and isblank
Jeff Johnston
jjohnstn@redhat.com
Wed Apr 8 19:48:00 GMT 2009
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.
-- Jeff J.
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.
>
> Mike
>
> ---
> Mike Burgess
> Avanex Corporation
>
>
More information about the Newlib
mailing list