emacs-diffs
[Top][All Lists]
Advanced

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

master 46a2e5dc93: * src/dired.c (directory_files_internal): Fix bug#564


From: Stefan Monnier
Subject: master 46a2e5dc93: * src/dired.c (directory_files_internal): Fix bug#56469
Date: Sun, 10 Jul 2022 10:13:38 -0400 (EDT)

branch: master
commit 46a2e5dc93ccbb36309f859460cb527c91adc4d1
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * src/dired.c (directory_files_internal): Fix bug#56469
    
    Avoid concatenating encoded and decoded file names.
---
 src/dired.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/dired.c b/src/dired.c
index 6bb8c2fcb9..9aeff51636 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -219,6 +219,13 @@ directory_files_internal (Lisp_Object directory, 
Lisp_Object full,
     }
 #endif
 
+  if (!NILP (full) && !STRING_MULTIBYTE (directory))
+    { /* We will be concatenating 'directory' with local file name.
+         We always decode local file names, so in order to safely concatenate
+         them we need 'directory' to be decoded as well (bug#56469).  */
+      directory = DECODE_FILE (directory);
+    }
+
   ptrdiff_t directory_nbytes = SBYTES (directory);
   re_match_object = Qt;
 
@@ -263,9 +270,10 @@ directory_files_internal (Lisp_Object directory, 
Lisp_Object full,
          ptrdiff_t name_nbytes = SBYTES (name);
          ptrdiff_t nbytes = directory_nbytes + needsep + name_nbytes;
          ptrdiff_t nchars = SCHARS (directory) + needsep + SCHARS (name);
-         finalname = make_uninit_multibyte_string (nchars, nbytes);
-         if (nchars == nbytes)
-           STRING_SET_UNIBYTE (finalname);
+         /* FIXME: Why not make them all multibyte?  */
+         finalname = (nchars == nbytes)
+                     ? make_uninit_string (nbytes)
+                     : make_uninit_multibyte_string (nchars, nbytes);
          memcpy (SDATA (finalname), SDATA (directory), directory_nbytes);
          if (needsep)
            SSET (finalname, directory_nbytes, DIRECTORY_SEP);



reply via email to

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