emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master e18c24b: Set last-coding-system-used upon ASCII conversion bypass


From: Mattias Engdegård
Subject: master e18c24b: Set last-coding-system-used upon ASCII conversion bypass (bug#40407)
Date: Thu, 9 Apr 2020 10:21:39 -0400 (EDT)

branch: master
commit e18c24b35a7cf9bb1b91288b706fa448ed28a7c2
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    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.
---
 src/coding.c             | 14 +++++++++-----
 test/src/coding-tests.el |  3 ++-
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/coding.c b/src/coding.c
index 450c498..9848f98 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -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))
     {
diff --git a/test/src/coding-tests.el b/test/src/coding-tests.el
index 9f6fac3..a741e23 100644
--- a/test/src/coding-tests.el
+++ b/test/src/coding-tests.el
@@ -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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]