diff options
author | Ilya Zakharevich <ilya@math.berkeley.edu> | 1999-10-24 23:06:21 -0400 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 1999-10-25 08:25:50 +0000 |
commit | 936ed89792056e61b492edd0cf6cce00104ce2f5 (patch) | |
tree | 37e025bd10fe90843342c09b90254a6a8e75d43f /regcomp.h | |
parent | b3c9acc1dea37c675a57f40a88b0c08196d48123 (diff) | |
download | perl-936ed89792056e61b492edd0cf6cce00104ce2f5.tar.gz |
Remove the last regnode<==>char*
To: perl5-porters@perl.org (Mailing list Perl5)
Message-Id: <199910250706.DAA16825@monk.mps.ohio-state.edu>
p4raw-id: //depot/cfgperl@4453
Diffstat (limited to 'regcomp.h')
-rw-r--r-- | regcomp.h | 44 |
1 files changed, 32 insertions, 12 deletions
@@ -87,6 +87,24 @@ struct regnode_2 { U16 arg2; }; +#define ANYOF_BITMAP_SIZE 32 /* 256 b/(8 b/B) */ +#define ANYOF_CLASSBITMAP_SIZE 4 + +struct regnode_charclass { + U8 flags; + U8 type; + U16 next_off; + char bitmap[ANYOF_BITMAP_SIZE]; +}; + +struct regnode_charclass_class { + U8 flags; + U8 type; + U16 next_off; + char bitmap[ANYOF_BITMAP_SIZE]; + char classflags[ANYOF_CLASSBITMAP_SIZE]; +}; + /* XXX fix this description. Impose a limit of REG_INFTY on various pattern matching operations to limit stack growth and to avoid "infinite" recursions. @@ -160,14 +178,14 @@ struct regnode_2 { #define SIZE_ONLY (PL_regcode == &PL_regdummy) -/* Flags for first parameter byte [0] of ANYOF */ +/* Flags for node->flags 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 */ +/* Character classes for node->classflags of ANYOF */ #define ANYOF_ALNUM 0 /* \w, utf8::IsWord, isALNUM() */ #define ANYOF_NALNUM 1 @@ -207,29 +225,31 @@ struct regnode_2 { /* 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_SIZE (sizeof(struct regnode_charclass)) +#define ANYOF_CLASS_SIZE (sizeof(struct regnode_charclass_class)) -#define ANYOF_FLAGS(p) ((p)[0]) +#define ANYOF_FLAGS(p) ((p)->flags) #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_BYTE(p, c) (((struct regnode_charclass_class*)(p))->classflags[((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_CLASS_ZERO(ret) Zero(((struct regnode_charclass_class*)(ret))->classflags, ANYOF_CLASSBITMAP_SIZE, char) +#define ANYOF_BITMAP_ZERO(ret) Zero(((struct regnode_charclass*)(ret))->bitmap, ANYOF_BITMAP_SIZE, char) + +#define ANYOF_BITMAP(p) (((struct regnode_charclass*)(p))->bitmap) +#define ANYOF_BITMAP_BYTE(p, c) (ANYOF_BITMAP(p)[((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) +#define ANYOF_SKIP ((ANYOF_SIZE - 1)/sizeof(regnode)) +#define ANYOF_CLASS_SKIP ((ANYOF_CLASS_SIZE - 1)/sizeof(regnode)) +#define ANYOF_CLASS_ADD_SKIP (ANYOF_CLASS_SKIP - ANYOF_SKIP) /* * Utility definitions. |