mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-17 10:06:13 +00:00
Fix 'replace-buffer-contents' in multibyte buffers
* src/editfns.c (buffer_chars_equal): Pass a byte position to BUF_FETCH_CHAR_AS_MULTIBYTE, not a character position. (Bug#31837) * test/src/editfns-tests.el (replace-buffer-contents-bug31837): New test.
This commit is contained in:
parent
c79a6275b2
commit
0d3c35807d
@ -3304,8 +3304,17 @@ buffer_chars_equal (struct context *ctx,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -247,6 +247,17 @@
|
||||
(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
|
||||
|
Loading…
Reference in New Issue
Block a user