Indent nested CPP-directives.
[gnulib.git] / lib / xgethostname.c
index 86408e7..216e78b 100644 (file)
 /* Written by Jim Meyering, meyering@comco.com */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <sys/types.h>
@@ -46,12 +39,12 @@ xgethostname ()
   int err;
 
   size = INITIAL_HOSTNAME_LENGTH;
+  hostname = xmalloc (size);
   while (1)
     {
-      hostname = xmalloc (size);
       hostname[size - 1] = '\0';
       err = gethostname (hostname, size);
-      if (err || hostname[size - 1] == '\0')
+      if (err == 0 && hostname[size - 1] == '\0')
        break;
       size *= 2;
       hostname = xrealloc (hostname, size);