Mercurial > emacs
diff src/xterm.c @ 398:a60eafebd43f
*** empty log message ***
| author | Jim Blandy <jimb@redhat.com> |
|---|---|
| date | Fri, 16 Aug 1991 16:09:27 +0000 |
| parents | b5cc63711808 |
| children | 10b1795f3ae9 |
line wrap: on
line diff
--- a/src/xterm.c Fri Aug 16 05:24:51 1991 +0000 +++ b/src/xterm.c Fri Aug 16 16:09:27 1991 +0000 @@ -161,6 +161,7 @@ /* Stuff for dealing with the main icon title. */ extern Lisp_Object Vcommand_line_args; +char *hostname, *x_id_name; Lisp_Object invocation_name; /* This is the X connection that we are using. */ @@ -3583,11 +3584,36 @@ #ifdef HAVE_X11 { + int hostname_size = MAXHOSTNAMELEN + 1; + + hostname = (char *) xmalloc (hostname_size); + #if 0 XSetAfterFunction (x_current_display, x_trace_wire); #endif invocation_name = Ffile_name_nondirectory (Fcar (Vcommand_line_args)); + + /* Try to get the host name; if the buffer is too short, try + again. Apparently, the only indication gethostname gives of + whether the buffer was large enough is the presence or absence + of a '\0' in the string. Eech. */ + for (;;) + { + gethostname (hostname, hostname_size - 1); + hostname[hostname_size - 1] = '\0'; + + /* Was the buffer large enough for gethostname to store the '\0'? */ + if (strlen (hostname) < hostname_size - 1) + break; + + hostname_size <<= 1; + hostname = (char *) xrealloc (hostname, hostname_size); + } + x_id_name = (char *) xmalloc (XSTRING (invocation_name)->size + + strlen (hostname) + + 2); + sprintf (x_id_name, "%s@%s", XSTRING (invocation_name)->data, hostname); } dup2 (ConnectionNumber (x_current_display), 0);
