diff options
| author | Eli Zaretskii | 2018-06-15 11:27:56 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2018-06-15 11:27:56 +0300 |
| commit | 0d3c35807d0b0a3aaa4c4ebd2f040bb78013879d (patch) | |
| tree | 3d1e838f66004370736692bef8c3c8eb8f03d1db /src | |
| parent | c79a6275b2f3bc529f9e7e9a65dc56fbd30364d9 (diff) | |
| download | emacs-0d3c35807d0b0a3aaa4c4ebd2f040bb78013879d.tar.gz emacs-0d3c35807d0b0a3aaa4c4ebd2f040bb78013879d.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/editfns.c b/src/editfns.c index b553a213e6c..fc5b6c117f5 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3304,8 +3304,17 @@ buffer_chars_equal (struct context *ctx, | |||
| 3304 | eassert (pos_b >= BUF_BEGV (ctx->buffer_b)); | 3304 | eassert (pos_b >= BUF_BEGV (ctx->buffer_b)); |
| 3305 | eassert (pos_b < BUF_ZV (ctx->buffer_b)); | 3305 | eassert (pos_b < BUF_ZV (ctx->buffer_b)); |
| 3306 | 3306 | ||
| 3307 | return BUF_FETCH_CHAR_AS_MULTIBYTE (ctx->buffer_a, pos_a) | 3307 | ptrdiff_t bpos_a = |
| 3308 | == BUF_FETCH_CHAR_AS_MULTIBYTE (ctx->buffer_b, pos_b); | 3308 | NILP (BVAR (ctx->buffer_a, enable_multibyte_characters)) |
| 3309 | ? pos_a | ||
| 3310 | : buf_charpos_to_bytepos (ctx->buffer_a, pos_a); | ||
| 3311 | ptrdiff_t bpos_b = | ||
| 3312 | NILP (BVAR (ctx->buffer_b, enable_multibyte_characters)) | ||
| 3313 | ? pos_b | ||
| 3314 | : buf_charpos_to_bytepos (ctx->buffer_b, pos_b); | ||
| 3315 | |||
| 3316 | return BUF_FETCH_CHAR_AS_MULTIBYTE (ctx->buffer_a, bpos_a) | ||
| 3317 | == BUF_FETCH_CHAR_AS_MULTIBYTE (ctx->buffer_b, bpos_b); | ||
| 3309 | } | 3318 | } |
| 3310 | 3319 | ||
| 3311 | 3320 | ||