X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/eb91e30040d44cf387bdcd0ad4dd10fec2d95799..c003e62a7fe827104127da3546a65f2ddadab3d4:/regcomp.h diff --git a/regcomp.h b/regcomp.h index 062bd01..6dc05f5 100644 --- a/regcomp.h +++ b/regcomp.h @@ -204,15 +204,16 @@ struct regnode_charclass { U8 flags; U8 type; U16 next_off; - U32 arg1; + U32 arg1; /* used as ptr in S_regclass */ char bitmap[ANYOF_BITMAP_SIZE]; /* only compile-time */ }; -struct regnode_charclass_class { /* has [[:blah:]] classes */ - U8 flags; /* should have ANYOF_CLASS here */ +/* has runtime (locale) \d, \w, ..., [:posix:] classes */ +struct regnode_charclass_class { + U8 flags; /* ANYOF_CLASS bit must go here */ U8 type; U16 next_off; - U32 arg1; + U32 arg1; /* used as ptr in S_regclass */ char bitmap[ANYOF_BITMAP_SIZE]; /* both compile-time */ char classflags[ANYOF_CLASSBITMAP_SIZE]; /* and run-time */ }; @@ -271,7 +272,7 @@ struct regnode_charclass_class { /* has [[:blah:]] classes */ #undef STRING #define OP(p) ((p)->type) -#define FLAGS(p) ((p)->flags) /* Caution: Doesn't apply to all +#define FLAGS(p) ((p)->flags) /* Caution: Doesn't apply to all \ regnode types */ #define OPERAND(p) (((struct regnode_string *)p)->string) #define MASK(p) ((char*)OPERAND(p)) @@ -313,21 +314,29 @@ struct regnode_charclass_class { /* has [[:blah:]] classes */ /* Flags for node->flags of ANYOF */ -#define ANYOF_CLASS 0x08 /* has runtime \d, \w, [:posix:], ... */ -#define ANYOF_LARGE ANYOF_CLASS /* Same; name retained for back compat */ -#define ANYOF_INVERT 0x04 -#define ANYOF_FOLD 0x02 #define ANYOF_LOCALE 0x01 +#define ANYOF_FOLD 0x02 +#define ANYOF_INVERT 0x04 + +/* CLASS is never set unless LOCALE is too: has runtime \d, \w, [:posix:], ... */ +#define ANYOF_CLASS 0x08 +#define ANYOF_LARGE ANYOF_CLASS /* Same; name retained for back compat */ -/* Used for regstclass only */ -#define ANYOF_EOS 0x10 /* Can match an empty string too */ +/* Can match something outside the bitmap that is expressible only in utf8 */ +#define ANYOF_UTF8 0x10 -/* There is a character or a range past 0xff */ -#define ANYOF_UNICODE 0x20 -#define ANYOF_UNICODE_ALL 0x40 /* Can match any char past 0xff */ +/* Can match something outside the bitmap that isn't in utf8 */ +#define ANYOF_NONBITMAP_NON_UTF8 0x20 -/* Are there any runtime flags on in this node? */ -#define ANYOF_RUNTIME(s) (ANYOF_FLAGS(s) & 0x0f) +/* Set if the bitmap doesn't fully represent what this node can match */ +#define ANYOF_NONBITMAP (ANYOF_UTF8|ANYOF_NONBITMAP_NON_UTF8) +#define ANYOF_UNICODE ANYOF_NONBITMAP /* old name, for back compat */ + +/* Matches every code point 0x100 and above*/ +#define ANYOF_UNICODE_ALL 0x40 + +/* EOS used for regstclass only */ +#define ANYOF_EOS 0x80 /* Can match an empty string too */ #define ANYOF_FLAGS_ALL 0xff @@ -397,6 +406,12 @@ struct regnode_charclass_class { /* has [[:blah:]] classes */ #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)) +/* Quicker way to see if there are actually any tests. This is because + * currently the set of tests can be empty even when the class bitmap is + * allocated */ +#define ANYOF_CLASS_TEST_ANY_SET(p) /* assumes sizeof(p) = 4 */ \ + memNE (((struct regnode_charclass_class*)(p))->classflags, "0000", ANYOF_CLASS_SIZE) + #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) @@ -411,7 +426,7 @@ struct regnode_charclass_class { /* has [[:blah:]] classes */ #define ANYOF_BITMAP_CLEARALL(p) \ Zero (ANYOF_BITMAP(p), ANYOF_BITMAP_SIZE) /* Check that all 256 bits are all set. Used in S_cl_is_anything() */ -#define ANYOF_BITMAP_TESTALLSET(p) \ +#define ANYOF_BITMAP_TESTALLSET(p) /* Assumes sizeof(p) == 32 */ \ memEQ (ANYOF_BITMAP(p), "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377", ANYOF_BITMAP_SIZE) #define ANYOF_SKIP ((ANYOF_SIZE - 1)/sizeof(regnode))