[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: getcwd infinite recursion
From: |
Bruno Haible |
Subject: |
Re: getcwd infinite recursion |
Date: |
Sun, 14 Oct 2007 22:28:58 +0200 |
User-agent: |
KMail/1.5.4 |
Colin Watson wrote:
> REPLACE_GETCWD is 1 and unistd.h is up to date.
This is all as it should be.
> However, getcwd.c includes <unistd.h>. Should this not be "unistd.h",
> in order to use the version from Gnulib in the current directory?
Good idea? Maybe your AM_CPPFLAGS are missing -I. -I$(srcdir) ?
(The first is needed so that it finds built .h files, such as unistd.h.
The second so that it finds .h files such as xalloc.h.)
Writing "unistd.h" instead of <unistd.h> would not help, because in a VPATH
build, "unistd.h" would cause the compiler to start searching in $(srcdir),
but the generated unistd.h is in the build dir (.).
Can you tell us whether missing include directives are really the cause
of the problem?
If so, I would propose to avoid the endless recursions as in the appended
patch. In other files than getcwd.c, we are explicitly defining the function
with an 'rpl_' prefix. This avoids the infinite recursion problem but not
other problems that may arise by the lack of the -I directives.
*** lib/fchdir.c.orig 2007-10-14 22:16:20.000000000 +0200
--- lib/fchdir.c 2007-10-14 21:55:02.000000000 +0200
***************
*** 31,36 ****
--- 31,45 ----
#include "canonicalize.h"
#include "dirfd.h"
+ /* Prevent infinite recursion. These symbols must be #defined to rpl_...
+ substitute names. */
+ #if !(defined close && defined open && defined dup && defined dup2)
+ # error "gnulib configuration problem: unistd.h not working as expected"
+ #endif
+ #if !(defined closedir && defined opendir)
+ # error "gnulib configuration problem: dirent.h not working as expected"
+ #endif
+
/* This replacement assumes that a directory is not renamed while opened
through a file descriptor. */
*** lib/fopen.c.orig 2007-10-14 22:16:20.000000000 +0200
--- lib/fopen.c 2007-10-14 21:56:09.000000000 +0200
***************
*** 23,28 ****
--- 23,33 ----
#include <string.h>
+ /* Prevent infinite recursion. fopen must be #defined to rpl_fopen. */
+ #if !defined fopen
+ # error "gnulib configuration problem: stdio.h not working as expected"
+ #endif
+
FILE *
fopen (const char *filename, const char *mode)
#undef fopen
*** lib/freopen.c.orig 2007-10-14 22:16:20.000000000 +0200
--- lib/freopen.c 2007-10-14 21:56:29.000000000 +0200
***************
*** 23,28 ****
--- 23,33 ----
#include <string.h>
+ /* Prevent infinite recursion. freopen must be #defined to rpl_freopen. */
+ #if !defined freopen
+ # error "gnulib configuration problem: stdio.h not working as expected"
+ #endif
+
FILE *
freopen (const char *filename, const char *mode, FILE *stream)
#undef freopen
*** lib/getcwd.c.orig 2007-10-14 22:16:20.000000000 +0200
--- lib/getcwd.c 2007-10-14 22:12:20.000000000 +0200
***************
*** 100,105 ****
--- 100,110 ----
therefore save some unnecessary recursion in fchdir.c. */
#undef opendir
#undef closedir
+
+ /* Prevent infinite recursion. getcwd must be #defined to rpl_getcwd. */
+ #if !defined getcwd
+ # error "gnulib configuration problem: unistd.h not working as expected"
+ #endif
/* Get the name of the current working directory, and put it in SIZE
bytes of BUF. Returns NULL if the directory couldn't be determined or
*** lib/getgroups.c.orig 2007-10-14 22:16:20.000000000 +0200
--- lib/getgroups.c 2007-10-14 21:57:30.000000000 +0200
***************
*** 1,6 ****
/* provide consistent interface to getgroups for systems that don't allow N==0
! Copyright (C) 1996, 1999, 2003, 2006 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
--- 1,6 ----
/* provide consistent interface to getgroups for systems that don't allow N==0
! Copyright (C) 1996, 1999, 2003, 2006, 2007 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
***************
*** 26,31 ****
--- 26,36 ----
#include "xalloc.h"
+ /* Prevent infinite recursion. getgroups must be #defined to rpl_getgroups.
*/
+ #if !defined getgroups
+ # error "gnulib configuration problem: config.h not working as expected"
+ #endif
+
/* On at least Ultrix 4.3 and NextStep 3.2, getgroups (0, 0) always fails.
On other systems, it returns the number of supplemental groups for the
process. This function handles that special case and lets the system-
*** lib/gettimeofday.c.orig 2007-10-14 22:16:20.000000000 +0200
--- lib/gettimeofday.c 2007-10-14 22:07:18.000000000 +0200
***************
*** 32,37 ****
--- 32,43 ----
#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME
+ /* Prevent infinite recursion. These symbols must be #defined to rpl_...
+ substitute names. */
+ # if !(defined localtime && defined gmtime)
+ # error "gnulib configuration problem: config.h not working as expected"
+ # endif
+
/* Work around the bug in some systems whereby gettimeofday clobbers
the static buffer that localtime uses for its return value. The
gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has
***************
*** 77,84 ****
--- 83,97 ----
#endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */
#if TZSET_CLOBBERS_LOCALTIME
+
+ /* Prevent infinite recursion. tzset must be #defined to rpl_tzset. */
+ # if !defined tzset
+ # error "gnulib configuration problem: config.h not working as expected"
+ # endif
+
/* This is a wrapper for tzset, for systems on which tzset may clobber
the static buffer used for localtime's result. */
+
void
tzset (void)
{
***************
*** 91,96 ****
--- 104,110 ----
tzset ();
*localtime_buffer_addr = save;
}
+
#endif
/* This is a wrapper for gettimeofday. It is used only on systems
*** lib/iconv.c.orig 2007-10-14 22:16:21.000000000 +0200
--- lib/iconv.c 2007-10-14 22:01:35.000000000 +0200
***************
*** 32,37 ****
--- 32,42 ----
# endif
#endif
+ /* Prevent infinite recursion. iconv must be #defined to rpl_iconv. */
+ #if !defined iconv
+ # error "gnulib configuration problem: iconv.h not working as expected"
+ #endif
+
#if REPLACE_ICONV_UTF
/* UTF-{16,32}{BE,LE} converters taken from GNU libiconv 1.11. */
*** lib/iconv_close.c.orig 2007-10-14 22:16:21.000000000 +0200
--- lib/iconv_close.c 2007-10-14 22:01:48.000000000 +0200
***************
*** 25,30 ****
--- 25,35 ----
# define uintptr_t unsigned long
#endif
+ /* Prevent infinite recursion. iconv must be #defined to rpl_iconv. */
+ #if !defined iconv_close
+ # error "gnulib configuration problem: iconv.h not working as expected"
+ #endif
+
int
iconv_close (iconv_t cd)
#undef iconv_close
- getcwd infinite recursion, Colin Watson, 2007/10/14
- Re: getcwd infinite recursion, Bruno Haible, 2007/10/14
- Re: getcwd infinite recursion, Colin Watson, 2007/10/14
- Re: getcwd infinite recursion,
Bruno Haible <=
- Re: getcwd infinite recursion, Colin Watson, 2007/10/14
- Re: getcwd infinite recursion, Bruno Haible, 2007/10/14
- Re: getcwd infinite recursion, Ralf Wildenhues, 2007/10/15
- Re: getcwd infinite recursion, Bruno Haible, 2007/10/15
- Re: getcwd infinite recursion, Ralf Wildenhues, 2007/10/29
- Re: getcwd infinite recursion, Colin Watson, 2007/10/15
- Re: getcwd infinite recursion, Bruno Haible, 2007/10/15
- Re: getcwd infinite recursion, Jim Meyering, 2007/10/15
- Re: getcwd infinite recursion, Paul Eggert, 2007/10/16