emacs-diffs
[Top][All Lists]
Advanced

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

master 42d4537: Really convert to multibyte in Fdirectory_append


From: Lars Ingebrigtsen
Subject: master 42d4537: Really convert to multibyte in Fdirectory_append
Date: Sat, 24 Jul 2021 12:53:47 -0400 (EDT)

branch: master
commit 42d4537ed2cae41c969f59b413b4b9adae6dbc9b
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Really convert to multibyte in Fdirectory_append
    
    * src/fileio.c (Fdirectory_append): Fix check for whether we need
    to convert to multibyte.
    (Fdirectory_append):
---
 src/fileio.c             | 3 +--
 test/src/fileio-tests.el | 5 +++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/fileio.c b/src/fileio.c
index 60f5650..6d505fd 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -799,8 +799,7 @@ usage: (record DIRECTORY &rest COMPONENTS) */)
          if (STRING_MULTIBYTE (arg) || string_ascii_p (arg))
            elements[i] = arg;
          else
-           elements[i] = make_multibyte_string (SSDATA (arg), SCHARS (arg),
-                                                SCHARS (arg));
+           elements[i] = Fstring_to_multibyte (arg);
          arg = elements[i];
          /* We have to recompute the number of bytes. */
          if (i == nargs - 1
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el
index 702659f..73a7775 100644
--- a/test/src/fileio-tests.el
+++ b/test/src/fileio-tests.el
@@ -170,6 +170,11 @@ Also check that an encoding error can appear in a symlink."
   (should (equal (directory-append "fóo" "bar") "fóo/bar"))
   (should (equal (directory-append "foo" "bár") "foo/bár"))
   (should (equal (directory-append "fóo" "bár") "fóo/bár"))
+  (let ((string (make-string 5 ?a)))
+    (should (not (multibyte-string-p string)))
+    (aset string 2 255)
+    (should (not (multibyte-string-p string)))
+    (should (equal (directory-append "fóo" string) "fóo/aa\377aa")))
   (should-error (directory-append "foo" ""))
   (should-error (directory-append "" "bar"))
   (should-error (directory-append "" "")))



reply via email to

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