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: Wed, 8 Apr 2009 09:13:21 -0400 (GMT-04:00)
- Subject: Re: [PATCH/RFA] Fix ctype table and isblank
- Reply-to: Wizards' Guild <wizardsguild at earthlink dot net>
Corinna,
Yes, we really should have an "alpha" flag AND a "blank" flag with the new semantics. The obvious and common approach would be to widen the table entries. I'm not a big fan of this because it bloats the small-footprint systems. This is maybe why it hasn't been done already?
Another approach would be to keep the "C" locale table and macros, but if extended charsets are supported just convert everything to UNICODE and handle it there. Some functions, such as tolower, are already using this approach. We might be able to improve mbtowc to make this less painful, but regardless this will be a dog for performance. The benefit is centralization. I think this approach is a reasonable choice for isblank. I don't care for the "half hardcoded" variation of isblank; seems like an accident waiting to happen.
Both _N and _X are locale-invariant, making them good candidates for removal from the ctype table. If we wanted to recover ONE flag, I'd take _N rather than _X. In this case add _X to the digits and use _X in isprint, isgraph, and isalnum. It is possible to implement isdigit as a standard macro with single evaluation:
#define isdigit(c) ((unsigned)((c)-'0')<=9)
Hard choices...
Mike
---
Mike Burgess
Avanex Corporation