From: Dmitry Antipov Date: Fri, 6 Jul 2012 14:16:54 +0000 (+0400) Subject: Fix marker debugging code. X-Git-Tag: emacs-24.2.90~1199^2~176 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9d44f8ce16669f862eb901435593193c54ac09dd;p=emacs.git 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. --- diff --git a/src/ChangeLog b/src/ChangeLog index 986c398b7fc..cfc4a00512f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2012-07-06 Dmitry Antipov + + 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 Compile marker debugging code only if ENABLE_CHECKING is defined. diff --git a/src/marker.c b/src/marker.c index ac444fcec08..ba98a78f0e4 100644 --- a/src/marker.c +++ b/src/marker.c @@ -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);