aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Brown2018-07-27 14:24:01 -0400
committerKen Brown2018-07-27 17:22:23 -0400
commit81d6418e6b7c3e637dccf9c856d9c4b94bd43b97 (patch)
tree3184286a9067d69a44bc138d4b3130a57f27c88d
parent8c8bf7db62af2c80537b5760bea01f7da9712a0e (diff)
downloademacs-81d6418e6b7c3e637dccf9c856d9c4b94bd43b97.tar.gz
emacs-81d6418e6b7c3e637dccf9c856d9c4b94bd43b97.zip
Fix file-name-case-insensitive-p on non-existent files
* src/fileio.c (Ffile_name_case_insensitive_p): If the file doesn't exist, move up the filesystem tree until an existing directory is found. Then test that directory for case-insensitivity. (Bug#32246)
-rw-r--r--src/fileio.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/fileio.c b/src/fileio.c
index b92492c93a6..2dcfb73b0d5 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2296,6 +2296,21 @@ The arg must be a string. */)
2296 if (!NILP (handler)) 2296 if (!NILP (handler))
2297 return call2 (handler, Qfile_name_case_insensitive_p, filename); 2297 return call2 (handler, Qfile_name_case_insensitive_p, filename);
2298 2298
2299 /* If the file doesn't exist, move up the filesystem tree until we
2300 reach an existing directory or the root. */
2301 if (NILP (Ffile_exists_p (filename)))
2302 {
2303 filename = Ffile_name_directory (filename);
2304 while (NILP (Ffile_exists_p (filename)))
2305 {
2306 Lisp_Object newname = expand_and_dir_to_file (filename);
2307 /* Avoid infinite loop if the root is reported as non-existing
2308 (impossible?). */
2309 if (!NILP (Fstring_equal (newname, filename)))
2310 break;
2311 filename = newname;
2312 }
2313 }
2299 filename = ENCODE_FILE (filename); 2314 filename = ENCODE_FILE (filename);
2300 return file_name_case_insensitive_p (SSDATA (filename)) ? Qt : Qnil; 2315 return file_name_case_insensitive_p (SSDATA (filename)) ? Qt : Qnil;
2301} 2316}