emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 9731106: Fix previous patch to match its commit mes


From: Paul Eggert
Subject: [Emacs-diffs] master 9731106: Fix previous patch to match its commit message
Date: Mon, 29 Dec 2014 20:42:17 +0000

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

    Fix previous patch to match its commit message
---
 ChangeLog              |   12 ++++-
 doc/lispref/os.texi    |   12 -----
 etc/NEWS               |    4 +-
 lisp/dnd.el            |   14 +++---
 lisp/gnus/message.el   |   10 ++--
 lisp/gnus/nnvirtual.el |    8 ++--
 lisp/startup.el        |    2 +
 src/sysdep.c           |  106 ------------------------------------------------
 8 files changed, 30 insertions(+), 138 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1fc7d66..6557ef9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2014-12-29  Paul Eggert  <address@hidden>
 
        system-name's returned value can vary
+       Also, the system-name variable is now obsolete.
        Fixes Bug#19438.
        * doc/lispref/os.texi (System Environment):
        * etc/NEWS: Document this.
@@ -8,6 +9,7 @@
        (Displaying the current file name in the titlebar):
        * lisp/desktop.el (desktop-save-frameset):
        * lisp/dnd.el (dnd-get-local-file-uri):
+       * lisp/gnus/message.el (message-make-fqdn):
        * lisp/gnus/nnvirtual.el (nnvirtual-retrieve-headers)
        (nnvirtual-update-xref-header):
        * lisp/nxml/rng-uri.el (rng-uri-file-name-1):
@@ -16,14 +18,18 @@
        * src/xrdb.c (get_environ_db):
        * src/xterm.c (same_x_server):
        * src/xterm.c (x_term_init):
-       Prefer (system-name) to system-name.
+       Prefer (system-name) to system-name, and avoid naming
+       locals 'system-name'.
        * doc/misc/smtpmail.texi (Server workarounds): Fix grammar.
+       * lisp/startup.el (system-name): Now an obsolete variable.
        * src/editfns.c (cached_system_name): New static var.
        (init_and_cache_system_name): New function.
        (init_editfns, Fsystem_name): Use it.
        (syms_of_editfns): Initialize it and Vsystem_name to the same value.
-       * src/sysdep.c (init_system_name): Don't create a new string if
-       the current value is already correct.
+       * src/sysdep.c [HAVE_SOCKETS]: Don't include <sys/socket.h>, <netdb.h>.
+       (h_errno) [TRY_AGAIN && !HAVE_H_ERRNO]: Remove decl.
+       (init_system_name) [HAVE_SOCKETS]: Don't canonicalize the name.
+       Don't create a new string if the current value is already correct.
 
 2014-12-28  Paul Eggert  <address@hidden>
 
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index 1300bc7..91bd190 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -917,18 +917,6 @@ This function returns the name of the machine you are 
running on, as a
 string.
 @end defun
 
-  The symbol @code{system-name} is a variable as well as a function.  In
-fact, the function normally returns whatever value the variable
address@hidden currently holds.  Thus, you can set the variable
address@hidden in case Emacs is confused about the name of your
-system.  If you do not set the variable, the function updates
-the variable to the current system name; this behavior can be useful
-if your Emacs process has changed systems or if the system has changed
-names.
-
-The @code{system-name} variable is also useful for constructing frame titles
-(@pxref{Frame Titles}).
-
 @c FIXME seems like this section is not the best place for this option?
 @defopt mail-host-address
 If this variable is address@hidden, it is used instead of
diff --git a/etc/NEWS b/etc/NEWS
index e5c988b..ae0cb70 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -542,7 +542,9 @@ optional repeat-count argument.
 ** Function `sort' can deal with vectors.
 
 ** Function `system-name' now returns an updated value if the current
