unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: jussi@aprikoodi.fi, emacs-devel@gnu.org
Subject: Re: [PATCH] Override Windows default Win-* key combinations when using Emacs
Date: Sun, 28 Feb 2016 23:07:38 -0800	[thread overview]
Message-ID: <56D3EE3A.5090803@cs.ucla.edu> (raw)
In-Reply-To: <83a8mk9oqd.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 783 bytes --]

Eli Zaretskii wrote:
>> The Gnulib getaddrinfo module is supposed to work on MS-Windows. If Emacs used
>> >the Gnulib getaddrinfo module, the mainline Emacs code could be simplified by
>> >assuming that getaddrinfo works.

> But the non-getaddrinfo parts are not conditioned on MS-Windows in any
> way.  What about other systems that might be using them?

Sorry, you've lost me.  The non-getaddrinfo parts of Gnulib?  Of Emacs?

For what it's worth, the Gnulib getaddrinfo module is supposed to work on a wide 
variety of systems lacking getaddrinfo, not just on MS-Windows.

I'm sure you mean something straightforward, it's just that I'm not getting it.

What I was thinking was that we add the Gnulib getaddrinfo module, and apply 
something like the attached (untested) patch.



[-- Attachment #2: t.diff --]
[-- Type: text/x-diff, Size: 5643 bytes --]

diff --git a/lib-src/pop.c b/lib-src/pop.c
index 57a5e52..55f2b10 100644
--- a/lib-src/pop.c
+++ b/lib-src/pop.c
@@ -962,13 +962,9 @@ static int have_winsock = 0;
 static int
 socket_connection (char *host, int flags)
 {
-#ifdef HAVE_GETADDRINFO
   struct addrinfo *res, *it;
   struct addrinfo hints;
   int ret;
-#else /* !HAVE_GETADDRINFO */
-  struct hostent *hostent;
-#endif
   struct servent *servent;
   struct sockaddr_in addr;
   char found_port = 0;
@@ -1055,7 +1051,6 @@ socket_connection (char *host, int flags)
 
     }
 
-#ifdef HAVE_GETADDRINFO
   memset (&hints, 0, sizeof (hints));
   hints.ai_socktype = SOCK_STREAM;
   hints.ai_flags = AI_CANONNAME;
@@ -1087,34 +1082,6 @@ socket_connection (char *host, int flags)
     }
   freeaddrinfo (res);
 
-#else /* !HAVE_GETADDRINFO */
-  do
-    {
-      hostent = gethostbyname (host);
-      try_count++;
-      if ((! hostent) && ((h_errno != TRY_AGAIN) || (try_count == 5)))
-	{
-	  strcpy (pop_error, "Could not determine POP server's address");
-	  return (-1);
-	}
-    } while (! hostent);
-
-  while (*hostent->h_addr_list)
-    {
-      memcpy (&addr.sin_addr, *hostent->h_addr_list, hostent->h_length);
-      if (! connect (sock, (struct sockaddr *) &addr, sizeof (addr)))
-	break;
-      hostent->h_addr_list++;
-    }
-  connect_ok = *hostent->h_addr_list != NULL;
-  if (! connect_ok)
-    {
-      realhost = alloca (strlen (hostent->h_name) + 1);
-      strcpy (realhost, hostent->h_name);
-    }
-
-#endif /* !HAVE_GETADDRINFO */
-
 #define CONNECT_ERROR "Could not connect to POP server: "
 
   if (! connect_ok)
diff --git a/src/conf_post.h b/src/conf_post.h
index 2788abf..b2eb2a2 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -122,7 +122,6 @@ typedef bool bool_bf;
 char *_getpty();
 #endif
 #define INET6 /* Needed for struct sockaddr_in6.  */
-#undef HAVE_GETADDRINFO /* IRIX has getaddrinfo but not struct addrinfo.  */
 #endif /* IRIX6_5 */
 
 #ifdef MSDOS
diff --git a/src/process.c b/src/process.c
index d83e2d2..9a4bedf 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3430,21 +3430,6 @@ connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
 
 }
 
