Subject: bug#64253: 26.3; Bug in revert-buffer-with-coding-system

From: Eli Zaretskii <[email-masked]>
Date: Sat, 24 Jun 2023 11:51:39 +0300

> Cc: meta1729 <[email-masked]>
> Date: Fri, 23 Jun 2023 12:43:19 +0530 (IST)
> From: meta1729 <[email-masked]>
> 
> 
> When a buffer is terminated with an un-encodable character,
> revert-buffer-with-coding-system modifies the buffer in unexpected
> ways when coding system of the buffer is changed from default
> iso-latin-1-unix to utf-8-unix, when the visited file contains
> characters that cannot be encoded in either iso-latin-1-unix or
> utf-8-unix.
> 
> Procedure to reproduce the bug.
> 
> [Create a file which has un-encodable characters and some text between them.]
> $ echo 3b3b20410a3b3b20420aa80a3b3b20430a3b3b20440aa9 | xxd -r -p > sample
> 
> Open in Emacs.
> $ emacs -q -nw --no-site-file -nsl sample
> 
> Enter: C-h C [describe-coding-system]
> Output:
> Coding system for saving this buffer:
>   1 -- iso-latin-1-unix (alias: iso-8859-1-unix latin-1-unix)
> 
> Enter: M-x revert-buffer-with-coding-system RET utf-8 RET yes
> 
> [The buffer has been incorrectly modified.  You can see escaped
> character code at the beginning of buffer, which previously existed at
> the end of the buffer.]

Thanks.  This 21-year old bug (a simple omission of a single code
line) should now be fixed on the emacs-29 branch.