diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 1999-07-06 21:47:04 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 1999-07-06 21:47:04 +0000 |
commit | b8c5462f6edbb2dd616e1733df011beee816eee1 (patch) | |
tree | 8769adc1886492ed5c33f80684e9905c3f407ee4 /regcomp.h | |
parent | 27806c827bf94df47a488c71aa19376daf71342b (diff) | |
download | perl-b8c5462f6edbb2dd616e1733df011beee816eee1.tar.gz |
POSIX [[:character class:]] support for standard, locale,
and utf8. If both utf8 and locale are on, utf8 wins.
I don't fully understand why so many tables changed in
lib/unicode because of "make" -- maybe it was just overdue.
p4raw-id: //depot/cfgperl@3624
Diffstat (limited to 'regcomp.h')
-rw-r--r-- | regcomp.h | 88 |
1 files changed, 70 insertions, 18 deletions
@@ -154,24 +154,76 @@ struct regnode_2 { #define SIZE_ONLY (PL_regcode == &PL_regdummy) -/* Flags for first parameter byte of ANYOF */ -#define ANYOF_INVERT 0x40 -#define ANYOF_FOLD 0x20 -#define ANYOF_LOCALE 0x10 -#define ANYOF_ISA 0x0F -#define ANYOF_ALNUML 0x08 -#define ANYOF_NALNUML 0x04 -#define ANYOF_SPACEL 0x02 -#define ANYOF_NSPACEL 0x01 - -/* Utility macros for bitmap of ANYOF */ -#define ANYOF_BYTE(p,c) (p)[1 + (((c) >> 3) & 31)] -#define ANYOF_BIT(c) (1 << ((c) & 7)) -#define ANYOF_SET(p,c) (ANYOF_BYTE(p,c) |= ANYOF_BIT(c)) -#define ANYOF_CLEAR(p,c) (ANYOF_BYTE(p,c) &= ~ANYOF_BIT(c)) -#define ANYOF_TEST(p,c) (ANYOF_BYTE(p,c) & ANYOF_BIT(c)) - -#define ANY_SKIP ((33 - 1)/sizeof(regnode) + 1) +/* Flags for first parameter byte [0] of ANYOF */ + +#define ANYOF_CLASS 0x08 +#define ANYOF_INVERT 0x04 +#define ANYOF_FOLD 0x02 +#define ANYOF_LOCALE 0x01 + +/* Character classes for bytes [1..4] of ANYOF */ + +#define ANYOF_ALNUM 0 /* \w, utf8::IsWord, isALNUM() */ +#define ANYOF_NALNUM 1 +#define ANYOF_SPACE 2 +#define ANYOF_NSPACE 3 +#define ANYOF_DIGIT 4 +#define ANYOF_NDIGIT 5 +#define ANYOF_ALNUMC 6 /* isalnum(3), utf8::IsAlnum, isALNUMC() */ +#define ANYOF_NALNUMC 7 +#define ANYOF_ALPHA 8 +#define ANYOF_NALPHA 9 +#define ANYOF_ASCII 10 +#define ANYOF_NASCII 11 +#define ANYOF_CNTRL 12 +#define ANYOF_NCNTRL 13 +#define ANYOF_GRAPH 14 +#define ANYOF_NGRAPH 15 +#define ANYOF_LOWER 16 +#define ANYOF_NLOWER 17 +#define ANYOF_PRINT 18 +#define ANYOF_NPRINT 19 +#define ANYOF_PUNCT 20 +#define ANYOF_NPUNCT 21 +#define ANYOF_UPPER 22 +#define ANYOF_NUPPER 23 +#define ANYOF_XDIGIT 24 +#define ANYOF_NXDIGIT 25 + +#define ANYOF_MAX 31 + +/* Backward source code compatibility. */ + +#define ANYOF_ALNUML ANYOF_ALNUM +#define ANYOF_NALNUML ANYOF_NALNUM +#define ANYOF_SPACEL ANYOF_SPACE +#define ANYOF_NSPACEL ANYOF_NSPACE + +/* Utility macros for the bitmap and classes of ANYOF */ + +#define ANYOF_OPND_SIZE 1 +#define ANYOF_CLASS_SIZE 4 +#define ANYOF_BITMAP_SIZE 32 /* 256 b/(8 b/B) */ +#define ANYOF_SIZE (ANYOF_OPND_SIZE+ANYOF_CLASS_SIZE+ANYOF_BITMAP_SIZE) + +#define ANYOF_FLAGS(p) ((p)[0]) +#define ANYOF_FLAGS_ALL 0xff + +#define ANYOF_BIT(c) (1 << ((c) & 7)) + +#define ANYOF_CLASS_OFFSET ANYOF_OPND_SIZE +#define ANYOF_CLASS_BYTE(p, c) ((p)[ANYOF_CLASS_OFFSET + (((c) >> 3) & 3)]) +#define ANYOF_CLASS_SET(p, c) (ANYOF_CLASS_BYTE(p, c) |= ANYOF_BIT(c)) +#define ANYOF_CLASS_CLEAR(p, c) (ANYOF_CLASS_BYTE(p, c) &= ~ANYOF_BIT(c)) +#define ANYOF_CLASS_TEST(p, c) (ANYOF_CLASS_BYTE(p, c) & ANYOF_BIT(c)) + +#define ANYOF_BITMAP_OFFSET (ANYOF_CLASS_OFFSET+ANYOF_CLASS_SIZE) +#define ANYOF_BITMAP_BYTE(p, c) ((p)[ANYOF_BITMAP_OFFSET + (((c) >> 3) & 31)]) +#define ANYOF_BITMAP_SET(p, c) (ANYOF_BITMAP_BYTE(p, c) |= ANYOF_BIT(c)) +#define ANYOF_BITMAP_CLEAR(p,c) (ANYOF_BITMAP_BYTE(p, c) &= ~ANYOF_BIT(c)) +#define ANYOF_BITMAP_TEST(p, c) (ANYOF_BITMAP_BYTE(p, c) & ANYOF_BIT(c)) + +#define ANY_SKIP ((ANYOF_SIZE - 1)/sizeof(regnode) + 1) /* * Utility definitions. |