From eca277f937f4c51b83fa0f156b8081e88ea3f121 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 3 Dec 2015 16:59:42 +0200 Subject: Fix documentation and implementation of 'directory-name-p' * lisp/files.el (directory-name-p): Modify to recognize backslashes on MS-Windows and MS-DOS. Adjust the doc string accordingly. Use '=', not char-equal, for comparison, as letter-case cannot possibly be an issue here. * doc/lispref/files.texi (Directory Names): Move the documentation of directory-name-p here from "Relative File Names". Update the description per the changes in implementation. * etc/NEWS: Move the entry for 'directory-name-p' to its proper place and mark it documented. --- lisp/files.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lisp/files.el') diff --git a/lisp/files.el b/lisp/files.el index f37c23b7bdd..d20bb1401fa 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -740,9 +740,14 @@ The path separator is colon in GNU and GNU-like systems." (error "No such directory found via CDPATH environment variable")))) (defsubst directory-name-p (name) - "Return non-nil if NAME ends with a slash character." - (and (> (length name) 0) - (char-equal (aref name (1- (length name))) ?/))) + "Return non-nil if NAME ends with a directory separator character." + (let ((len (length name)) + (lastc ?.)) + (if (> len 0) + (setq lastc (aref name (1- len)))) + (or (= lastc ?/) + (and (memq system-type '(windows-nt ms-dos)) + (= lastc ?\\))))) (defun directory-files-recursively (dir regexp &optional include-directories) "Return list of all files under DIR that have file names matching REGEXP. -- cgit v1.2.1