summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authortv <tv@NetBSD.org>2002-01-28 23:50:09 +0000
committertv <tv@NetBSD.org>2002-01-28 23:50:09 +0000
commit7f8540d87fd179bfdd9a4b13de4e11343af623ab (patch)
tree985b2073b59c786745affc6f4a53261c2e99334e /lib/libc
parent03bd9dc73f985dd9cd2d3439f8913bb91a349b7f (diff)
Add hooks to make this compilable from src/tools/compat.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/__fts13.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/lib/libc/gen/__fts13.c b/lib/libc/gen/__fts13.c
index d706663d01d..9f329d9f274 100644
--- a/lib/libc/gen/__fts13.c
+++ b/lib/libc/gen/__fts13.c
@@ -1,4 +1,4 @@
-/* $NetBSD: __fts13.c,v 1.36 2001/11/28 22:31:39 christos Exp $ */
+/* $NetBSD: __fts13.c,v 1.37 2002/01/28 23:50:09 tv Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -33,12 +33,15 @@
* SUCH DAMAGE.
*/
+#if HAVE_CONFIG_H
+#include "config.h"
+#else
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
#else
-__RCSID("$NetBSD: __fts13.c,v 1.36 2001/11/28 22:31:39 christos Exp $");
+__RCSID("$NetBSD: __fts13.c,v 1.37 2002/01/28 23:50:09 tv Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -54,6 +57,7 @@ __RCSID("$NetBSD: __fts13.c,v 1.36 2001/11/28 22:31:39 christos Exp $");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#endif /* !HAVE_CONFIG_H */
#ifdef __weak_alias
#ifdef __LIBC12_SOURCE__
@@ -89,6 +93,7 @@ __warn_references(fts_set,
" include <fts.h> for correct reference")
#endif
+#if !HAVE_FTS_H
static FTSENT *fts_alloc __P((FTS *, const char *, size_t));
static FTSENT *fts_build __P((FTS *, int));
static void fts_lfree __P((FTSENT *));
@@ -1001,6 +1006,7 @@ fts_alloc(sp, name, namelen)
_DIAGASSERT(sp != NULL);
_DIAGASSERT(name != NULL);
+#if defined(ALIGNBYTES) && defined(ALIGN)
/*
* The file name is a variable length array and no stat structure is
* necessary if the user has set the nostat bit. Allocate the FTSENT
@@ -1015,12 +1021,23 @@ fts_alloc(sp, name, namelen)
if ((p = malloc(len)) == NULL)
return (NULL);
- /* Copy the name plus the trailing NULL. */
- memmove(p->fts_name, name, namelen + 1);
-
if (!ISSET(FTS_NOSTAT))
p->fts_statp =
(struct STAT *)ALIGN((u_long)(p->fts_name + namelen + 2));
+#else
+ if ((p = malloc(sizeof(FTSENT) + namelen)) == NULL)
+ return (NULL);
+
+ if (!ISSET(FTS_NOSTAT))
+ if ((p->fts_statp = malloc(sizeof(struct STAT))) == NULL) {
+ free(p);
+ return (NULL);
+ }
+#endif
+
+ /* Copy the name plus the trailing NULL. */
+ memmove(p->fts_name, name, namelen + 1);
+
p->fts_namelen = namelen;
p->fts_path = sp->fts_path;
p->fts_errno = 0;
@@ -1042,6 +1059,11 @@ fts_lfree(head)
/* Free a linked list of structures. */
while ((p = head) != NULL) {
head = head->fts_link;
+
+#if !defined(ALIGNBYTES) || !defined(ALIGN)
+ if (p->fts_statp)
+ free(p->fts_statp);
+#endif
free(p);
}
}
@@ -1185,3 +1207,4 @@ bail:
}
return ret;
}
+#endif /* !HAVE_FTS_H */