Avoid endless recursions if config.h includes some header files.
authorBruno Haible <bruno@clisp.org>
Tue, 30 Aug 2011 07:57:33 +0000 (09:57 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 30 Aug 2011 07:57:33 +0000 (09:57 +0200)
* lib/fopen.c (__need_FILE): Define already before including config.h.
* lib/freopen.c (__need_FILE): Likewise.
* lib/open.c (__need_system_fcntl_h): Likewise.
* lib/stat.c (__need_system_sys_stat_h): Likewise.
* lib/lstat.c (__need_system_sys_stat_h): Likewise.
Reported by Michael Goffioul <michael.goffioul@gmail.com>.

ChangeLog
lib/fopen.c
lib/freopen.c
lib/lstat.c
lib/open.c
lib/stat.c

index aef20cd..c7d961e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-08-30  Bruno Haible  <bruno@clisp.org>
+
+       Avoid endless recursions if config.h includes some header files.
+       * lib/fopen.c (__need_FILE): Define already before including config.h.
+       * lib/freopen.c (__need_FILE): Likewise.
+       * lib/open.c (__need_system_fcntl_h): Likewise.
+       * lib/stat.c (__need_system_sys_stat_h): Likewise.
+       * lib/lstat.c (__need_system_sys_stat_h): Likewise.
+       Reported by Michael Goffioul <michael.goffioul@gmail.com>.
+
 2011-08-25  Karl Berry  <karl@gnu.org>
 
        * config/srclist.txt (ylwrap): new try.
index 81c8617..33412fb 100644 (file)
 
 /* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
 
+/* If the user's config.h happens to include <stdio.h>, let it include only
+   the system's <stdio.h> here, so that orig_fopen doesn't recurse to
+   rpl_fopen.  */
+#define __need_FILE
 #include <config.h>
 
 /* Get the original definition of fopen.  It might be defined as a macro.  */
-#define __need_FILE
 #include <stdio.h>
 #undef __need_FILE
 
index 0decbaf..c763365 100644 (file)
 
 /* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
 
+/* If the user's config.h happens to include <stdio.h>, let it include only
+   the system's <stdio.h> here, so that orig_freopen doesn't recurse to
+   rpl_freopen.  */
+#define __need_FILE
 #include <config.h>
 
 /* Get the original definition of freopen.  It might be defined as a macro.  */
-#define __need_FILE
 #include <stdio.h>
 #undef __need_FILE
 
index b26065e..29fc6d2 100644 (file)
 
 /* written by Jim Meyering */
 
+/* If the user's config.h happens to include <sys/stat.h>, let it include only
+   the system's <sys/stat.h> here, so that orig_lstat doesn't recurse to
+   rpl_lstat.  */
+#define __need_system_sys_stat_h
 #include <config.h>
 
 #if !HAVE_LSTAT
@@ -27,7 +31,6 @@ typedef int dummy;
 #else /* HAVE_LSTAT */
 
 /* Get the original definition of lstat.  It might be defined as a macro.  */
-# define __need_system_sys_stat_h
 # include <sys/types.h>
 # include <sys/stat.h>
 # undef __need_system_sys_stat_h
index e60b619..ffd3b8d 100644 (file)
 
 /* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
 
+/* If the user's config.h happens to include <fcntl.h>, let it include only
+   the system's <fcntl.h> here, so that orig_open doesn't recurse to
+   rpl_open.  */
+#define __need_system_fcntl_h
 #include <config.h>
 
 /* Get the original definition of open.  It might be defined as a macro.  */
-#define __need_system_fcntl_h
 #include <fcntl.h>
-#undef __need_system_fcntl_h
 #include <sys/types.h>
+#undef __need_system_fcntl_h
 
 static inline int
 orig_open (const char *filename, int flags, mode_t mode)
index f07370d..6c354d1 100644 (file)
 
 /* written by Eric Blake */
 
+/* If the user's config.h happens to include <sys/stat.h>, let it include only
+   the system's <sys/stat.h> here, so that orig_stat doesn't recurse to
+   rpl_stat.  */
+#define __need_system_sys_stat_h
 #include <config.h>
 
 /* Get the original definition of stat.  It might be defined as a macro.  */
-#define __need_system_sys_stat_h
 #include <sys/types.h>
 #include <sys/stat.h>
 #undef __need_system_sys_stat_h