From eff8b7dc9a14f3aa38ddb85d01d614da4c6d8957 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Mon, 30 Dec 2013 15:04:37 -0700 Subject: [PATCH] regcomp.c: Split #define into two The syntethic start class regnode (SSC) and a bracketed character class node share much of the same data structure, including a flags field, and some of the same flag bits within it. Currently, only locale-related flags (under /l rules) are the same between the two during construction of the SSC. But a future commit will introduce another common flag. This commit creates an extra #define for use where we want the common flags, while retaining the existing one for use where we want the locale flags. The new #define is just a copy of the existing one, to be changed in the future commit. --- regcomp.c | 10 +++++----- regcomp.h | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/regcomp.c b/regcomp.c index ec9c6ed..eda2257 100644 --- a/regcomp.c +++ b/regcomp.c @@ -1075,12 +1075,12 @@ S_ssc_flags_and(regnode_ssc *ssc, const U8 and_with) * The flags 'and_with' should not come from another SSC (otherwise the * EMPTY_STRING flag won't work) */ - const U8 ssc_only_flags = ANYOF_FLAGS(ssc) & ~ANYOF_LOCALE_FLAGS; + const U8 ssc_only_flags = ANYOF_FLAGS(ssc) & ~ANYOF_COMMON_FLAGS; PERL_ARGS_ASSERT_SSC_FLAGS_AND; /* Use just the SSC-related flags from 'and_with' */ - ANYOF_FLAGS(ssc) &= (and_with & ANYOF_LOCALE_FLAGS); + ANYOF_FLAGS(ssc) &= (and_with & ANYOF_COMMON_FLAGS); ANYOF_FLAGS(ssc) |= ssc_only_flags; } @@ -1111,7 +1111,7 @@ S_ssc_and(pTHX_ const RExC_state_t *pRExC_state, regnode_ssc *ssc, else { anded_cp_list = get_ANYOF_cp_list_for_ssc(pRExC_state, (regnode_charclass_posixl*) and_with); - anded_flags = ANYOF_FLAGS(and_with) & ANYOF_LOCALE_FLAGS; + anded_flags = ANYOF_FLAGS(and_with) & ANYOF_COMMON_FLAGS; } ANYOF_FLAGS(ssc) &= anded_flags; @@ -1260,7 +1260,7 @@ S_ssc_or(pTHX_ const RExC_state_t *pRExC_state, regnode_ssc *ssc, else { ored_cp_list = get_ANYOF_cp_list_for_ssc(pRExC_state, (regnode_charclass_posixl*) or_with); - ored_flags = ANYOF_FLAGS(or_with) & ANYOF_LOCALE_FLAGS; + ored_flags = ANYOF_FLAGS(or_with) & ANYOF_COMMON_FLAGS; } ANYOF_FLAGS(ssc) |= ored_flags; @@ -1397,7 +1397,7 @@ S_ssc_finalize(pTHX_ RExC_state_t *pRExC_state, regnode_ssc *ssc) /* The code in this file assumes that all but these flags aren't relevant * to the SSC, except ANYOF_EMPTY_STRING, which should be cleared by the * time we reach here */ - assert(! (ANYOF_FLAGS(ssc) & ~ANYOF_LOCALE_FLAGS)); + assert(! (ANYOF_FLAGS(ssc) & ~ANYOF_COMMON_FLAGS)); populate_ANYOF_from_invlist( (regnode *) ssc, &invlist); diff --git a/regcomp.h b/regcomp.h index 0967af5..fb24579 100644 --- a/regcomp.h +++ b/regcomp.h @@ -370,6 +370,11 @@ struct regnode_ssc { |ANYOF_LOC_FOLD \ |ANYOF_POSIXL) +/* These are the flags that apply to both regular ANYOF nodes and synthetic + * start class nodes during construction of the SSC. During finalization of + * the SSC, other of the flags could be added to it */ +#define ANYOF_COMMON_FLAGS (ANYOF_LOCALE_FLAGS) + /* Character classes for node->classflags of ANYOF */ /* Should be synchronized with a table in regprop() */ /* 2n should be the normal one, paired with its complement at 2n+1 */ -- 2.7.4