-system's name has changed, or if the Emacs process has changed systems.
+system's name has changed or if the Emacs process has changed systems,
+and to avoid long waits it no longer consults DNS to canonicalize the
+name.  The variable `system-name' is now obsolete.
 
 ---
 ** New utilities in subr-x.el:
diff --git a/lisp/dnd.el b/lisp/dnd.el
index 2b68b02..3fda471 100644
--- a/lisp/dnd.el
+++ b/lisp/dnd.el
@@ -122,17 +122,17 @@ Return nil if URI is not a local file."
 
   ;; The hostname may be our hostname, in that case, convert to a local
   ;; file.  Otherwise return nil.  TODO:  How about an IP-address as hostname?
-  (let ((system-name (system-name)))
+  (let ((sysname (system-name)))
     (let ((hostname (when (string-match "^file://\\([^/]*\\)" uri)
                      (downcase (match-string 1 uri))))
-         (system-name-no-dot
-          (downcase (if (string-match "^[^\\.]+" system-name)
-                        (match-string 0 system-name)
-                      system-name))))
+         (sysname-no-dot
+          (downcase (if (string-match "^[^\\.]+" sysname)
+                        (match-string 0 sysname)
+                      sysname))))
       (when (and hostname
                 (or (string-equal "localhost" hostname)
-                    (string-equal (downcase system-name) hostname)
-                    (string-equal system-name-no-dot hostname)))
+                    (string-equal (downcase sysname) hostname)
+                    (string-equal sysname-no-dot hostname)))
        (concat "file://" (substring uri (+ 7 (length hostname))))))))
 
 (defsubst dnd-unescape-uri (uri)
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index d58a292..ee5d824 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -5849,7 +5849,7 @@ give as trustworthy answer as possible."
 
 (defun message-make-fqdn ()
   "Return user's fully qualified domain name."
-  (let* ((system-name (system-name))
+  (let* ((sysname (system-name))
         (user-mail (message-user-mail-address))
         (user-domain
          (if (and user-mail
@@ -5863,10 +5863,10 @@ give as trustworthy answer as possible."
           (not (string-match message-bogus-system-names message-user-fqdn)))
       ;; `message-user-fqdn' seems to be valid
       message-user-fqdn)
