1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-15 09:47:20 +00:00

Set last-coding-system-used upon ASCII conversion bypass (bug#40407)

Spotted by Kazuhiro Ito.

* src/coding.c (code_convert_string):
Set Vlast_coding_system if appropriate.
* test/src/coding-tests.el (coding-nocopy-ascii): Add test.
This commit is contained in:
Mattias Engdegård 2020-04-09 16:19:14 +02:00
parent 50618cc303
commit e18c24b35a
2 changed files with 11 additions and 6 deletions

View File

@ -9527,11 +9527,15 @@ code_convert_string (Lisp_Object string, Lisp_Object coding_system,
&& (EQ (CODING_ID_EOL_TYPE (coding.id), Qunix)
|| inhibit_eol_conversion
|| ! memchr (SDATA (string), encodep ? '\n' : '\r', bytes)))
return (nocopy
? string
: (encodep
? make_unibyte_string (SSDATA (string), bytes)
: make_multibyte_string (SSDATA (string), bytes, bytes)));
{
if (! norecord)
Vlast_coding_system_used = coding_system;
return (nocopy
? string
: (encodep
? make_unibyte_string (SSDATA (string), bytes)
: make_multibyte_string (SSDATA (string), bytes, bytes)));
}
}
else if (BUFFERP (dst_object))
{

View File

@ -393,7 +393,8 @@
(should-not (eq (decode-coding-string s coding nil) s))
(should-not (eq (encode-coding-string s coding nil) s))
(should (eq (decode-coding-string s coding t) s))
(should (eq (encode-coding-string s coding t) s)))
(should (eq (encode-coding-string s coding t) s))
(should (eq last-coding-system-used coding)))
;; With EOL conversion inhibited.
(let ((inhibit-eol-conversion t))