t means that HOST answered.
`accept' means the relevant variable told us to accept.
\"mesg\" means HOST exists, but does not respond for some reason."
- ;; Try some (Emory local):
- ;; (ffap-machine-p "ftp" nil nil 'ping)
- ;; (ffap-machine-p "nonesuch" nil nil 'ping)
- ;; (ffap-machine-p "ftp.mathcs.emory.edu" nil nil 'ping)
- ;; (ffap-machine-p "mathcs" 5678 nil 'ping)
- ;; (ffap-machine-p "foo.bonk" nil nil 'ping)
- ;; (ffap-machine-p "foo.bonk.com" nil nil 'ping)
(if (or (string-match "[^-[:alnum:].]" host) ; Invalid chars (?)
(not (string-match "[^0-9]" host))) ; 1: a number? 2: quick reject
nil
(defun ffap-file-remote-p (filename)
"If FILENAME looks remote, return it (maybe slightly improved)."
- ;; (ffap-file-remote-p "/user@foo.bar.com:/pub")
- ;; (ffap-file-remote-p "/cssun.mathcs.emory.edu://dir")
- ;; (ffap-file-remote-p "/ffap.el:80")
(or (and ffap-ftp-regexp
(string-match ffap-ftp-regexp filename)
;; Convert "/host.com://dir" to "/host:/dir", to handle a dying
;; www.ncsa.uiuc.edu
((and (string-match "\\`w\\(ww\\|eb\\)[-.]" mach))
(concat "http://" mach "/"))
- ;; More cases? Maybe "telnet:" for archie?
+ ;; More cases?
(ffap-ftp-regexp (ffap-host-to-filename mach))
))
(ffap-replace-file-component "/ftp:who@foo.com:/whatever" "/new")
"/ftp:who@foo.com:/new")))
+(ert-deftest ffap-file-remote-p ()
+ (dolist (test '(("/user@foo.bar.com:/pub" .
+ "/user@foo.bar.com:/pub")
+ ("/cssun.mathcs.emory.edu://dir" .
+ "/cssun.mathcs.emory.edu:/dir")
+ ("/ffap.el:80" .
+ "/ffap.el:80")))
+ (let ((A (car test))
+ (B (cdr test)))
+ (should (equal (ffap-file-remote-p A) B)))))
+
+(ert-deftest ffap-machine-p ()
+ (should-not (ffap-machine-p "ftp"))
+ (should-not (ffap-machine-p "nonesuch"))
+ (should (eq (ffap-machine-p "ftp.mathcs.emory.edu") 'accept))
+ (should-not (ffap-machine-p "mathcs" 5678))
+ (should-not (ffap-machine-p "foo.bonk"))
+ (should (eq (ffap-machine-p "foo.bonk.com") 'accept)))
+
(ert-deftest ffap-tests-25243 ()
"Test for https://debbugs.gnu.org/25243 ."
(ert-with-temp-file file