]> git.eshelyaron.com Git - emacs.git/commitdiff
* net/tramp.el (tramp-file-name-real-user, tramp-file-name-domain)
authorMichael Albinus <michael.albinus@gmx.de>
Thu, 8 Oct 2009 15:19:56 +0000 (15:19 +0000)
committerMichael Albinus <michael.albinus@gmx.de>
Thu, 8 Oct 2009 15:19:56 +0000 (15:19 +0000)
(tramp-file-name-real-host, tramp-file-name-port): Apply
`save-match-data.

lisp/net/tramp.el

index baac32479631908d605aec901e0cbf2e08438436..f266d314b67d1169d220c0b5418fbca51cabcc74 100644 (file)
@@ -3905,11 +3905,11 @@ the result will be a local, non-Tramp, filename."
       (while (string-match "//" localname)
        (setq localname (replace-match "/" t t localname)))
       ;; No tilde characters in file name, do normal
-      ;; expand-file-name (this does "/./" and "/../").  We bind
-      ;; `directory-sep-char' here for XEmacs on Windows, which
-      ;; would otherwise use backslash.  `default-directory' is
-      ;; bound, because on Windows there would be problems with UNC
-      ;; shares or Cygwin mounts.
+      ;; `expand-file-name' (this does "/./" and "/../").  We bind
+      ;; `directory-sep-char' here for XEmacs on Windows, which would
+      ;; otherwise use backslash.  `default-directory' is bound,
+      ;; because on Windows there would be problems with UNC shares or
+      ;; Cygwin mounts.
       (let ((directory-sep-char ?/)
            (default-directory (tramp-compat-temporary-file-directory)))
        (tramp-make-tramp-file-name
@@ -7296,35 +7296,39 @@ Not actually used.  Use `(format \"%o\" i)' instead?"
 ;; "user%domain".  Sometimes, we must extract these parts.
 (defun tramp-file-name-real-user (vec)
   "Return the user name of VEC without domain."
-  (let ((user (tramp-file-name-user vec)))
-    (if (and (stringp user)
-            (string-match tramp-user-with-domain-regexp user))
-       (match-string 1 user)
-      user)))
+  (save-match-data
+    (let ((user (tramp-file-name-user vec)))
+      (if (and (stringp user)
+              (string-match tramp-user-with-domain-regexp user))
+         (match-string 1 user)
+       user))))
 
 (defun tramp-file-name-domain (vec)
   "Return the domain name of VEC."
-  (let ((user (tramp-file-name-user vec)))
-    (and (stringp user)
-        (string-match tramp-user-with-domain-regexp user)
-        (match-string 2 user))))
+  (save-match-data
+    (let ((user (tramp-file-name-user vec)))
+      (and (stringp user)
+          (string-match tramp-user-with-domain-regexp user)
+          (match-string 2 user)))))
 
 ;; The host part of a Tramp file name vector can be of kind
 ;; "host#port".  Sometimes, we must extract these parts.
 (defun tramp-file-name-real-host (vec)
   "Return the host name of VEC without port."
-  (let ((host (tramp-file-name-host vec)))
-    (if (and (stringp host)
-            (string-match tramp-host-with-port-regexp host))
-       (match-string 1 host)
-      host)))
+  (save-match-data
+    (let ((host (tramp-file-name-host vec)))
+      (if (and (stringp host)
+              (string-match tramp-host-with-port-regexp host))
+         (match-string 1 host)
+       host))))
 
 (defun tramp-file-name-port (vec)
   "Return the port number of VEC."
-  (let ((host (tramp-file-name-host vec)))
-    (and (stringp host)
-        (string-match tramp-host-with-port-regexp host)
-        (string-to-number (match-string 2 host)))))
+  (save-match-data
+    (let ((host (tramp-file-name-host vec)))
+      (and (stringp host)
+          (string-match tramp-host-with-port-regexp host)
+          (string-to-number (match-string 2 host))))))
 
 (defun tramp-tramp-file-p (name)
   "Return t if NAME is a Tramp file."