diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-03-23 16:25:51 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-03-23 16:25:51 +0000 |
commit | a922f900a6916d70770b1348cbacd5ea3df02a9f (patch) | |
tree | 0292cb6518cdda25a9e272f45d98db0e7742867d /sv.c | |
parent | b308eaac984433b634f42b8721523057190cf20c (diff) | |
download | perl-a922f900a6916d70770b1348cbacd5ea3df02a9f.tar.gz |
Rejig the location of the cache assertion code in Perl_sv_pos_b2u().
p4raw-id: //depot/perl@27588
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 35 |
1 files changed, 18 insertions, 17 deletions
@@ -5776,6 +5776,7 @@ Perl_sv_pos_b2u(pTHX_ register SV* sv, I32* offsetp) STRLEN blen; MAGIC* mg = NULL; const U8* send; + bool found = FALSE; if (!sv) return; @@ -5830,27 +5831,27 @@ Perl_sv_pos_b2u(pTHX_ register SV* sv, I32* offsetp) } ASSERT_UTF8_CACHE(cache); - if (PL_utf8cache < 0) { - const STRLEN reallen = S_sv_pos_b2u_forwards(aTHX_ s, send); - - if (len != reallen) { - /* Need to turn the assertions off otherwise we may recurse - infinitely while printing error messages. */ - SAVEI8(PL_utf8cache); - PL_utf8cache = 0; - Perl_croak(aTHX_ "panic: sv_pos_b2u cache %"UVf - " real %"UVf" for %"SVf, - (UV) len, (UV) reallen, sv); - } - } + found = TRUE; } else if (mg->mg_len != -1) { len = S_sv_pos_b2u_midway(aTHX_ s, send, s + blen, mg->mg_len); - } else { - len = S_sv_pos_b2u_forwards(aTHX_ s, send); + found = TRUE; } } - else { - len = S_sv_pos_b2u_forwards(aTHX_ s, send); + if (!found || PL_utf8cache < 0) { + const STRLEN real_len = S_sv_pos_b2u_forwards(aTHX_ s, send); + + if (found && PL_utf8cache < 0) { + if (len != real_len) { + /* Need to turn the assertions off otherwise we may recurse + infinitely while printing error messages. */ + SAVEI8(PL_utf8cache); + PL_utf8cache = 0; + Perl_croak(aTHX_ "panic: sv_pos_b2u cache %"UVf + " real %"UVf" for %"SVf, + (UV) len, (UV) real_len, sv); + } + } + len = real_len; } *offsetp = len; |