emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master e7650ba 1/2: Allow using "number strings" as servic


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master e7650ba 1/2: Allow using "number strings" as services on non-GNU systems
Date: Thu, 25 Feb 2016 05:25:13 +0000

branch: master
commit e7650ba63b552def6892ca7913194ee8c85f20d1
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Allow using "number strings" as services on non-GNU systems
    
    * src/process.c (string_integer_p): New function.
    (Fmake_network_process): Use it to allow connecting to
    services specified as "993" even when getaddrbyname isn't
    available.
---
 src/process.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/process.c b/src/process.c
index 8c88e62..62a26c3 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3428,6 +3428,17 @@ conv_numerical_to_lisp (unsigned char *number, int 
length, int port)
 }
 #endif
 
+/* Return true if STRING consists only of numerical characters. */
+static bool
+string_integer_p (Lisp_Object string)
+{
+  char *s = SSDATA (string), c;
+  while ((c = *s++))
+    if (c < '0' || c > '9')
+      return false;
+  return true;
+}
+
 /* 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
@@ -3852,6 +3863,10 @@ usage: (make-network-process &rest ARGS)  */)
     port = 0;
   else if (INTEGERP (service))
     port = (unsigned short) XINT (service);
+  /* Allow the service to be a string containing the port number,
+     because that's allowed if you have getaddrbyname. */
+  else if (string_integer_p (service))
+    port = strtol (SSDATA (service), NULL, 10);
   else
     {
       struct servent *svc_info;



reply via email to

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