Re: fix xgethostname on OSX [patch]

Jim Meyering <[email protected]> Sun, 20 Feb 2005 17:39:22 +0100
Newsgroups gmane.comp.lib.gnulib.bugs,gmane.comp.version-control.cvs.bugs
Message-ID <[email protected]>
"Mark D. Baushke" <[email protected]> wrote:
...
>   2) It seems that the patch you sent was stripped
>      by the list software on gnu.org (normally it
>      throws away attachments of any kind).
...
> I am adding [email protected] to this message so
> that they see a description of your problem. They
> may wish to consider an MacOSX change even without
> the patch your message to [email protected] was
> missing.
...
>> 2005-02-21  Neil Conway  <[email protected]>
>>
>> 	* lib/xgethostname.c: Check for ENOMEM, which is returned by
>> 	OSX/Darwin if the specified buffer is not large enough for the
>> 	hostname.

Thanks for forwarding that.
I've just checked in this change:

2005-02-20  Neil Conway  <[email protected]>

	* xgethostname.c (xgethostname): Check for ENOMEM, which is
	returned by OSX/Darwin if the specified buffer is not large
	enough for the hostname.

Index: xgethostname.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/xgethostname.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -p -u -r1.19 -r1.20
--- xgethostname.c	9 Aug 2004 23:45:32 -0000	1.19
+++ xgethostname.c	20 Feb 2005 16:35:32 -0000	1.20
@@ -1,6 +1,6 @@
 /* xgethostname.c -- return current hostname with unlimited length
 
-   Copyright (C) 1992, 1996, 2000, 2001, 2003, 2004 Free Software
+   Copyright (C) 1992, 1996, 2000, 2001, 2003, 2004, 2005 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -69,7 +69,9 @@ xgethostname (void)
 	  if (! hostname[size_1 - 1])
 	    break;
 	}
-      else if (errno != 0 && errno != ENAMETOOLONG && errno != EINVAL)
+      else if (errno != 0 && errno != ENAMETOOLONG && errno != EINVAL
+	       /* OSX/Darwin does this when the buffer is not large enough */
+	       && errno != ENOMEM)
 	{
 	  int saved_errno = errno;
 	  free (hostname);