Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc Restore the compatibility versions of fts not to do...
details: https://anonhg.NetBSD.org/src/rev/00b55603d726
branches: trunk
changeset: 586242:00b55603d726
user: christos <christos%NetBSD.org@localhost>
date: Sun Dec 11 04:12:58 2005 +0000
description:
Restore the compatibility versions of fts not to do path mangling (i.e.
remove double slashes). Also make sure we free sp in all cases. From yamt,
many thanks!
diffstat:
lib/libc/compat/gen/compat___fts13.c | 4 ++-
lib/libc/compat/gen/compat_fts.c | 4 ++-
lib/libc/gen/fts.c | 38 +++++++++++++++++++++++++----------
3 files changed, 33 insertions(+), 13 deletions(-)
diffs (113 lines):
diff -r b0ed0f2bbfc3 -r 00b55603d726 lib/libc/compat/gen/compat___fts13.c
--- a/lib/libc/compat/gen/compat___fts13.c Sun Dec 11 02:40:25 2005 +0000
+++ b/lib/libc/compat/gen/compat___fts13.c Sun Dec 11 04:12:58 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat___fts13.c,v 1.1 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: compat___fts13.c,v 1.2 2005/12/11 04:12:58 christos Exp $ */
#include "namespace.h"
#include <sys/cdefs.h>
@@ -47,4 +47,6 @@
#include <fts.h>
#include <compat/include/fts.h>
+#define __FTS_COMPAT_TAILINGSLASH
+
#include "gen/fts.c"
diff -r b0ed0f2bbfc3 -r 00b55603d726 lib/libc/compat/gen/compat_fts.c
--- a/lib/libc/compat/gen/compat_fts.c Sun Dec 11 02:40:25 2005 +0000
+++ b/lib/libc/compat/gen/compat_fts.c Sun Dec 11 04:12:58 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_fts.c,v 1.1 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: compat_fts.c,v 1.2 2005/12/11 04:12:58 christos Exp $ */
/*
* Written by Jason R. Thorpe <thorpej%NetBSD.org@localhost>, October 21, 1997.
@@ -44,4 +44,6 @@
"warning: reference to compatibility fts_set();"
" include <fts.h> for correct reference")
+#define __FTS_COMPAT_TAILINGSLASH
+
#include "gen/fts.c"
diff -r b0ed0f2bbfc3 -r 00b55603d726 lib/libc/gen/fts.c
--- a/lib/libc/gen/fts.c Sun Dec 11 02:40:25 2005 +0000
+++ b/lib/libc/gen/fts.c Sun Dec 11 04:12:58 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fts.c,v 1.28 2005/11/18 16:48:48 christos Exp $ */
+/* $NetBSD: fts.c,v 1.29 2005/12/11 04:12:58 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
#else
-__RCSID("$NetBSD: fts.c,v 1.28 2005/11/18 16:48:48 christos Exp $");
+__RCSID("$NetBSD: fts.c,v 1.29 2005/12/11 04:12:58 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -236,7 +236,7 @@
fts_close(FTS *sp)
{
FTSENT *freep, *p;
- int saved_errno;
+ int saved_errno = 0;
_DIAGASSERT(sp != NULL);
@@ -265,22 +265,23 @@
/* Return to original directory, save errno if necessary. */
if (!ISSET(FTS_NOCHDIR)) {
- saved_errno = fchdir(sp->fts_rfd) ? errno : 0;
+ if (fchdir(sp->fts_rfd) == -1)
+ saved_errno = errno;
(void)close(sp->fts_rfd);
- /* Set errno and return. */
- if (saved_errno) {
- errno = saved_errno;
- return (-1);
- }
}
/* Free up the stream pointer. */
free(sp);
- /* ISSET() is illegal after this, since the macro touches sp */
+ if (saved_errno) {
+ errno = saved_errno;
+ return -1;
+ }
- return (0);
+ return 0;
}
+#if !defined(__FTS_COMPAT_TAILINGSLASH)
+
/*
* Special case of "/" at the end of the path so that slashes aren't
* appended which would cause paths to be written as "....//foo".
@@ -289,6 +290,21 @@
(p->fts_path[p->fts_pathlen - 1] == '/' \
? p->fts_pathlen - 1 : p->fts_pathlen)
+#else /* !defined(__FTS_COMPAT_TAILINGSLASH) */
+
+/*
+ * compatibility with the old behaviour.
+ *
+ * Special case a root of "/" so that slashes aren't appended which would
+ * cause paths to be written as "//foo".
+ */
+
+#define NAPPEND(p) \
+ (p->fts_level == FTS_ROOTLEVEL && p->fts_pathlen == 1 && \
+ p->fts_path[0] == '/' ? 0 : p->fts_pathlen)
+
+#endif /* !defined(__FTS_COMPAT_TAILINGSLASH) */
+
FTSENT *
fts_read(FTS *sp)
{
Home |
Main Index |
Thread Index |
Old Index