changeset 23529:ccedc9675dab

(whois-get-tld): Rewrite not to use `do'.
author Richard M. Stallman <rms@gnu.org>
date Wed, 21 Oct 1998 18:09:39 +0000
parents 3bb7a66a51a8
children 8fd3e2d95a51
files lisp/net-utils.el
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/net-utils.el	Wed Oct 21 18:08:17 1998 +0000
+++ b/lisp/net-utils.el	Wed Oct 21 18:09:39 1998 +0000
@@ -626,13 +626,15 @@
   :group 'net-utils
   :type 'boolean)
 
-
 (defun whois-get-tld (host)
-  (do ((i (1- (length host)) (1- i))
-       (max-len (- (length host) 4)))
-      ((or (= i max-len) (char-equal (aref host i) ?.))
-       (if (= i max-len) nil
-	 (substring host (1+ i))))))
+  "Return the top level domain of `host', or nil if it isn't a domain name."
+  (let ((i (1- (length host)))
+	(max-len (- (length host) 5)))
+    (while (not (or (= i max-len) (char-equal (aref host i) ?.)))
+      (setq i (1- i)))
+    (if (= i max-len)
+	nil
+      (substring host (1+ i)))))
 
 ;; Whois protocol
 ;;;###autoload