-#ifndef HAVE_GETADDRINFO
-static Lisp_Object
-conv_numerical_to_lisp (unsigned char *number, int length, int port)
-{
-  Lisp_Object address = Fmake_vector (make_number (length + 1), Qnil);
-  struct Lisp_Vector *p = XVECTOR (address);
-
-  p->contents[length] = make_number (port);
-  for (int i = 0; i < length; i++)
-    p->contents[i] = make_number (number[i]);
-
-  return address;
-}
-#endif
-
 /* Create a network stream/datagram client/server process.  Treated
    exactly like a normal process when reading and writing.  Primary
    differences are in status display and process deletion.  A network
@@ -3615,11 +3600,9 @@ usage: (make-network-process &rest ARGS)  */)
   Lisp_Object proc;
   Lisp_Object contact;
   struct Lisp_Process *p;
-#if defined HAVE_GETADDRINFO || defined HAVE_GETADDRINFO_A
   const char *portstring;
   ptrdiff_t portstringlen ATTRIBUTE_UNUSED;
   char portbuf[INT_BUFSIZE_BOUND (EMACS_INT)];
-#endif
 #ifdef HAVE_LOCAL_SOCKETS
   struct sockaddr_un address_un;
 #endif
@@ -3690,7 +3673,7 @@ usage: (make-network-process &rest ARGS)  */)
   tem = Fplist_get (contact, QCfamily);
   if (NILP (tem))
     {
-#if defined (HAVE_GETADDRINFO) && defined (AF_INET6)
+#ifdef AF_INET6
       family = AF_UNSPEC;
 #else
       family = AF_INET;
@@ -3762,7 +3745,6 @@ usage: (make-network-process &rest ARGS)  */)
     }
 #endif
 
-#if defined HAVE_GETADDRINFO || defined HAVE_GETADDRINFO_A
   if (!NILP (host))
     {
       /* SERVICE can either be a string or int.
@@ -3784,7 +3766,6 @@ usage: (make-network-process &rest ARGS)  */)
 	  portstringlen = SBYTES (service);
 	}
     }
-#endif
 
 #ifdef HAVE_GETADDRINFO_A
   if (!NILP (host) && !NILP (Fplist_get (contact, QCnowait)))
@@ -3816,7 +3797,6 @@ usage: (make-network-process &rest ARGS)  */)
     }
 #endif /* HAVE_GETADDRINFO_A */
 
-#ifdef HAVE_GETADDRINFO
   /* If we have a host, use getaddrinfo to resolve both host and service.
      Otherwise, use getservbyname to lookup the service.  */
 
@@ -3860,7 +3840,6 @@ usage: (make-network-process &rest ARGS)  */)
 
       goto open_socket;
     }
-#endif /* HAVE_GETADDRINFO */
 
   /* We end up here if getaddrinfo is not defined, or in case no hostname
      has been specified (e.g. for a local server process).  */
@@ -3899,47 +3878,6 @@ usage: (make-network-process &rest ARGS)  */)
       xsignal1 (Qerror, CALLN (Fformat, unknown_service, service));
     }
 
