summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-03-16 15:12:00 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-03-16 15:12:00 +0000
commit0eda9292bc85e7f943d7a8738310d47e93f67325 (patch)
tree2fa61e5e926f651949e806dad18738e53cf7844a /regcomp.c
parent17ba578bf41cdb4933f7c577f6b4ba5403154874 (diff)
downloadperl-0eda9292bc85e7f943d7a8738310d47e93f67325.tar.gz
Further potential pitfalls for the utf8 len/pos cache
found by Inaba Hiroto. No test cases, yet. p4raw-id: //depot/perl@18990
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/regcomp.c b/regcomp.c
index 2cd31ea173..c738714acf 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -495,6 +495,13 @@ S_scan_commit(pTHX_ RExC_state_t *pRExC_state, scan_data_t *data)
}
}
SvCUR_set(data->last_found, 0);
+ {
+ SV * sv = data->last_found;
+ MAGIC *mg =
+ SvUTF8(sv) && SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_utf8) : NULL;
+ if (mg && mg->mg_len > 0)
+ mg->mg_len = 0;
+ }
data->last_end = -1;
data->flags &= ~SF_BEFORE_EOL;
}
@@ -913,6 +920,14 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
? I32_MAX : data->pos_min + data->pos_delta;
}
sv_catpvn(data->last_found, STRING(scan), STR_LEN(scan));
+ {
+ SV * sv = data->last_found;
+ MAGIC *mg = SvUTF8(sv) && SvMAGICAL(sv) ?
+ mg_find(sv, PERL_MAGIC_utf8) : NULL;
+ if (mg && mg->mg_len >= 0)
+ mg->mg_len += utf8_length(STRING(scan),
+ STRING(scan)+STR_LEN(scan));
+ }
if (UTF)
SvUTF8_on(data->last_found);
data->last_end = data->pos_min + l;
@@ -1283,6 +1298,14 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
SvCUR_set(data->last_found,
SvCUR(data->last_found) - l);
sv_catsv(data->last_found, last_str);
+ {
+ SV * sv = data->last_found;
+ MAGIC *mg =
+ SvUTF8(sv) && SvMAGICAL(sv) ?
+ mg_find(sv, PERL_MAGIC_utf8) : NULL;
+ if (mg && mg->mg_len >= 0)
+ mg->mg_len += CHR_SVLEN(last_str);
+ }
data->last_end += l * (mincount - 1);
}
} else {