Bruno Haible <[EMAIL PROTECTED]> wrote: > A gnulib testdir with modules fts and quotearg fails to compile on IRIX 6.5 > with CC="cc -O": > > cc -O -DHAVE_CONFIG_H -I. -I. -I.. -g -c fts.c > > "fts.c", line 244: error(1241): declaration may not appear after executable > statement in block > size_t maxarglen = fts_maxarglen(argv); > ^
Thanks. I've just checked in a fix for that, along with a few real bug fixes: [Hmm.. I see I've also included the change adding O_NOCTTY and O_NONBLOCK. I'll update the ChangeLog entry to include that. ] 2006-01-21 Jim Meyering <[EMAIL PROTECTED]> Sync from the stable (b5) branch of coreutils: * fts.c (fts_children): Don't let close() clobber errno from failed fchdir(). * fts.c (fts_stat): When following a symlink-to-directory, don't necessarily interpret stat-fails+lstat-succeeds as indicating a dangling symlink. That can also happen at least for ELOOP. The fix: return FTS_SLNONE only when the stat errno is ENOENT. FYI, this bug predates the inclusion of fts.c in coreutils. * fts.c (fts_open): Put new maxarglen declaration and uses in their own block, so pre-c99 compilers don't object. Avoid the double-free (first in fts_read, second in fts_close) that would occur when an `active' directory is made inaccessible (e.g., via chmod a-x) during a traversal. * fts.c (fts_read): After a failed fchdir, update sp->fts_cur before returning. Reproduce this failure by mkdir -p a/b; cd a; chmod a-x . b Reported by Stavros Passas. Index: lib/fts.c =================================================================== RCS file: /sources/gnulib/gnulib/lib/fts.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -p -u -r1.9 -r1.10 --- lib/fts.c 10 Jan 2006 21:31:01 -0000 1.9 +++ lib/fts.c 25 Jan 2006 16:45:04 -0000 1.10 @@ -203,7 +203,10 @@ static int internal_function diropen (char const *dir) { - return open (dir, O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK); + int fd = open (dir, O_RDONLY | O_DIRECTORY); + if (fd < 0) + fd = open (dir, O_WRONLY | O_DIRECTORY); + return fd; } FTS * @@ -241,9 +244,11 @@ fts_open (char * const *argv, #ifndef MAXPATHLEN # define MAXPATHLEN 1024 #endif - size_t maxarglen = fts_maxarglen(argv); - if (! fts_palloc(sp, MAX(maxarglen, MAXPATHLEN))) - goto mem1; + { + size_t maxarglen = fts_maxarglen(argv); + if (! fts_palloc(sp, MAX(maxarglen, MAXPATHLEN))) + goto mem1; + } /* Allocate/initialize root's parent. */ if ((parent = fts_alloc(sp, "", 0)) == NULL) @@ -693,7 +698,9 @@ fts_children (register FTS *sp, int inst return (sp->fts_child = NULL); sp->fts_child = fts_build(sp, instr); if (fchdir(fd)) { + int saved_errno = errno; (void)close(fd); + __set_errno (saved_errno); return (NULL); } (void)close(fd); @@ -1066,7 +1073,8 @@ fts_stat(FTS *sp, register FTSENT *p, bo if (ISSET(FTS_LOGICAL) || follow) { if (stat(p->fts_accpath, sbp)) { saved_errno = errno; - if (!lstat(p->fts_accpath, sbp)) { + if (errno == ENOENT + && lstat(p->fts_accpath, sbp) == 0) { __set_errno (0); return (FTS_SLNONE); } _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib