eassert (pos_b >= BUF_BEGV (ctx->buffer_b));
eassert (pos_b < BUF_ZV (ctx->buffer_b));
- return BUF_FETCH_CHAR_AS_MULTIBYTE (ctx->buffer_a, pos_a)
- == BUF_FETCH_CHAR_AS_MULTIBYTE (ctx->buffer_b, pos_b);
+ ptrdiff_t bpos_a =
+ NILP (BVAR (ctx->buffer_a, enable_multibyte_characters))
+ ? pos_a
+ : buf_charpos_to_bytepos (ctx->buffer_a, pos_a);
+ ptrdiff_t bpos_b =
+ NILP (BVAR (ctx->buffer_b, enable_multibyte_characters))
+ ? pos_b
+ : buf_charpos_to_bytepos (ctx->buffer_b, pos_b);
+
+ return BUF_FETCH_CHAR_AS_MULTIBYTE (ctx->buffer_a, bpos_a)
+ == BUF_FETCH_CHAR_AS_MULTIBYTE (ctx->buffer_b, bpos_b);
}
\f
(buffer-string)
"foo bar baz qux"))))))
+(ert-deftest replace-buffer-contents-bug31837 ()
+ (switch-to-buffer "a")
+ (insert-char (char-from-name "SMILE"))
+ (insert "1234")
+ (switch-to-buffer "b")
+ (insert-char (char-from-name "SMILE"))
+ (insert "5678")
+ (replace-buffer-contents "a")
+ (should (equal (buffer-substring-no-properties (point-min) (point-max))
+ (concat (string (char-from-name "SMILE")) "1234"))))
+
(ert-deftest delete-region-undo-markers-1 ()
"Make sure we don't end up with freed markers reachable from Lisp."
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30931#40