From: Lars Ingebrigtsen Date: Thu, 25 Feb 2016 05:24:03 +0000 (+1030) Subject: Allow using "number strings" as services on non-GNU systems X-Git-Tag: emacs-26.0.90~2464 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e7650ba63b552def6892ca7913194ee8c85f20d1;p=emacs.git 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. --- diff --git a/src/process.c b/src/process.c index 8c88e62ee05..62a26c381b9 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;