-     ((and (string-match message-valid-fqdn-regexp system-name)
-          (not (string-match message-bogus-system-names system-name)))
+     ((and (string-match message-valid-fqdn-regexp sysname)
+          (not (string-match message-bogus-system-names sysname)))
       ;; `system-name' returned the right result.
-      system-name)
+      sysname)
      ;; Try `mail-host-address'.
      ((and (boundp 'mail-host-address)
           (stringp mail-host-address)
@@ -5881,7 +5881,7 @@ give as trustworthy answer as possible."
       user-domain)
      ;; Default to this bogus thing.
      (t
-      (concat system-name
+      (concat sysname
              ".i-did-not-set--mail-host-address--so-tickle-me")))))
 
 (defun message-make-domain ()
diff --git a/lisp/gnus/nnvirtual.el b/lisp/gnus/nnvirtual.el
index d13b492..61bf556 100644
--- a/lisp/gnus/nnvirtual.el
+++ b/lisp/gnus/nnvirtual.el
@@ -99,7 +99,7 @@ component group will show up when you enter the virtual 
group.")
        (let ((vbuf (nnheader-set-temp-buffer
                     (get-buffer-create " *virtual headers*")))
              (carticles (nnvirtual-partition-sequence articles))
-             (system-name (system-name))
+             (sysname (system-name))
              cgroup carticle article result prefix)
          (while carticles
            (setq cgroup (caar carticles))
@@ -151,7 +151,7 @@ component group will show up when you enter the virtual 
group.")
                  ;; and clean up the xrefs.
                  (princ article nntp-server-buffer)
                  (nnvirtual-update-xref-header cgroup carticle
-                                               prefix (system-name))
+                                               prefix sysname)
                  (forward-line 1))
                )
 
@@ -378,7 +378,7 @@ component group will show up when you enter the virtual 
group.")
       (mapc 'nnheader-insert-nov headers))))
 
 
-(defun nnvirtual-update-xref-header (group article prefix system-name)
+(defun nnvirtual-update-xref-header (group article prefix sysname)
   "Edit current NOV header in current buffer to have an xref to the component 
group, and also server prefix any existing xref lines."
   ;; Move to beginning of Xref field, creating a slot if needed.
   (beginning-of-line)
@@ -393,7 +393,7 @@ component group will show up when you enter the virtual 
group.")
     (forward-char -1)
     (delete-char 1))
 
-  (insert "Xref: " (system-name) " " group ":")
+  (insert "Xref: " sysname " " group ":")
   (princ article (current-buffer))
   (insert " ")
 
diff --git a/lisp/startup.el b/lisp/startup.el
index 8e981bb..0c5e66a 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -358,6 +358,8 @@ this variable usefully is to set it while building and 
dumping Emacs."
   :set (lambda (_variable _value)
          (error "Customizing `site-run-file' does not work")))
 
+(make-obsolete-variable 'system-name "use (system-name) instead" "25.1")
+
 (defcustom mail-host-address nil
   "Name of this machine, for purposes of naming users.
 If non-nil, Emacs uses this instead of `system-name' when constructing
diff --git a/src/sysdep.c b/src/sysdep.c
index b4a9be1..013c86b 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -1406,17 +1406,6 @@ setup_pty (int fd)
 }
 #endif /* HAVE_PTYS */
 
-#ifdef HAVE_SOCKETS
-#include <sys/socket.h>
-#include <netdb.h>
-#endif /* HAVE_SOCKETS */
-
-#ifdef TRY_AGAIN
-#ifndef HAVE_H_ERRNO
-extern int h_errno;
-#endif
-#endif /* TRY_AGAIN */
-
 void
 init_system_name (void)
 {
@@ -1447,101 +1436,6 @@ init_system_name (void)
       hostname = hostname_alloc = xpalloc (hostname_alloc, &hostname_size, 1,
                                           min (PTRDIFF_MAX, SIZE_MAX), 1);
     }
-#ifdef HAVE_SOCKETS
-  /* Turn the hostname into the official, fully-qualified hostname.
-     Don't do this if we're going to dump; this can confuse system
-     libraries on some machines and make the dumped emacs core dump. */
-#ifndef CANNOT_DUMP
-  if (initialized)
-#endif /* not CANNOT_DUMP */
-    if (! strchr (hostname, '.'))
-      {
-       int count;
-#ifdef HAVE_GETADDRINFO
-        struct addrinfo *res;
-        struct addrinfo hints;
-        int ret;
-
-        memset (&hints, 0, sizeof (hints));
-        hints.ai_socktype = SOCK_STREAM;
-        hints.ai_flags = AI_CANONNAME;
-
-       for (count = 0;; count++)
-         {
-            if ((ret = getaddrinfo (hostname, NULL, &hints, &res)) == 0
-                || ret != EAI_AGAIN)
-              break;
-
-            if (count >= 5)
-             break;
-           Fsleep_for (make_number (1), Qnil);
-         }
-
-        if (ret == 0)
-          {
-            struct addrinfo *it = res;
-            while (it)
-              {
-                char *fqdn = it->ai_canonname;
-                if (fqdn && strchr (fqdn, '.')
-                    && strcmp (fqdn, "localhost.localdomain") != 0)
-                  break;
-                it = it->ai_next;
-              }
-            if (it)
-              {
-               ptrdiff_t len = strlen (it->ai_canonname);
-               if (hostname_size <= len)
-                 {
-                   hostname_size = len + 1;
-                   hostname = hostname_alloc = xrealloc (hostname_alloc,
-                                                         hostname_size);
-                 }
-                strcpy (hostname, it->ai_canonname);
-              }
-            freeaddrinfo (res);
-          }
-#else /* !HAVE_GETADDRINFO */
-        struct hostent *hp;
-       for (count = 0;; count++)
-         {
-
-#ifdef TRY_AGAIN
-           h_errno = 0;
-#endif
-           hp = gethostbyname (hostname);
-#ifdef TRY_AGAIN
-           if (! (hp == 0 && h_errno == TRY_AGAIN))
-#endif
-
-             break;
-
-           if (count >= 5)
-             break;
-           Fsleep_for (make_number (1), Qnil);
-         }
-
-       if (hp)
-         {
-           char *fqdn = (char *) hp->h_name;
-
-           if (!strchr (fqdn, '.'))
-             {
-               /* We still don't have a fully qualified domain name.
-                  Try to find one in the list of alternate names */
-               char **alias = hp->h_aliases;
-               while (*alias
-                      && (!strchr (*alias, '.')
-                          || !strcmp (*alias, "localhost.localdomain")))
-                 alias++;
-               if (*alias)
-                 fqdn = *alias;
-             }
-           hostname = fqdn;
-         }
-#endif /* !HAVE_GETADDRINFO */
-      }
-#endif /* HAVE_SOCKETS */
 #endif /* HAVE_GETHOSTNAME */
   char *p;
   for (p = hostname; *p; p++)



reply via email to

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