+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.
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));
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);
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);
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);
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);