-#ifndef HAVE_GETADDRINFO
-  if (!NILP (host))
-    {
-      struct hostent *host_info_ptr;
-      unsigned char *addr;
-      int addrlen;
-
-      /* gethostbyname may fail with TRY_AGAIN, but we don't honor that,
-	 as it may `hang' Emacs for a very long time.  */
-      immediate_quit = 1;
-      QUIT;
-
-#ifdef HAVE_RES_INIT
-      res_init ();
-#endif
-
-      host_info_ptr = gethostbyname ((const char *) SDATA (host));
-      immediate_quit = 0;
-
-      if (host_info_ptr)
-	{
-	  addr = (unsigned char *) host_info_ptr->h_addr;
-	  addrlen = host_info_ptr->h_length;
-	}
-      else
-	/* Attempt to interpret host as numeric inet address.  This
-	   only works for IPv4 addresses. */
-	{
-	  unsigned long numeric_addr = inet_addr (SSDATA (host));
-
-	  if (numeric_addr == -1)
-	    error ("Unknown host \"%s\"", SDATA (host));
-
-	  addr = (unsigned char *) &numeric_addr;
-	  addrlen = 4;
-	}
-
-      ip_addresses = list1 (conv_numerical_to_lisp (addr, addrlen, port));
-    }
-#endif /* not HAVE_GETADDRINFO */
-
  open_socket:
 
   if (!NILP (buffer))

  reply	other threads:[~2016-02-29  7:07 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-05 12:51 [PATCH] Override Windows default Win-* key combinations when using Emacs Jussi Lahdenniemi
2016-01-05 13:54 ` Herring, Davis
2016-01-05 17:05   ` Eli Zaretskii
2016-01-05 19:32     ` Jussi Lahdenniemi
2016-01-05 17:05 ` Eli Zaretskii
2016-01-05 19:03   ` Rasmus
2016-01-05 19:17     ` Eli Zaretskii
2016-01-05 19:31       ` Jussi Lahdenniemi
     [not found]     ` <<83d1tf4z0h.fsf@gnu.org>
2016-01-05 19:45       ` Drew Adams
2016-01-05 19:41   ` Jussi Lahdenniemi
2016-01-05 20:01     ` Eli Zaretskii
2016-01-09 19:58   ` Jussi Lahdenniemi
2016-01-11 18:54     ` Eli Zaretskii
2016-01-12 11:16       ` Jussi Lahdenniemi
2016-01-12 15:08         ` covici
2016-01-13  5:07           ` Jussi Lahdenniemi
2016-01-12 15:54         ` Eli Zaretskii
2016-01-13  5:31           ` Jussi Lahdenniemi
2016-01-13 15:49             ` Eli Zaretskii
2016-01-13  9:16           ` Jussi Lahdenniemi
2016-01-13 11:28             ` Jussi Lahdenniemi
2016-01-13 15:57               ` Eli Zaretskii
2016-01-14 12:49                 ` Jussi Lahdenniemi
2016-01-14 17:10                   ` Jussi Lahdenniemi
2016-01-14 18:07                     ` Eli Zaretskii
2016-01-14 18:15                   ` Eli Zaretskii
2016-01-15  6:56                     ` Jussi Lahdenniemi
2016-01-15  7:52                       ` Jussi Lahdenniemi
2016-01-15  8:08                         ` Windows 9X crash (was: [PATCH] Override Windows default Win-* key combinations when using Emacs) Eli Zaretskii
2016-01-15  9:35                           ` Windows 9X crash Jussi Lahdenniemi
2016-01-15 10:18                             ` Eli Zaretskii
2016-01-15 10:31                               ` Fabrice Popineau
2016-01-15 10:33                               ` Jussi Lahdenniemi
2016-01-16  9:15                                 ` Eli Zaretskii
2016-01-15  9:47                           ` Windows 9X crash (was: [PATCH] Override Windows default Win-* key combinations when using Emacs) Fabrice Popineau
2016-01-15  9:56                             ` Windows 9X crash Jussi Lahdenniemi
2016-01-15 10:19                               ` Eli Zaretskii
2016-01-15  9:23                         ` [PATCH] Override Windows default Win-* key combinations when using Emacs Yuri Khan
2016-01-16  9:58                     ` Eli Zaretskii
2016-01-16 11:00                       ` Jussi Lahdenniemi
2016-01-16 11:41                         ` Eli Zaretskii
2016-02-03 13:59                         ` Jussi Lahdenniemi
2016-02-03 15:42                           ` Eli Zaretskii
2016-02-26 10:55                             ` Eli Zaretskii
2016-02-26 10:59                               ` Jussi Lahdenniemi
2016-02-27 11:34                                 ` Eli Zaretskii
2016-02-28  8:42                                   ` Paul Eggert
2016-02-28 15:50                                     ` Eli Zaretskii
2016-02-28 20:03                                       ` Paul Eggert
2016-02-28 20:10                                         ` Eli Zaretskii
2016-02-28 23:27                                           ` Paul Eggert
2016-02-29  3:31                                             ` Eli Zaretskii
2016-02-29  7:07                                               ` Paul Eggert [this message]
2016-02-29 15:52                                                 ` Eli Zaretskii
2016-02-29 19:01                                                   ` Paul Eggert
2016-03-05 10:16                                                     ` Eli Zaretskii
2016-03-08  2:57                                                       ` Paul Eggert
2016-03-08  4:46                                                         ` Clément Pit--Claudel
2016-02-28 23:33                                         ` John Wiegley
2016-02-27  2:11                               ` Lars Ingebrigtsen
2016-02-27  7:47                                 ` Eli Zaretskii
2016-02-28  4:40                                   ` Lars Ingebrigtsen
2016-01-13 15:53             ` Eli Zaretskii
     [not found] <<568BBC58.50702@aprikoodi.fi>

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56D3EE3A.5090803@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=jussi@aprikoodi.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).