emacs-diffs
[Top][All Lists]
Advanced

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

master 4c9a7010bc: Correctly encode and decode filenames on NS


From: Po Lu
Subject: master 4c9a7010bc: Correctly encode and decode filenames on NS
Date: Wed, 4 May 2022 03:31:58 -0400 (EDT)

branch: master
commit 4c9a7010bc553abb07ccc3c998faff9cf4472ed1
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Correctly encode and decode filenames on NS
    
    * src/nsfns.m (Fns_read_file_name): Run dir through ENCODE_FILE
    and fname through DECODE_FILE.
---
 src/nsfns.m | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/nsfns.m b/src/nsfns.m
index 41fea6f0fe..a67dafe095 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1677,16 +1677,18 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only 
directories.  */)
   BOOL isSave = NILP (mustmatch) && NILP (dir_only_p);
   id panel;
   Lisp_Object fname = Qnil;
-
-  NSString *promptS = NILP (prompt) || !STRINGP (prompt) ? nil :
-    [NSString stringWithLispString:prompt];
-  NSString *dirS = NILP (dir) || !STRINGP (dir) ?
-    [NSString stringWithLispString:BVAR (current_buffer, directory)] :
-    [NSString stringWithLispString:dir];
-  NSString *initS = NILP (init) || !STRINGP (init) ? nil :
-    [NSString stringWithLispString:init];
+  NSString *promptS, *dirS, *initS, *str;
   NSEvent *nxev;
 
+  promptS = (NILP (prompt) || !STRINGP (prompt)
+            ? nil : [NSString stringWithLispString: prompt]);
+  dirS = (NILP (dir) || !STRINGP (dir)
+         ? [NSString stringWithLispString:
+                       ENCODE_FILE (BVAR (current_buffer, directory))] :
+         [NSString stringWithLispString: ENCODE_FILE (dir)]);
+  initS = (NILP (init) || !STRINGP (init)
+          ? nil : [NSString stringWithLispString: init]);
+
   check_window_system (NULL);
 
   if (fileDelegate == nil)
@@ -1758,9 +1760,15 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only 
directories.  */)
 
   if (ns_fd_data.ret == MODAL_OK_RESPONSE)
     {
-      NSString *str = ns_filename_from_panel (panel);
-      if (! str) str = ns_directory_from_panel (panel);
-      if (str) fname = [str lispString];
+      str = ns_filename_from_panel (panel);
+
+      if (!str)
+       str = ns_directory_from_panel (panel);
+      if (str)
+       fname = [str lispString];
+
+      if (!NILP (fname))
+       fname = DECODE_FILE (fname);
     }
 
   [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow];



reply via email to

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