Fix marker debugging code.
authorDmitry Antipov <dmantipov@yandex.ru>
Fri, 6 Jul 2012 14:16:54 +0000 (18:16 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Fri, 6 Jul 2012 14:16:54 +0000 (18:16 +0400)
* marker.c (byte_char_debug_check): Do not perform the check
if buffer is not multibyte.
(buf_charpos_to_bytepos, buf_bytepos_to_charpos): Call
byte_char_debug_check with correct arguments.

src/ChangeLog
src/marker.c

index 986c398..cfc4a00 100644 (file)
@@ -1,3 +1,11 @@
+2012-07-06  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       Fix marker debugging code.
+       * marker.c (byte_char_debug_check): Do not perform the check
+       if buffer is not multibyte.
+       (buf_charpos_to_bytepos, buf_bytepos_to_charpos): Call
+       byte_char_debug_check with correct arguments.
+
 2012-07-06  Dmitry Antipov  <dmantipov@yandex.ru>
 
        Compile marker debugging code only if ENABLE_CHECKING is defined.
index ac444fc..ba98a78 100644 (file)
@@ -38,15 +38,17 @@ extern int count_markers (struct buffer *) EXTERNALLY_VISIBLE;
 static void
 byte_char_debug_check (struct buffer *b, ptrdiff_t charpos, ptrdiff_t bytepos)
 {
-  ptrdiff_t nchars = 0;
+  ptrdiff_t nchars;
+
+  if (NILP (BVAR (b, enable_multibyte_characters)))
+    return;
 
   if (bytepos > BUF_GPT_BYTE (b))
-    {
-      nchars = multibyte_chars_in_text (BUF_BEG_ADDR (b),
-                                       BUF_GPT_BYTE (b) - BUF_BEG_BYTE (b));
-      nchars += multibyte_chars_in_text (BUF_GAP_END_ADDR (b),
-                                        bytepos - BUF_GPT_BYTE (b));
-    }
+    nchars
+      = multibyte_chars_in_text (BUF_BEG_ADDR (b),
+                                BUF_GPT_BYTE (b) - BUF_BEG_BYTE (b))
+      + multibyte_chars_in_text (BUF_GAP_END_ADDR (b),
+                                bytepos - BUF_GPT_BYTE (b));
   else
     nchars = multibyte_chars_in_text (BUF_BEG_ADDR (b),
                                      bytepos - BUF_BEG_BYTE (b));
@@ -197,7 +199,7 @@ buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos)
       if (record)
        build_marker (b, best_below, best_below_byte);
 
-      byte_char_debug_check (b, charpos, best_below_byte);
+      byte_char_debug_check (b, best_below, best_below_byte);
 
       cached_buffer = b;
       cached_modiff = BUF_MODIFF (b);
@@ -222,7 +224,7 @@ buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos)
       if (record)
        build_marker (b, best_above, best_above_byte);
 
-      byte_char_debug_check (b, charpos, best_above_byte);
+      byte_char_debug_check (b, best_above, best_above_byte);
 
       cached_buffer = b;
       cached_modiff = BUF_MODIFF (b);
@@ -363,7 +365,7 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos)
       if (record && BUF_MARKERS (b))
        build_marker (b, best_below, best_below_byte);
 
-      byte_char_debug_check (b, best_below, bytepos);
+      byte_char_debug_check (b, best_below, best_below_byte);
 
       cached_buffer = b;
       cached_modiff = BUF_MODIFF (b);
@@ -390,7 +392,7 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos)
       if (record && BUF_MARKERS (b))
        build_marker (b, best_above, best_above_byte);
 
-      byte_char_debug_check (b, best_above, bytepos);
+      byte_char_debug_check (b, best_above, best_above_byte);
 
       cached_buffer = b;
       cached_modiff = BUF_MODIFF (b);