summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2011-12-23 18:51:45 -0700
committerKarl Williamson <public@khwilliamson.com>2012-01-19 11:58:18 -0700
commitf646642f35679c7859c80485da40c0d146e5550c (patch)
treec9f0a11f43aae78756219df58e5880fd786b3819 /regcomp.c
parente22b340a2e08cb60ead800f83a4e05a34a035593 (diff)
downloadperl-f646642f35679c7859c80485da40c0d146e5550c.tar.gz
regcomp.c: Change param to join_exact()
This changes a parameter to this function to instead of changing a running total, return the actual value computed by the function; and it changes the calling areas of code to compensate.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/regcomp.c b/regcomp.c
index f7bb10889a..11f1ca4ef1 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -2506,14 +2506,12 @@ S_make_trie_failtable(pTHX_ RExC_state_t *pRExC_state, regnode *source, regnode
-
-
-#define JOIN_EXACT(scan,min,flags) \
+#define JOIN_EXACT(scan,min_change,flags) \
if (PL_regkind[OP(scan)] == EXACT) \
- join_exact(pRExC_state,(scan),(min),(flags),NULL,depth+1)
+ join_exact(pRExC_state,(scan),(min_change),(flags),NULL,depth+1)
STATIC U32
-S_join_exact(pTHX_ RExC_state_t *pRExC_state, regnode *scan, I32 *min, U32 flags,regnode *val, U32 depth) {
+S_join_exact(pTHX_ RExC_state_t *pRExC_state, regnode *scan, IV *min_change, U32 flags,regnode *val, U32 depth) {
/* Merge several consecutive EXACTish nodes into one. */
regnode *n = regnext(scan);
U32 stringok = 1;
@@ -2595,6 +2593,8 @@ S_join_exact(pTHX_ RExC_state_t *pRExC_state, regnode *scan, I32 *min, U32 flags
#define GREEK_SMALL_LETTER_UPSILON_WITH_DIALYTIKA_AND_TONOS 0x03B0
#define UPSILON_D_T GREEK_SMALL_LETTER_UPSILON_WITH_DIALYTIKA_AND_TONOS
+ *min_change = 0;
+
/* Here, all the adjacent mergeable EXACTish nodes have been merged. We
* can now analyze for sequences of problematic code points. (Prior to
* this final joining, sequences could have been split over boundaries, and
@@ -2652,7 +2652,7 @@ S_join_exact(pTHX_ RExC_state_t *pRExC_state, regnode *scan, I32 *min, U32 flags
if (((U8)t[-1] == 0xB9 && (U8)t[-2] == 0xCE) ||
((U8)t[-1] == 0x85 && (U8)t[-2] == 0xCF))
#endif
- *min -= 4;
+ *min_change -= 4;
}
}
@@ -2769,10 +2769,11 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
fake_study_recurse:
while ( scan && OP(scan) != END && scan < last ){
+ IV min_change = 0;
/* Peephole optimizer: */
DEBUG_STUDYDATA("Peep:", data,depth);
DEBUG_PEEP("Peep",scan,depth);
- JOIN_EXACT(scan,&min,0);
+ JOIN_EXACT(scan,&min_change,0);
/* Follow the next-chain of the current node and optimize
away all the NOTHINGs from it. */
@@ -3286,9 +3287,16 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
l = utf8_length(s, s + l);
uc = utf8_to_uvchr(s, NULL);
}
- min += l;
- if (flags & SCF_DO_SUBSTR)
- data->pos_min += l;
+ min += l + min_change;
+ if (min < 0) {
+ min = 0;
+ }
+ if (flags & SCF_DO_SUBSTR) {
+ data->pos_min += l + min_change;
+ if (data->pos_min < 0) {
+ data->pos_min = 0;
+ }
+ }
if (flags & SCF_DO_STCLASS_AND) {
/* Check whether it is compatible with what we know already! */
int compat = 1;