getopt: fix compilation on darwin
authorEric Blake <ebb9@byu.net>
Wed, 7 Oct 2009 02:44:13 +0000 (20:44 -0600)
committerEric Blake <ebb9@byu.net>
Wed, 7 Oct 2009 03:25:42 +0000 (21:25 -0600)
* lib/getopt.in.h (includes): Leave breadcrumbs during system
include.
* lib/unistd.in.h (getopt): Use them to avoid recursive include.
Reported by Ludovic Courtès.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/getopt.in.h
lib/unistd.in.h

index e971922..78b3386 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-10-06  Eric Blake  <ebb9@byu.net>
+
+       getopt: fix compilation on darwin
+       * lib/getopt.in.h (includes): Leave breadcrumbs during system
+       include.
+       * lib/unistd.in.h (getopt): Use them to avoid recursive include.
+       Reported by Ludovic Courtès.
+
 2009-10-06  Bruno Haible  <bruno@clisp.org>
 
        * modules/size_max (Description): Discourage its use.
index 9de467a..7377f3c 100644 (file)
 @PRAGMA_SYSTEM_HEADER@
 #endif
 
-/* The include_next requires a split double-inclusion guard.  */
+/* The include_next requires a split double-inclusion guard.  We must
+   also inform the replacement unistd.h to not recursively use
+   <getopt.h>; our definitions will be present soon enough.  */
 #if @HAVE_GETOPT_H@
+# define _GL_SYSTEM_GETOPT
 # @INCLUDE_NEXT@ @NEXT_GETOPT_H@
+# undef _GL_SYSTEM_GETOPT
 #endif
 
 #ifndef _GL_GETOPT_H
index 38e2e13..b6ea889 100644 (file)
@@ -49,7 +49,7 @@
 #endif
 
 /* Get getopt(), optarg, optind, opterr, optopt.  */
-#if @GNULIB_UNISTD_H_GETOPT@
+#if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
 # include <getopt.h>
 #endif