From: Nguyen Thai Ngoc Duy Date: Sun, 14 Oct 2012 13:25:10 GMT Subject: Re: [PATCH v5 02/12] ctype: support iscntrl, ispunct, isxdigit and isprint Message-ID: In-Reply-To: <507AB73D.8010406@lsrfire.ath.cx> On Sun, Oct 14, 2012 at 7:59 PM, René Scharfe wrote: >> +const unsigned char sane_ctype2[256] = { >> + CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, /* >> 0..15 */ >> + CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, /* >> 16..31 */ >> + 0, PU, PU, PU, PU, PU, PU, PU, PU, PU, PU, PU, PU, PU, PU, PU, /* >> 32..47 */ >> + XD, XD, XD, XD, XD, XD, XD, XD, XD, XD, PU, PU, PU, PU, PU, PU, /* >> 48..63 */ >> + PU, 0, XD, 0, XD, 0, XD, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* >> 64..79 */ >> + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, PU, PU, PU, PU, PU, /* >> 80..95 */ >> + PU, 0, XD, 0, XD, 0, XD, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* >> 96..111 */ >> + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, PU, PU, PU, PU, CN, /* >> 112..127 */ > > > Shouldn't [ace] (65, 67, 69) and [ACE] (97, 99, 101) be xdigits as well? Hmm.. I generated it from LANG=C. I wonder where I got it wrong.. > But how about using the existing hexval_table instead, like this: > > #define isxdigit(x) (hexval_table[(x)] != -1) > > With that, couldn't you squeeze the other two classes into the existing > sane_type? No there are still conflicts: 9, 10 and 13 as spaces (vs controls) and 123, 124 and 126 as regex/pathspec special (vs punctuation). > By the way, I'm working on a patch series for implementing a lot more > character classes with table lookups. It grew out of a desire to make > bad_ref_char() faster but perhaps got a bit out of hand by now; it's at 24 > patches and still not finished. I'm curious how long we have until it > escapes. ;-) I don't think the series is going to graduate any time soon :) -- Duy