diff options
| author | Paul Eggert | 2014-12-29 12:39:58 -0800 |
|---|---|---|
| committer | Paul Eggert | 2014-12-29 12:42:07 -0800 |
| commit | 973110680c094b7a3bbcebbfbafb9abfc7adc8fd (patch) | |
| tree | d4a329e7633a0e2e685c9cf2b7476a771de6006c | |
| parent | f9acac751d4cd22480e62cc63936b1208ca9fe48 (diff) | |
| download | emacs-973110680c094b7a3bbcebbfbafb9abfc7adc8fd.tar.gz emacs-973110680c094b7a3bbcebbfbafb9abfc7adc8fd.zip | |
Fix previous patch to match its commit message
| -rw-r--r-- | ChangeLog | 12 | ||||
| -rw-r--r-- | doc/lispref/os.texi | 12 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/dnd.el | 14 | ||||
| -rw-r--r-- | lisp/gnus/message.el | 10 | ||||
| -rw-r--r-- | lisp/gnus/nnvirtual.el | 8 | ||||
| -rw-r--r-- | lisp/startup.el | 2 | ||||
| -rw-r--r-- | src/sysdep.c | 106 |
8 files changed, 30 insertions, 138 deletions
| @@ -1,6 +1,7 @@ | |||
| 1 | 2014-12-29 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2014-12-29 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | system-name's returned value can vary | 3 | system-name's returned value can vary |
| 4 | Also, the system-name variable is now obsolete. | ||
| 4 | Fixes Bug#19438. | 5 | Fixes Bug#19438. |
| 5 | * doc/lispref/os.texi (System Environment): | 6 | * doc/lispref/os.texi (System Environment): |
| 6 | * etc/NEWS: Document this. | 7 | * etc/NEWS: Document this. |
| @@ -8,6 +9,7 @@ | |||
| 8 | (Displaying the current file name in the titlebar): | 9 | (Displaying the current file name in the titlebar): |
| 9 | * lisp/desktop.el (desktop-save-frameset): | 10 | * lisp/desktop.el (desktop-save-frameset): |
| 10 | * lisp/dnd.el (dnd-get-local-file-uri): | 11 | * lisp/dnd.el (dnd-get-local-file-uri): |
| 12 | * lisp/gnus/message.el (message-make-fqdn): | ||
| 11 | * lisp/gnus/nnvirtual.el (nnvirtual-retrieve-headers) | 13 | * lisp/gnus/nnvirtual.el (nnvirtual-retrieve-headers) |
| 12 | (nnvirtual-update-xref-header): | 14 | (nnvirtual-update-xref-header): |
| 13 | * lisp/nxml/rng-uri.el (rng-uri-file-name-1): | 15 | * lisp/nxml/rng-uri.el (rng-uri-file-name-1): |
| @@ -16,14 +18,18 @@ | |||
| 16 | * src/xrdb.c (get_environ_db): | 18 | * src/xrdb.c (get_environ_db): |
| 17 | * src/xterm.c (same_x_server): | 19 | * src/xterm.c (same_x_server): |
| 18 | * src/xterm.c (x_term_init): | 20 | * src/xterm.c (x_term_init): |
| 19 | Prefer (system-name) to system-name. | 21 | Prefer (system-name) to system-name, and avoid naming |
| 22 | locals 'system-name'. | ||
| 20 | * doc/misc/smtpmail.texi (Server workarounds): Fix grammar. | 23 | * doc/misc/smtpmail.texi (Server workarounds): Fix grammar. |
| 24 | * lisp/startup.el (system-name): Now an obsolete variable. | ||
| 21 | * src/editfns.c (cached_system_name): New static var. | 25 | * src/editfns.c (cached_system_name): New static var. |
| 22 | (init_and_cache_system_name): New function. | 26 | (init_and_cache_system_name): New function. |
| 23 | (init_editfns, Fsystem_name): Use it. | 27 | (init_editfns, Fsystem_name): Use it. |
| 24 | (syms_of_editfns): Initialize it and Vsystem_name to the same value. | 28 | (syms_of_editfns): Initialize it and Vsystem_name to the same value. |
| 25 | * src/sysdep.c (init_system_name): Don't create a new string if | 29 | * src/sysdep.c [HAVE_SOCKETS]: Don't include <sys/socket.h>, <netdb.h>. |
| 26 | the current value is already correct. | 30 | (h_errno) [TRY_AGAIN && !HAVE_H_ERRNO]: Remove decl. |
| 31 | (init_system_name) [HAVE_SOCKETS]: Don't canonicalize the name. | ||
| 32 | Don't create a new string if the current value is already correct. | ||
| 27 | 33 | ||
| 28 | 2014-12-28 Paul Eggert <eggert@cs.ucla.edu> | 34 | 2014-12-28 Paul Eggert <eggert@cs.ucla.edu> |
| 29 | 35 | ||
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 1300bc70d9a..91bd19036f7 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 | |||
| 917 | string. | 917 | string. |
| 918 | @end defun | 918 | @end defun |
| 919 | 919 | ||
| 920 | The symbol @code{system-name} is a variable as well as a function. In | ||
| 921 | fact, the function normally returns whatever value the variable | ||
| 922 | @code{system-name} currently holds. Thus, you can set the variable | ||
| 923 | @code{system-name} in case Emacs is confused about the name of your | ||
| 924 | system. If you do not set the variable, the function updates | ||
| 925 | the variable to the current system name; this behavior can be useful | ||
| 926 | if your Emacs process has changed systems or if the system has changed | ||
| 927 | names. | ||
| 928 | |||
| 929 | The @code{system-name} variable is also useful for constructing frame titles | ||
| 930 | (@pxref{Frame Titles}). | ||
| 931 | |||
| 932 | @c FIXME seems like this section is not the best place for this option? | 920 | @c FIXME seems like this section is not the best place for this option? |
| 933 | @defopt mail-host-address | 921 | @defopt mail-host-address |
| 934 | If this variable is non-@code{nil}, it is used instead of | 922 | If this variable is non-@code{nil}, it is used instead of |
| @@ -542,7 +542,9 @@ optional repeat-count argument. | |||
| 542 | ** Function `sort' can deal with vectors. | 542 | ** Function `sort' can deal with vectors. |
| 543 | 543 | ||
| 544 | ** Function `system-name' now returns an updated value if the current | 544 | ** Function `system-name' now returns an updated value if the current |
| 545 | system's name has changed, or if the Emacs process has changed systems. | 545 | system's name has changed or if the Emacs process has changed systems, |
| 546 | and to avoid long waits it no longer consults DNS to canonicalize the | ||
| 547 | name. The variable `system-name' is now obsolete. | ||
| 546 | 548 | ||
| 547 | --- | 549 | --- |
| 548 | ** New utilities in subr-x.el: | 550 | ** New utilities in subr-x.el: |
diff --git a/lisp/dnd.el b/lisp/dnd.el index 2b68b025ac1..3fda471497f 100644 --- a/lisp/dnd.el +++ b/lisp/dnd.el | |||
| @@ -122,17 +122,17 @@ Return nil if URI is not a local file." | |||
| 122 | 122 | ||
| 123 | ;; The hostname may be our hostname, in that case, convert to a local | 123 | ;; The hostname may be our hostname, in that case, convert to a local |
| 124 | ;; file. Otherwise return nil. TODO: How about an IP-address as hostname? | 124 | ;; file. Otherwise return nil. TODO: How about an IP-address as hostname? |
| 125 | (let ((system-name (system-name))) | 125 | (let ((sysname (system-name))) |
| 126 | (let ((hostname (when (string-match "^file://\\([^/]*\\)" uri) | 126 | (let ((hostname (when (string-match "^file://\\([^/]*\\)" uri) |
| 127 | (downcase (match-string 1 uri)))) | 127 | (downcase (match-string 1 uri)))) |
| 128 | (system-name-no-dot | 128 | (sysname-no-dot |
| 129 | (downcase (if (string-match "^[^\\.]+" system-name) | 129 | (downcase (if (string-match "^[^\\.]+" sysname) |
| 130 | (match-string 0 system-name) | 130 | (match-string 0 sysname) |
| 131 | system-name)))) | 131 | sysname)))) |
| 132 | (when (and hostname | 132 | (when (and hostname |
| 133 | (or (string-equal "localhost" hostname) | 133 | (or (string-equal "localhost" hostname) |
| 134 | (string-equal (downcase system-name) hostname) | 134 | (string-equal (downcase sysname) hostname) |
| 135 | (string-equal system-name-no-dot hostname))) | 135 | (string-equal sysname-no-dot hostname))) |
| 136 | (concat "file://" (substring uri (+ 7 (length hostname)))))))) | 136 | (concat "file://" (substring uri (+ 7 (length hostname)))))))) |
| 137 | 137 | ||
| 138 | (defsubst dnd-unescape-uri (uri) | 138 | (defsubst dnd-unescape-uri (uri) |
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index d58a2922217..ee5d824a852 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el | |||
| @@ -5849,7 +5849,7 @@ give as trustworthy answer as possible." | |||
| 5849 | 5849 | ||
| 5850 | (defun message-make-fqdn () | 5850 | (defun message-make-fqdn () |
| 5851 | "Return user's fully qualified domain name." | 5851 | "Return user's fully qualified domain name." |
| 5852 | (let* ((system-name (system-name)) | 5852 | (let* ((sysname (system-name)) |
| 5853 | (user-mail (message-user-mail-address)) | 5853 | (user-mail (message-user-mail-address)) |
| 5854 | (user-domain | 5854 | (user-domain |
| 5855 | (if (and user-mail | 5855 | (if (and user-mail |
| @@ -5863,10 +5863,10 @@ give as trustworthy answer as possible." | |||
| 5863 | (not (string-match message-bogus-system-names message-user-fqdn))) | 5863 | (not (string-match message-bogus-system-names message-user-fqdn))) |
| 5864 | ;; `message-user-fqdn' seems to be valid | 5864 | ;; `message-user-fqdn' seems to be valid |
| 5865 | message-user-fqdn) | 5865 | message-user-fqdn) |
| 5866 | ((and (string-match message-valid-fqdn-regexp system-name) | 5866 | ((and (string-match message-valid-fqdn-regexp sysname) |
| 5867 | (not (string-match message-bogus-system-names system-name))) | 5867 | (not (string-match message-bogus-system-names sysname))) |
| 5868 | ;; `system-name' returned the right result. | 5868 | ;; `system-name' returned the right result. |
| 5869 | system-name) | 5869 | sysname) |
| 5870 | ;; Try `mail-host-address'. | 5870 | ;; Try `mail-host-address'. |
| 5871 | ((and (boundp 'mail-host-address) | 5871 | ((and (boundp 'mail-host-address) |
| 5872 | (stringp mail-host-address) | 5872 | (stringp mail-host-address) |
| @@ -5881,7 +5881,7 @@ give as trustworthy answer as possible." | |||
| 5881 | user-domain) | 5881 | user-domain) |
| 5882 | ;; Default to this bogus thing. | 5882 | ;; Default to this bogus thing. |
| 5883 | (t | 5883 | (t |
| 5884 | (concat system-name | 5884 | (concat sysname |
| 5885 | ".i-did-not-set--mail-host-address--so-tickle-me"))))) | 5885 | ".i-did-not-set--mail-host-address--so-tickle-me"))))) |
| 5886 | 5886 | ||
| 5887 | (defun message-make-domain () | 5887 | (defun message-make-domain () |
diff --git a/lisp/gnus/nnvirtual.el b/lisp/gnus/nnvirtual.el index d13b492ddb3..61bf5560e2e 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.") | |||
| 99 | (let ((vbuf (nnheader-set-temp-buffer | 99 | (let ((vbuf (nnheader-set-temp-buffer |
| 100 | (get-buffer-create " *virtual headers*"))) | 100 | (get-buffer-create " *virtual headers*"))) |
| 101 | (carticles (nnvirtual-partition-sequence articles)) | 101 | (carticles (nnvirtual-partition-sequence articles)) |
| 102 | (system-name (system-name)) | 102 | (sysname (system-name)) |
| 103 | cgroup carticle article result prefix) | 103 | cgroup carticle article result prefix) |
| 104 | (while carticles | 104 | (while carticles |
| 105 | (setq cgroup (caar carticles)) | 105 | (setq cgroup (caar carticles)) |
| @@ -151,7 +151,7 @@ component group will show up when you enter the virtual group.") | |||
| 151 | ;; and clean up the xrefs. | 151 | ;; and clean up the xrefs. |
| 152 | (princ article nntp-server-buffer) | 152 | (princ article nntp-server-buffer) |
| 153 | (nnvirtual-update-xref-header cgroup carticle | 153 | (nnvirtual-update-xref-header cgroup carticle |
| 154 | prefix (system-name)) | 154 | prefix sysname) |
| 155 | (forward-line 1)) | 155 | (forward-line 1)) |
| 156 | ) | 156 | ) |
| 157 | 157 | ||
| @@ -378,7 +378,7 @@ component group will show up when you enter the virtual group.") | |||
| 378 | (mapc 'nnheader-insert-nov headers)))) | 378 | (mapc 'nnheader-insert-nov headers)))) |
| 379 | 379 | ||
| 380 | 380 | ||
| 381 | (defun nnvirtual-update-xref-header (group article prefix system-name) | 381 | (defun nnvirtual-update-xref-header (group article prefix sysname) |
| 382 | "Edit current NOV header in current buffer to have an xref to the component group, and also server prefix any existing xref lines." | 382 | "Edit current NOV header in current buffer to have an xref to the component group, and also server prefix any existing xref lines." |
| 383 | ;; Move to beginning of Xref field, creating a slot if needed. | 383 | ;; Move to beginning of Xref field, creating a slot if needed. |
| 384 | (beginning-of-line) | 384 | (beginning-of-line) |
| @@ -393,7 +393,7 @@ component group will show up when you enter the virtual group.") | |||
| 393 | (forward-char -1) | 393 | (forward-char -1) |
| 394 | (delete-char 1)) | 394 | (delete-char 1)) |
| 395 | 395 | ||
| 396 | (insert "Xref: " (system-name) " " group ":") | 396 | (insert "Xref: " sysname " " group ":") |
| 397 | (princ article (current-buffer)) | 397 | (princ article (current-buffer)) |
| 398 | (insert " ") | 398 | (insert " ") |
| 399 | 399 | ||
diff --git a/lisp/startup.el b/lisp/startup.el index 8e981bbc64a..0c5e66a2e6e 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." | |||
| 358 | :set (lambda (_variable _value) | 358 | :set (lambda (_variable _value) |
| 359 | (error "Customizing `site-run-file' does not work"))) | 359 | (error "Customizing `site-run-file' does not work"))) |
| 360 | 360 | ||
| 361 | (make-obsolete-variable 'system-name "use (system-name) instead" "25.1") | ||
| 362 | |||
| 361 | (defcustom mail-host-address nil | 363 | (defcustom mail-host-address nil |
| 362 | "Name of this machine, for purposes of naming users. | 364 | "Name of this machine, for purposes of naming users. |
| 363 | If non-nil, Emacs uses this instead of `system-name' when constructing | 365 | If non-nil, Emacs uses this instead of `system-name' when constructing |
diff --git a/src/sysdep.c b/src/sysdep.c index b4a9be1eb1a..013c86b859d 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -1406,17 +1406,6 @@ setup_pty (int fd) | |||
| 1406 | } | 1406 | } |
| 1407 | #endif /* HAVE_PTYS */ | 1407 | #endif /* HAVE_PTYS */ |
| 1408 | 1408 | ||
| 1409 | #ifdef HAVE_SOCKETS | ||
| 1410 | #include <sys/socket.h> | ||
| 1411 | #include <netdb.h> | ||
| 1412 | #endif /* HAVE_SOCKETS */ | ||
| 1413 | |||
| 1414 | #ifdef TRY_AGAIN | ||
| 1415 | #ifndef HAVE_H_ERRNO | ||
| 1416 | extern int h_errno; | ||
| 1417 | #endif | ||
| 1418 | #endif /* TRY_AGAIN */ | ||
| 1419 | |||
| 1420 | void | 1409 | void |
| 1421 | init_system_name (void) | 1410 | init_system_name (void) |
| 1422 | { | 1411 | { |
| @@ -1447,101 +1436,6 @@ init_system_name (void) | |||
| 1447 | hostname = hostname_alloc = xpalloc (hostname_alloc, &hostname_size, 1, | 1436 | hostname = hostname_alloc = xpalloc (hostname_alloc, &hostname_size, 1, |
| 1448 | min (PTRDIFF_MAX, SIZE_MAX), 1); | 1437 | min (PTRDIFF_MAX, SIZE_MAX), 1); |
| 1449 | } | 1438 | } |
| 1450 | #ifdef HAVE_SOCKETS | ||
| 1451 | /* Turn the hostname into the official, fully-qualified hostname. | ||
| 1452 | Don't do this if we're going to dump; this can confuse system | ||
| 1453 | libraries on some machines and make the dumped emacs core dump. */ | ||
| 1454 | #ifndef CANNOT_DUMP | ||
| 1455 | if (initialized) | ||
| 1456 | #endif /* not CANNOT_DUMP */ | ||
| 1457 | if (! strchr (hostname, '.')) | ||
| 1458 | { | ||
| 1459 | int count; | ||
| 1460 | #ifdef HAVE_GETADDRINFO | ||
| 1461 | struct addrinfo *res; | ||
| 1462 | struct addrinfo hints; | ||
| 1463 | int ret; | ||
| 1464 | |||
| 1465 | memset (&hints, 0, sizeof (hints)); | ||
| 1466 | hints.ai_socktype = SOCK_STREAM; | ||
| 1467 | hints.ai_flags = AI_CANONNAME; | ||
| 1468 | |||
| 1469 | for (count = 0;; count++) | ||
| 1470 | { | ||
| 1471 | if ((ret = getaddrinfo (hostname, NULL, &hints, &res)) == 0 | ||
| 1472 | || ret != EAI_AGAIN) | ||
| 1473 | break; | ||
| 1474 | |||
| 1475 | if (count >= 5) | ||
| 1476 | break; | ||
| 1477 | Fsleep_for (make_number (1), Qnil); | ||
| 1478 | } | ||
| 1479 | |||
| 1480 | if (ret == 0) | ||
| 1481 | { | ||
| 1482 | struct addrinfo *it = res; | ||
| 1483 | while (it) | ||
| 1484 | { | ||
| 1485 | char *fqdn = it->ai_canonname; | ||
| 1486 | if (fqdn && strchr (fqdn, '.') | ||
| 1487 | && strcmp (fqdn, "localhost.localdomain") != 0) | ||
| 1488 | break; | ||
| 1489 | it = it->ai_next; | ||
| 1490 | } | ||
| 1491 | if (it) | ||
| 1492 | { | ||
| 1493 | ptrdiff_t len = strlen (it->ai_canonname); | ||
| 1494 | if (hostname_size <= len) | ||
| 1495 | { | ||
| 1496 | hostname_size = len + 1; | ||
| 1497 | hostname = hostname_alloc = xrealloc (hostname_alloc, | ||
| 1498 | hostname_size); | ||
| 1499 | } | ||
| 1500 | strcpy (hostname, it->ai_canonname); | ||
| 1501 | } | ||
| 1502 | freeaddrinfo (res); | ||
| 1503 | } | ||
| 1504 | #else /* !HAVE_GETADDRINFO */ | ||
| 1505 | struct hostent *hp; | ||
| 1506 | for (count = 0;; count++) | ||
| 1507 | { | ||
| 1508 | |||
| 1509 | #ifdef TRY_AGAIN | ||
| 1510 | h_errno = 0; | ||
| 1511 | #endif | ||
| 1512 | hp = gethostbyname (hostname); | ||
| 1513 | #ifdef TRY_AGAIN | ||
| 1514 | if (! (hp == 0 && h_errno == TRY_AGAIN)) | ||
| 1515 | #endif | ||
| 1516 | |||
| 1517 | break; | ||
| 1518 | |||
| 1519 | if (count >= 5) | ||
| 1520 | break; | ||
| 1521 | Fsleep_for (make_number (1), Qnil); | ||
| 1522 | } | ||
| 1523 | |||
| 1524 | if (hp) | ||
| 1525 | { | ||
| 1526 | char *fqdn = (char *) hp->h_name; | ||
| 1527 | |||
| 1528 | if (!strchr (fqdn, '.')) | ||
| 1529 | { | ||
| 1530 | /* We still don't have a fully qualified domain name. | ||
| 1531 | Try to find one in the list of alternate names */ | ||
| 1532 | char **alias = hp->h_aliases; | ||
| 1533 | while (*alias | ||
| 1534 | && (!strchr (*alias, '.') | ||
| 1535 | || !strcmp (*alias, "localhost.localdomain"))) | ||
| 1536 | alias++; | ||
| 1537 | if (*alias) | ||
| 1538 | fqdn = *alias; | ||
| 1539 | } | ||
| 1540 | hostname = fqdn; | ||
| 1541 | } | ||
| 1542 | #endif /* !HAVE_GETADDRINFO */ | ||
| 1543 | } | ||
| 1544 | #endif /* HAVE_SOCKETS */ | ||
| 1545 | #endif /* HAVE_GETHOSTNAME */ | 1439 | #endif /* HAVE_GETHOSTNAME */ |
| 1546 | char *p; | 1440 | char *p; |
| 1547 | for (p = hostname; *p; p++) | 1441 | for (p = hostname; *p; p++) |