Better patch from Inaba Hiroto for
Jarkko Hietaniemi [Sat, 31 May 2003 17:37:36 +0000 (17:37 +0000)]
[perl #22375] 'split'/'index' problem for utf8

p4raw-id: //depot/perl@19648

sv.c

diff --git a/sv.c b/sv.c
index d6ae16c..d7487ee 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -5947,12 +5947,16 @@ Perl_sv_pos_b2u(pTHX_ register SV* sv, I32* offsetp)
 
                        while (backw--) {
                            p--;
-                           while (UTF8_IS_CONTINUATION(*p))
+                           while (UTF8_IS_CONTINUATION(*p)) {
                                p--;
+                               backw--;
+                           }
                            ubackw++;
                        }
 
                        cache[0] -= ubackw;
+                       *offsetp = cache[0];
+                       return;
                    }
                }
            }