diff options
author | Dave Mitchell <davem@fdisolutions.com> | 2005-04-21 15:36:14 +0000 |
---|---|---|
committer | Dave Mitchell <davem@fdisolutions.com> | 2005-04-21 15:36:14 +0000 |
commit | ec0624293b57ae07d6b2c32bae099d4f163e7e07 (patch) | |
tree | 01d6b0ff58f43fa9a8d6808c0773376527f812a6 | |
parent | a9c4fd4eb137d3951b59e73b4474669240f974c1 (diff) | |
download | perl-ec0624293b57ae07d6b2c32bae099d4f163e7e07.tar.gz |
[perl #34976] substr uses utf8 length cache incorrectly
p4raw-id: //depot/perl@24270
-rw-r--r-- | sv.c | 2 | ||||
-rwxr-xr-x | t/op/substr.t | 9 |
2 files changed, 9 insertions, 2 deletions
@@ -6402,7 +6402,7 @@ Perl_sv_pos_u2b(pTHX_ register SV *sv, I32* offsetp, I32* lenp) if (lenp) { found = FALSE; start = s; - if (utf8_mg_pos(sv, &mg, &cache, 2, lenp, *lenp + *offsetp, &s, start, send)) { + if (utf8_mg_pos(sv, &mg, &cache, 2, lenp, *lenp, &s, start, send)) { *lenp -= boffset; found = TRUE; } diff --git a/t/op/substr.t b/t/op/substr.t index 9549d29028..2c6a0ed32e 100755 --- a/t/op/substr.t +++ b/t/op/substr.t @@ -1,6 +1,6 @@ #!./perl -print "1..190\n"; +print "1..192\n"; #P = start of string Q = start of substr R = end of substr S = end of string @@ -658,3 +658,10 @@ ok 174, $x eq "\x{100}\x{200}\xFFb"; substr($a, -1) &= chr(0xfeff); ok 190, $a eq "\xbf"; } + +# [perl #34976] incorrect caching of utf8 substr length +{ + my $a = "abcd\x{100}"; + ok 191, substr($a,1,2) eq 'bc'; + ok 192, substr($a,1,1) eq 'b'; +} |