From d1d040e539a86226d1a68f741e36ac5b3cfdbda9 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Wed, 14 Aug 2013 11:39:38 -0600 Subject: [PATCH] regcomp.h: Create new typedef synonym for clarity This commit finishes (at least for now) removing some of the overloading of the term class. A 'regnode_charclass_class' node contains space for storing the posix classes it matches that are never defined until the moment of matching because they are subject to the current run-time locale. This commit creates a typedef 'regnode_charclass_posixl' synonym that doesn't re-use the term 'class' for two different purposes. --- perl.h | 5 +++++ pod/perlreguts.pod | 6 +++--- regcomp.h | 16 ++++++++-------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/perl.h b/perl.h index cbd4320..dfd425c 100644 --- a/perl.h +++ b/perl.h @@ -3277,6 +3277,11 @@ typedef struct magic_state MGS; /* struct magic_state defined in mg.c */ struct scan_data_t; /* Used in S_* functions in regcomp.c */ struct regnode_charclass_class; /* Used in S_* functions in regcomp.c */ + +/* A hopefully less confusing name. The sub-classes are all Posix classes only + * used under /l matching */ +typedef struct regnode_charclass_class regnode_charclass_posixl; + typedef struct regnode_ssc regnode_ssc; struct ptr_tbl_ent { diff --git a/pod/perlreguts.pod b/pod/perlreguts.pod index d93c799..eac08f5 100644 --- a/pod/perlreguts.pod +++ b/pod/perlreguts.pod @@ -180,15 +180,15 @@ Various flags whose names begin with C are used for special situations. Above Latin1 matches and things not known until run-time are stored in L. -=item C +=item C There is also a larger form of a char class structure used to represent POSIX char classes under C matching, -called C which has an +called C which has an additional 32-bit bitmap indicating which POSIX char classes have been included. - regnode_charclass_class U32 arg1; + regnode_charclass_posixl U32 arg1; char bitmap[ANYOF_BITMAP_SIZE]; U32 classflags; diff --git a/regcomp.h b/regcomp.h index 5e8bcb5..5629990 100644 --- a/regcomp.h +++ b/regcomp.h @@ -333,7 +333,7 @@ struct regnode_ssc { #define ANYOF_INVERT 0x04 -/* Set if this is a struct regnode_charclass_class vs a regnode_charclass. This +/* Set if this is a regnode_charclass_posixl vs a regnode_charclass. This * is used for runtime \d, \w, [:posix:], ..., which are used only in locale * and the optimizer's synthetic start class. Non-locale \d, etc are resolved * at compile-time. Could be shared with ANYOF_LOCALE, forcing all locale @@ -443,32 +443,32 @@ struct regnode_ssc { /* Utility macros for the bitmap and classes of ANYOF */ #define ANYOF_SIZE (sizeof(struct regnode_charclass)) -#define ANYOF_POSIXL_SIZE (sizeof(struct regnode_charclass_class)) +#define ANYOF_POSIXL_SIZE (sizeof(regnode_charclass_posixl)) #define ANYOF_CLASS_SIZE ANYOF_POSIXL_SIZE #define ANYOF_FLAGS(p) ((p)->flags) #define ANYOF_BIT(c) (1 << ((c) & 7)) -#define ANYOF_POSIXL_SET(p, c) (((struct regnode_charclass_class*) (p))->classflags |= (1U << (c))) +#define ANYOF_POSIXL_SET(p, c) (((regnode_charclass_posixl*) (p))->classflags |= (1U << (c))) #define ANYOF_CLASS_SET(p, c) ANYOF_POSIXL_SET((p), (c)) -#define ANYOF_POSIXL_CLEAR(p, c) (((struct regnode_charclass_class*) (p))->classflags &= ~ (1U <<(c))) +#define ANYOF_POSIXL_CLEAR(p, c) (((regnode_charclass_posixl*) (p))->classflags &= ~ (1U <<(c))) #define ANYOF_CLASS_CLEAR(p, c) ANYOF_POSIXL_CLEAR((p), (c)) -#define ANYOF_POSIXL_TEST(p, c) (((struct regnode_charclass_class*) (p))->classflags & (1U << (c))) +#define ANYOF_POSIXL_TEST(p, c) (((regnode_charclass_posixl*) (p))->classflags & (1U << (c))) #define ANYOF_CLASS_TEST(p, c) ANYOF_POSIXL_TEST((p), (c)) -#define ANYOF_POSIXL_ZERO(ret) STMT_START { ((struct regnode_charclass_class*) (ret))->classflags = 0; } STMT_END +#define ANYOF_POSIXL_ZERO(ret) STMT_START { ((regnode_charclass_posixl*) (ret))->classflags = 0; } STMT_END #define ANYOF_CLASS_ZERO(ret) ANYOF_POSIXL_ZERO(ret) /* Shifts a bit to get, eg. 0x4000_0000, then subtracts 1 to get 0x3FFF_FFFF */ -#define ANYOF_POSIXL_SETALL(ret) STMT_START { ((struct regnode_charclass_class*) (ret))->classflags = ((1U << ((ANYOF_POSIXL_MAX) - 1))) - 1; } STMT_END +#define ANYOF_POSIXL_SETALL(ret) STMT_START { ((regnode_charclass_posixl*) (ret))->classflags = ((1U << ((ANYOF_POSIXL_MAX) - 1))) - 1; } STMT_END #define ANYOF_CLASS_SETALL(ret) ANYOF_POSIXL_SETALL(ret) #define ANYOF_POSIXL_TEST_ANY_SET(p) \ ((ANYOF_FLAGS(p) & ANYOF_POSIXL) \ - && (((struct regnode_charclass_class*)(p))->classflags)) + && (((regnode_charclass_posixl*)(p))->classflags)) #define ANYOF_CLASS_TEST_ANY_SET(p) ANYOF_POSIXL_TEST_ANY_SET(p) #define ANYOF_POSIXL_OR(source, dest) STMT_START { (dest)->classflags |= (source)->classflags ; } STMT_END -- 2.7.4