From: Ken Brown Date: Fri, 27 Jul 2018 18:24:01 +0000 (-0400) Subject: Fix file-name-case-insensitive-p on non-existent files X-Git-Tag: emacs-27.0.90~4664^2~19 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=81d6418e6b7c3e637dccf9c856d9c4b94bd43b97;p=emacs.git 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) --- 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. */) if (!NILP (handler)) return call2 (handler, Qfile_name_case_insensitive_p, filename); + /* If the file doesn't exist, move up the filesystem tree until we + reach an existing directory or the root. */ + if (NILP (Ffile_exists_p (filename))) + { + filename = Ffile_name_directory (filename); + while (NILP (Ffile_exists_p (filename))) + { + Lisp_Object newname = expand_and_dir_to_file (filename); + /* Avoid infinite loop if the root is reported as non-existing + (impossible?). */ + if (!NILP (Fstring_equal (newname, filename))) + break; + filename = newname; + } + } filename = ENCODE_FILE (filename); return file_name_case_insensitive_p (SSDATA (filename)) ? Qt : Qnil; }