{
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]))));
}
\f
DEFUN ("file-exists-p", Ffile_exists_p, Sfile_exists_p, 1, 1, 0,
(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)))))))