summaryrefslogtreecommitdiff
path: root/lib-src/emacsclient.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1999-01-16 21:45:10 +0000
committerRichard M. Stallman <rms@gnu.org>1999-01-16 21:45:10 +0000
commita2b3f2b55c2d4c813e3feb0ddf005dfa6000b9d6 (patch)
treebc7595e3786b9b1c0433b54c26759536570a38d0 /lib-src/emacsclient.c
parent40beb971f4015cea4252d2f1e7dfb130a8f1ae75 (diff)
downloademacs-a2b3f2b55c2d4c813e3feb0ddf005dfa6000b9d6.tar.gz
(main): Eliminate arbitrary limit on length of system_name.
(xmalloc): Define unconditionally.
Diffstat (limited to 'lib-src/emacsclient.c')
-rw-r--r--lib-src/emacsclient.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 5e95604c4f9..412256b916e 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -146,7 +146,6 @@ quote_file_name (name)
return copy;
}
-#ifdef C_ALLOCA
/* Like malloc but get fatal error if memory is exhausted. */
char *
@@ -161,7 +160,6 @@ xmalloc (size)
}
return result;
}
-#endif /* C_ALLOCA */
#if !defined (HAVE_SOCKETS) && !defined (HAVE_SYSVIPC)
@@ -194,7 +192,8 @@ main (argc, argv)
int argc;
char **argv;
{
- char system_name[32];
+ char *system_name;
+ int system_name_length;
int s, i;
FILE *out, *in;
struct sockaddr_un server;
@@ -223,10 +222,22 @@ main (argc, argv)
#ifndef SERVER_HOME_DIR
{
struct stat statbfr;
+ system_name_length = 32;
+
+ while (1)
+ {
+ system_name = (char *) xmalloc (system_name_length + 1);
+
+ /* system_name must be null-terminated string. */
+ system_name[system_name_length] = '\0';
+
+ if (gethostname (system_name, system_name_length) == 0)
+ break;
+
+ free (system_name);
+ system_name_length *= 2;
+ }
- gethostname (system_name, sizeof (system_name));
- /* system_name must be null-terminated string */
- system_name[sizeof (system_name) - 1] = '\0';
sprintf (server.sun_path, "/tmp/esrv%d-%s", geteuid (), system_name);
if (stat (server.sun_path, &statbfr) == -1)