This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
RE: [PATCH/RFA] Fix ctype table and isblank
- From: Wizards' Guild <wizardsguild at earthlink dot net>
- To: newlib at sourceware dot org
- Date: Tue, 7 Apr 2009 17:54:04 -0400 (EDT)
- Subject: RE: [PATCH/RFA] Fix ctype table and isblank
- Reply-to: Wizards' Guild <wizardsguild at earthlink dot net>
Corinna,
One of the things that happened here is the addition of _B to the tab character in the default ctype table. (Oddly, it has NOT been added throughout the new NLS code pages.) This was done so that isblank (and by proxy, the wrapper form of iswblank) could be implemented as a flag test rather than as a hardcoded { 0x09 0x20 } test. The PROBLEM is that _B traditionally exists for the sole benefit of isprint. So, if _B is used such that
#define isblank(c) ((__ctype_ptr__)[(unsigned)((c)+1)]&_B)
returns the correct thing, it is guaranteed that
#define isprint(c) ((__ctype_ptr__)[(unsigned)((c)+1)]&(_P|_U|_L|_N|_B))
returns nonzero for tab characters, which is wrong.
I don't see any clever way to reconcile this behavior; we are out of bits in the ctype table. For "C" locale, the old hardcoded test is guaranteed to work. For anything else, maybe reverse the wrapper and resort to the full blown iswblank check?
---
Mike Burgess
Avanex Corporation