This is the mail archive of the 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] Fix ctype table and isblank


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

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