diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2003-03-16 15:12:00 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2003-03-16 15:12:00 +0000 |
commit | 0eda9292bc85e7f943d7a8738310d47e93f67325 (patch) | |
tree | 2fa61e5e926f651949e806dad18738e53cf7844a /regcomp.c | |
parent | 17ba578bf41cdb4933f7c577f6b4ba5403154874 (diff) | |
download | perl-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.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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 { |