From: Karl Williamson Date: Thu, 15 Aug 2013 21:07:44 +0000 (-0600) Subject: Rename regex flag bit for clarity X-Git-Tag: upstream/5.20.0~1655 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b1eb0677ed31eb8828470cdf12198cc308a4998;p=platform%2Fupstream%2Fperl.git Rename regex flag bit for clarity ANYOF_UNICODE_ALL doesn't mean every Unicode code point. It means those above the Latin1 range. Rename it, while retaining the old one for back compat. --- diff --git a/regcomp.c b/regcomp.c index dfd1cff..096fc9f 100644 --- a/regcomp.c +++ b/regcomp.c @@ -818,7 +818,7 @@ S_ssc_anything(const RExC_state_t *pRExC_state, regnode_ssc *ssc) PERL_ARGS_ASSERT_SSC_ANYTHING; ANYOF_BITMAP_SETALL(ssc); - ssc->flags = ANYOF_UNICODE_ALL; + ssc->flags = ANYOF_ABOVE_LATIN1_ALL; SET_SSC_EOS(ssc); /* If any portion of the regex is to operate under locale rules, @@ -848,7 +848,7 @@ S_ssc_is_anything(const regnode_ssc *ssc) for (value = 0; value < ANYOF_POSIXL_MAX; value += 2) if (ANYOF_POSIXL_TEST(ssc, value) && ANYOF_POSIXL_TEST(ssc, value + 1)) return 1; - if (!(ssc->flags & ANYOF_UNICODE_ALL)) + if (!(ssc->flags & ANYOF_ABOVE_LATIN1_ALL)) return 0; if (!ANYOF_BITMAP_TESTALLSET((const void*)ssc)) return 0; @@ -914,8 +914,8 @@ S_ssc_and(pTHX_ const RExC_state_t *pRExC_state, regnode_ssc *ssc, const regnode /* The inversion of these two flags indicate that the resulting * intersection doesn't have them */ - if (and_with->flags & ANYOF_UNICODE_ALL) { - ssc->flags &= ~ANYOF_UNICODE_ALL; + if (and_with->flags & ANYOF_ABOVE_LATIN1_ALL) { + ssc->flags &= ~ANYOF_ABOVE_LATIN1_ALL; } if (and_with->flags & ANYOF_NON_UTF8_LATIN1_ALL) { ssc->flags &= ~ANYOF_NON_UTF8_LATIN1_ALL; @@ -927,12 +927,12 @@ S_ssc_and(pTHX_ const RExC_state_t *pRExC_state, regnode_ssc *ssc, const regnode if (! ANYOF_NONBITMAP(and_with)) { /* Here 'and_with' doesn't match anything outside the bitmap - * (except possibly ANYOF_UNICODE_ALL), which means the - * intersection can't either, except for ANYOF_UNICODE_ALL, in + * (except possibly ANYOF_ABOVE_LATIN1_ALL), which means the + * intersection can't either, except for ANYOF_ABOVE_LATIN1_ALL, in * which case we don't know what the intersection is, but it's no * greater than what ssc already has, so can just leave it alone, * with possible false positives */ - if (! (and_with->flags & ANYOF_UNICODE_ALL)) { + if (! (and_with->flags & ANYOF_ABOVE_LATIN1_ALL)) { ARG_SET(ssc, ANYOF_NONBITMAP_EMPTY); ssc->flags &= ~ANYOF_NONBITMAP_NON_UTF8; } @@ -947,7 +947,7 @@ S_ssc_and(pTHX_ const RExC_state_t *pRExC_state, regnode_ssc *ssc, const regnode * match anything outside the bitmap (since the 'if' that got us * into this block tested for that), so we leave the bitmap empty. */ - if (ssc->flags & ANYOF_UNICODE_ALL) { + if (ssc->flags & ANYOF_ABOVE_LATIN1_ALL) { ARG_SET(ssc, ARG(and_with)); /* and_with's ARG may match things that don't require UTF8. @@ -1035,7 +1035,7 @@ S_ssc_or(const RExC_state_t *pRExC_state, regnode_ssc *ssc, const regnode_ssc *o ssc->flags |= or_with->flags & INVERSION_UNAFFECTED_FLAGS; /* For the remaining flags: - ANYOF_UNICODE_ALL and inverted means to not match anything above + ANYOF_ABOVE_LATIN1_ALL and inverted means to not match anything above 255, which means that the union with ssc should just be what ssc has in it, so can ignore this flag ANYOF_NON_UTF8_LATIN1_ALL and inverted means if not utf8 and ord @@ -1079,7 +1079,7 @@ S_ssc_or(const RExC_state_t *pRExC_state, regnode_ssc *ssc, const regnode_ssc *o ssc_anything(pRExC_state, ssc); } else { - ssc->flags |= ANYOF_UNICODE_ALL; + ssc->flags |= ANYOF_ABOVE_LATIN1_ALL; } } } @@ -3665,14 +3665,14 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, } CLEAR_SSC_EOS(data->start_class); if (uc < 0x100) - data->start_class->flags &= ~ANYOF_UNICODE_ALL; + data->start_class->flags &= ~ANYOF_ABOVE_LATIN1_ALL; } else if (flags & SCF_DO_STCLASS_OR) { /* false positive possible if the class is case-folded */ if (uc < 0x100) ANYOF_BITMAP_SET(data->start_class, uc); else - data->start_class->flags |= ANYOF_UNICODE_ALL; + data->start_class->flags |= ANYOF_ABOVE_LATIN1_ALL; CLEAR_SSC_EOS(data->start_class); ssc_and(pRExC_state, data->start_class, and_withp); } @@ -11560,7 +11560,7 @@ S_populate_ANYOF_from_invlist(pTHX_ regnode *node, SV** invlist_ptr) int i; if (end == UV_MAX && start <= 256) { - ANYOF_FLAGS(node) |= ANYOF_UNICODE_ALL; + ANYOF_FLAGS(node) |= ANYOF_ABOVE_LATIN1_ALL; } /* Quit if are above what we should change */ @@ -11586,7 +11586,7 @@ S_populate_ANYOF_from_invlist(pTHX_ regnode *node, SV** invlist_ptr) if (change_invlist) { _invlist_subtract(*invlist_ptr, PL_Latin1, invlist_ptr); } - if (ANYOF_FLAGS(node) & ANYOF_UNICODE_ALL) { + if (ANYOF_FLAGS(node) & ANYOF_ABOVE_LATIN1_ALL) { _invlist_intersection(*invlist_ptr, PL_Latin1, invlist_ptr); } @@ -14962,7 +14962,7 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o) } /* output information about the unicode matching */ - if (flags & ANYOF_UNICODE_ALL) + if (flags & ANYOF_ABOVE_LATIN1_ALL) sv_catpvs(sv, "{unicode_all}"); else if (ANYOF_NONBITMAP(o)) { SV *lv; /* Set if there is something outside the bit map. */ diff --git a/regcomp.h b/regcomp.h index 5629990..4b3f892 100644 --- a/regcomp.h +++ b/regcomp.h @@ -315,13 +315,13 @@ struct regnode_ssc { /* Flags for node->flags of ANYOF. These are in short supply, but there is one * currently available. If more than this are needed, the ANYOF_LOCALE and * ANYOF_POSIXL bits could be shared, making a space penalty for all locale nodes. - * Also, the UNICODE_ALL bit could be freed up by resorting to creating a swash - * containing everything above 255. This introduces a performance penalty. - * Better would be to split it off into a separate node, which actually would - * improve performance a bit by allowing regexec.c to test for a UTF-8 - * character being above 255 without having to call a function nor calculate - * its code point value. However, this solution might need to have a second - * node type, ANYOF_SYNTHETIC_ABOVE_LATIN1_ALL */ + * Also, the ABOVE_LATIN1_ALL bit could be freed up by resorting to creating a + * swash containing everything above 255. This introduces a performance + * penalty. Better would be to split it off into a separate node, which + * actually would improve performance a bit by allowing regexec.c to test for a + * UTF-8 character being above 255 without having to call a function nor + * calculate its code point value. However, this solution might need to have a + * second node type, ANYOF_SYNTHETIC_ABOVE_LATIN1_ALL */ #define ANYOF_LOCALE 0x01 /* /l modifier */ @@ -348,7 +348,8 @@ struct regnode_ssc { #define ANYOF_NONBITMAP_NON_UTF8 0x20 /* Matches every code point 0x100 and above*/ -#define ANYOF_UNICODE_ALL 0x40 +#define ANYOF_ABOVE_LATIN1_ALL 0x40 +#define ANYOF_UNICODE_ALL ANYOF_ABOVE_LATIN1_ALL /* Match all Latin1 characters that aren't ASCII when the target string is not * in utf8. */ @@ -358,7 +359,7 @@ struct regnode_ssc { /* These are the flags that ANYOF_INVERT being set or not doesn't affect * whether they are operative or not. e.g., the node still has LOCALE - * regardless of being inverted; whereas ANYOF_UNICODE_ALL means something + * regardless of being inverted; whereas ANYOF_ABOVE_LATIN1_ALL means something * different if inverted */ #define INVERSION_UNAFFECTED_FLAGS (ANYOF_LOCALE \ |ANYOF_LOC_FOLD \ diff --git a/regexec.c b/regexec.c index 7b61357..fd9f01c 100644 --- a/regexec.c +++ b/regexec.c @@ -7505,7 +7505,7 @@ S_reginclass(pTHX_ regexp * const prog, const regnode * const n, const U8* const * positive that will be resolved when the match is done again as not part * of the synthetic start class */ if (!match) { - if (utf8_target && (flags & ANYOF_UNICODE_ALL) && c >= 256) { + if (utf8_target && (flags & ANYOF_ABOVE_LATIN1_ALL) && c >= 256) { match = TRUE; /* Everything above 255 matches */ } else if (ANYOF_NONBITMAP(n)