emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master e3575ee: Fix recently-introduced file-name-absolute


From: Paul Eggert
Subject: [Emacs-diffs] master e3575ee: Fix recently-introduced file-name-absolute-p typo
Date: Fri, 26 Jul 2019 12:49:02 -0400 (EDT)

branch: master
commit e3575ee4b2fc8e74238dcc710c569885e1eef937
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Fix recently-introduced file-name-absolute-p typo
    
    Fix a bug introduced in 2019-07-24T21:28:13!address@hidden.
    * src/fileio.c (file_name_absolute_p):
    ~/foo is also absolute (Bug#36809).
    * test/src/fileio-tests.el (fileio-tests--file-name-absolute-p):
    Rename from fileio-tests--no-such-user and add more tests.
---
 src/fileio.c             |  3 ++-
 test/src/fileio-tests.el | 20 ++++++++++----------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/fileio.c b/src/fileio.c
index d1a7f39..968a55e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2690,7 +2690,8 @@ file_name_absolute_p (char const *filename)
 {
   return (IS_ABSOLUTE_FILE_NAME (filename)
          || (filename[0] == '~'
-             && (!filename[1] || user_homedir (&filename[1]))));
+             && (!filename[1] || IS_DIRECTORY_SEP (filename[1])
+                 || user_homedir (&filename[1]))));
 }
 
 DEFUN ("file-exists-p", Ffile_exists_p, Sfile_exists_p, 1, 1, 0,
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el
index 09a5b14..98d3d6b 100644
--- a/test/src/fileio-tests.el
+++ b/test/src/fileio-tests.el
@@ -137,13 +137,13 @@ Also check that an encoding error can appear in a 
symlink."
     (should (and (file-name-absolute-p name)
                  (not (eq (aref name 0) ?~))))))
 
-(ert-deftest fileio-tests--no-such-user ()
-  "Test file-name-absolute-p on ~nosuchuser."
-  (unless (user-full-name "nosuchuser")
-    (should (not (file-name-absolute-p "~nosuchuser")))
-    (should (not (file-name-absolute-p "~nosuchuser/")))
-    (should (not (file-name-absolute-p "~nosuchuser//")))
-    (should (not (file-name-absolute-p "~nosuchuser/foo")))
-    (should (not (file-name-absolute-p "~nosuchuser/foo/")))
-    (should (not (file-name-absolute-p "~nosuchuser/foo//")))
-    (should (not (file-name-absolute-p "~nosuchuser/foo/bar")))))
+(ert-deftest fileio-tests--file-name-absolute-p ()
+  "Test file-name-absolute-p."
+  (dolist (suffix '("" "/" "//" "/foo" "/foo/" "/foo//" "/foo/bar"))
+    (unless (string-equal suffix "")
+      (should (file-name-absolute-p suffix)))
+    (should (file-name-absolute-p (concat "~" suffix)))
+    (when (user-full-name user-login-name)
+      (should (file-name-absolute-p (concat "~" user-login-name suffix))))
+    (unless (user-full-name "nosuchuser")
+      (should (not (file-name-absolute-p (concat "~nosuchuser" suffix)))))))



reply via email to

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