Previously it would not take special action if the offset requested happened to
be the end of the string, meaning that the (fixed size) UTF-8 offset cache
would be used for a value which could (and should) be stored elsewhere.
}
*offsetp = len;
- if (PL_utf8cache)
- utf8_mg_pos_cache_update(sv, &mg, byte, len, blen);
+ if (PL_utf8cache) {
+ if (blen == byte)
+ utf8_mg_len_cache_update(sv, &mg, len);
+ else
+ utf8_mg_pos_cache_update(sv, &mg, byte, len, blen);
+ }
}
/*
require './test.pl';
}
-plan tests => 6;
+plan tests => 7;
$x='banana';
$x=~/.a/g;
is(pos($x), 4);
{ local $x }
is(pos($x), 4);
+
+# Explict test that triggers the utf8_mg_len_cache_update() code path in
+# Perl_sv_pos_b2u().
+
+$x = "\x{100}BC";
+$x =~ m/.*/g;
+is(pos $x, 3);
+