From 6c8b4f07d1ccde31589e46d3582cedaab8af8062 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sat, 19 Apr 2008 03:09:47 +0000 Subject: [PATCH] (directory_files_internal, file_name_completion): Only call ENCODE_FILE if the string is indeed decoded. --- src/ChangeLog | 5 +++++ src/dired.c | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index a853b6fe917..2afb3a412b3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-04-19 Stefan Monnier + + * dired.c (directory_files_internal, file_name_completion): + Only call ENCODE_FILE if the string is indeed decoded. + 2008-04-18 Stefan Monnier * Makefile.in (TOOLKIT_DEFINES): Remove. diff --git a/src/dired.c b/src/dired.c index 3efc87ac844..f8b8f2dc84a 100644 --- a/src/dired.c +++ b/src/dired.c @@ -193,8 +193,10 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format) /* Note: ENCODE_FILE and DECODE_FILE can GC because they can run run_pre_post_conversion_on_str which calls Lisp directly and indirectly. */ - dirfilename = ENCODE_FILE (dirfilename); - encoded_directory = ENCODE_FILE (directory); + if (STRING_MULTIBYTE (dirfilename)) + dirfilename = ENCODE_FILE (dirfilename); + encoded_directory = (STRING_MULTIBYTE (directory) + ? ENCODE_FILE (directory) : directory); /* Now *bufp is the compiled form of MATCH; don't call anything which might compile a new regexp until we're done with the loop! */ @@ -251,7 +253,7 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format) name = finalname = make_unibyte_string (dp->d_name, len); GCPRO2 (finalname, name); - /* Note: ENCODE_FILE can GC; it should protect its argument, + /* Note: DECODE_FILE can GC; it should protect its argument, though. */ name = DECODE_FILE (name); len = SBYTES (name); @@ -506,7 +508,7 @@ file_name_completion (file, dirname, all_flag, ver_flag, predicate) /* Do completion on the encoded file name because the other names in the directory are (we presume) encoded likewise. We decode the completed string at the end. */ - encoded_file = ENCODE_FILE (file); + encoded_file = STRING_MULTIBYTE (file) ? ENCODE_FILE (file) : file; encoded_dir = ENCODE_FILE (dirname); -- 2.39.5