Re: [PATCH v5 02/12] ctype: support iscntrl, ispunct, isxdigit and isprint
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Oct 14, 2012, 13:25 UTC
- Message-ID
- <CACsJy8B+6OPkP6ijMDzm+n0eHnDZ4Pj8UO_KasdfEP4wF+_hww@mail.gmail.com>
- In-Reply-To
- <507AB73D.8010406@lsrfire.ath.cx>
On Sun, Oct 14, 2012 at 7:59 PM, René Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:
Show 20 quoted lines
>> +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..
Show 6 quoted lines
> 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).
Show 5 quoted lines
> 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