Change 27588 by [EMAIL PROTECTED] on 2006/03/23 16:25:51

        Rejig the location of the cache assertion code in Perl_sv_pos_b2u().

Affected files ...

... //depot/perl/sv.c#1211 edit

Differences ...

==== //depot/perl/sv.c#1211 (text) ====
Index: perl/sv.c
--- perl/sv.c#1210~27586~       2006-03-23 06:31:28.000000000 -0800
+++ perl/sv.c   2006-03-23 08:25:51.000000000 -0800
@@ -5776,6 +5776,7 @@
     STRLEN blen;
     MAGIC* mg = NULL;
     const U8* send;
+    bool found = FALSE;
 
     if (!sv)
        return;
@@ -5830,27 +5831,27 @@
 
            }
            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;
 
End of Patch.

Reply via email to