aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2016-02-25 15:54:03 +1030
committerLars Ingebrigtsen2016-02-25 15:54:03 +1030
commite7650ba63b552def6892ca7913194ee8c85f20d1 (patch)
tree685fedc22d55ca9db41ad64741da5384ff670039 /src
parentce6a03cb00fb95b3e32440c1388d5f40375aadb2 (diff)
downloademacs-e7650ba63b552def6892ca7913194ee8c85f20d1.tar.gz
emacs-e7650ba63b552def6892ca7913194ee8c85f20d1.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/process.c15
1 files changed, 15 insertions, 0 deletions
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)
3428} 3428}
3429#endif 3429#endif
3430 3430
3431/* Return true if STRING consists only of numerical characters. */
3432static bool
3433string_integer_p (Lisp_Object string)
3434{
3435 char *s = SSDATA (string), c;
3436 while ((c = *s++))
3437 if (c < '0' || c > '9')
3438 return false;
3439 return true;
3440}
3441
3431/* Create a network stream/datagram client/server process. Treated 3442/* Create a network stream/datagram client/server process. Treated
3432 exactly like a normal process when reading and writing. Primary 3443 exactly like a normal process when reading and writing. Primary
3433 differences are in status display and process deletion. A network 3444 differences are in status display and process deletion. A network
@@ -3852,6 +3863,10 @@ usage: (make-network-process &rest ARGS) */)
3852 port = 0; 3863 port = 0;
3853 else if (INTEGERP (service)) 3864 else if (INTEGERP (service))
3854 port = (unsigned short) XINT (service); 3865 port = (unsigned short) XINT (service);
3866 /* Allow the service to be a string containing the port number,
3867 because that's allowed if you have getaddrbyname. */
3868 else if (string_integer_p (service))
3869 port = strtol (SSDATA (service), NULL, 10);
3855 else 3870 else
3856 { 3871 {
3857 struct servent *svc_info; 3872 struct servent *svc_info;