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!
This commit is contained in:
parent
e87cf683ad
commit
b53fea69d0
|
@ -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 "namespace.h"
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
@ -47,4 +47,6 @@ __warn_references(__fts_set13,
|
||||||
#include <fts.h>
|
#include <fts.h>
|
||||||
#include <compat/include/fts.h>
|
#include <compat/include/fts.h>
|
||||||
|
|
||||||
|
#define __FTS_COMPAT_TAILINGSLASH
|
||||||
|
|
||||||
#include "gen/fts.c"
|
#include "gen/fts.c"
|
||||||
|
|
|
@ -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>, October 21, 1997.
|
* Written by Jason R. Thorpe <thorpej@NetBSD.org>, October 21, 1997.
|
||||||
|
@ -44,4 +44,6 @@ __warn_references(fts_set,
|
||||||
"warning: reference to compatibility fts_set();"
|
"warning: reference to compatibility fts_set();"
|
||||||
" include <fts.h> for correct reference")
|
" include <fts.h> for correct reference")
|
||||||
|
|
||||||
|
#define __FTS_COMPAT_TAILINGSLASH
|
||||||
|
|
||||||
#include "gen/fts.c"
|
#include "gen/fts.c"
|
||||||
|
|
|
@ -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
|
* Copyright (c) 1990, 1993, 1994
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
|
static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
|
||||||
#else
|
#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
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ int
|
||||||
fts_close(FTS *sp)
|
fts_close(FTS *sp)
|
||||||
{
|
{
|
||||||
FTSENT *freep, *p;
|
FTSENT *freep, *p;
|
||||||
int saved_errno;
|
int saved_errno = 0;
|
||||||
|
|
||||||
_DIAGASSERT(sp != NULL);
|
_DIAGASSERT(sp != NULL);
|
||||||
|
|
||||||
|
@ -265,22 +265,23 @@ fts_close(FTS *sp)
|
||||||
|
|
||||||
/* Return to original directory, save errno if necessary. */
|
/* Return to original directory, save errno if necessary. */
|
||||||
if (!ISSET(FTS_NOCHDIR)) {
|
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);
|
(void)close(sp->fts_rfd);
|
||||||
/* Set errno and return. */
|
|
||||||
if (saved_errno) {
|
|
||||||
errno = saved_errno;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free up the stream pointer. */
|
/* Free up the stream pointer. */
|
||||||
free(sp);
|
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
|
* Special case of "/" at the end of the path so that slashes aren't
|
||||||
* appended which would cause paths to be written as "....//foo".
|
* appended which would cause paths to be written as "....//foo".
|
||||||
|
@ -289,6 +290,21 @@ fts_close(FTS *sp)
|
||||||
(p->fts_path[p->fts_pathlen - 1] == '/' \
|
(p->fts_path[p->fts_pathlen - 1] == '/' \
|
||||||
? p->fts_pathlen - 1 : p->fts_pathlen)
|
? 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 *
|
FTSENT *
|
||||||
fts_read(FTS *sp)
|
fts_read(FTS *sp)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue