+ /* Was the buffer large enough for the '\0'? */
+ if (strlen (hostname) < hostname_size - 1)
+ break;
+
+ hostname_size <<= 1;
+ hostname = (char *) xrealloc (hostname, hostname_size);
+ }
+ get_system_name_cache = hostname;
+#ifdef HAVE_SOCKETS
+ /* Turn the hostname into the official, fully-qualified hostname.
+ Don't do this if we're going to dump; this can confuse system
+ libraries on some machines and make the dumped emacs core dump. */
+#ifndef CANNOT_DUMP
+ if (initialized)
+#endif /* not CANNOT_DUMP */
+ {
+ struct hostent *hp = gethostbyname (hostname);
+ if (hp)
+ {
+ char *fqdn = hp->h_name;
+ if (!index (fqdn, '.'))
+ {
+ /* We still don't have a fully qualified domain name.
+ Try to find one in the list of alternate names */
+ char **alias = hp->h_aliases;
+ while (*alias && !index (*alias, '.'))
+ alias++;
+ if (*alias)
+ fqdn = *alias;
+ }
+ hostname = (char *) xrealloc (hostname, strlen (fqdn) + 1);
+ strcpy (hostname, fqdn);
+ }
+ }
+#endif /* HAVE_SOCKETS */
+ get_system_name_cache = hostname;
+ }
+#endif /* HAVE_GETHOSTNAME */
+#endif /* VMS */
+#ifndef CANNOT_DUMP
+ get_system_name_predump_p = !initialized;
+#endif
+ }
+ return (get_system_name_cache);
+#endif /* BSD4_1 */
+}