45 lines
1.3 KiB
Diff
45 lines
1.3 KiB
Diff
|
--- perl-5.8.8/t/op/index.t.U27116 2005-10-31 09:11:17.000000000 -0500
|
||
|
+++ perl-5.8.8/t/op/index.t 2006-06-01 18:20:53.000000000 -0400
|
||
|
@@ -7,7 +7,7 @@
|
||
|
|
||
|
use strict;
|
||
|
require './test.pl';
|
||
|
-plan( tests => 58 );
|
||
|
+plan( tests => 66 );
|
||
|
|
||
|
my $foo = 'Now is the time for all good men to come to the aid of their country.';
|
||
|
|
||
|
@@ -121,3 +121,15 @@
|
||
|
is (index($text, $search_octets), -1);
|
||
|
is (rindex($text, $search_octets), -1);
|
||
|
}
|
||
|
+
|
||
|
+foreach my $utf8 ('', ', utf-8') {
|
||
|
+ foreach my $arraybase (0, 1, -1, -2) {
|
||
|
+ my $expect_pos = 2 + $arraybase;
|
||
|
+
|
||
|
+ my $prog = "\$[ = $arraybase; \$big = \"N\\xabN\\xab\"; ";
|
||
|
+ $prog .= '$big .= chr 256; chop $big; ' if $utf8;
|
||
|
+ $prog .= 'print rindex $big, "N", 2 + $[';
|
||
|
+
|
||
|
+ fresh_perl_is($prog, $expect_pos, {}, "\$[ = $arraybase$utf8");
|
||
|
+ }
|
||
|
+}
|
||
|
--- perl-5.8.8/pp.c.U27116 2006-06-01 17:04:25.000000000 -0400
|
||
|
+++ perl-5.8.8/pp.c 2006-06-01 18:19:16.000000000 -0400
|
||
|
@@ -3258,9 +3258,13 @@
|
||
|
if (MAXARG < 3)
|
||
|
offset = blen;
|
||
|
else {
|
||
|
+ /* arybase is in characters, like offset, so combine prior to the
|
||
|
+ UTF-8 to bytes calculation. */
|
||
|
+ offset -= arybase;
|
||
|
if (offset > 0 && big_utf8)
|
||
|
sv_pos_u2b(big, &offset, 0);
|
||
|
- offset = offset - arybase + llen;
|
||
|
+ /* llen is in bytes. */
|
||
|
+ offset += llen;
|
||
|
}
|
||
|
if (offset < 0)
|
||
|
offset = 0;
|