Add strndup(3) to libnbcompat, since estrndup(3) added into efun.c calls it.

This commit is contained in:
nakayama 2007-07-03 12:11:09 +00:00
parent b3b62c0dff
commit 0c74dffd74
6 changed files with 25 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: strndup.c,v 1.3 2007/01/14 23:41:24 cbiere Exp $ */
/* $NetBSD: strndup.c,v 1.4 2007/07/03 12:11:09 nakayama Exp $ */
/*
* Copyright (c) 1988, 1993
@ -29,12 +29,16 @@
* SUCH DAMAGE.
*/
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: strndup.c,v 1.3 2007/01/14 23:41:24 cbiere Exp $");
__RCSID("$NetBSD: strndup.c,v 1.4 2007/07/03 12:11:09 nakayama Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -49,6 +53,7 @@ __RCSID("$NetBSD: strndup.c,v 1.3 2007/01/14 23:41:24 cbiere Exp $");
__weak_alias(strndup,_strndup)
#endif
#if !HAVE_STRNDUP
char *
strndup(const char *str, size_t n)
{
@ -66,3 +71,4 @@ strndup(const char *str, size_t n)
copy[len] = '\0';
return (copy);
}
#endif /* !HAVE_STRNDUP */

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.48 2006/12/14 20:09:36 he Exp $
# $NetBSD: Makefile,v 1.49 2007/07/03 12:11:09 nakayama Exp $
HOSTLIB= nbcompat
@ -10,7 +10,7 @@ SRCS= atoll.c basename.c dirname.c fgetln.c flock.c fparseln.c \
pw_scan.c rmd160.c rmd160hl.c setenv.c setgroupent.c \
setpassent.c setprogname.c sha1.c sha1hl.c sha2.c \
sha256hl.c sha384hl.c sha512hl.c snprintf.c stat_flags.c \
strlcat.c strlcpy.c strmode.c strsep.c strsuftoll.c \
strlcat.c strlcpy.c strmode.c strndup.c strsep.c strsuftoll.c \
strtoll.c unvis.c vis.c err.c errx.c verr.c verrx.c \
vwarn.c vwarnx.c warn.c warnx.c fts.c glob.c efun.c

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat_defs.h,v 1.58 2007/01/09 17:34:27 ginsbach Exp $ */
/* $NetBSD: compat_defs.h,v 1.59 2007/07/03 12:11:09 nakayama Exp $ */
#ifndef __NETBSD_COMPAT_DEFS_H__
#define __NETBSD_COMPAT_DEFS_H__
@ -236,6 +236,7 @@ void (*esetfunc(void (*)(int, const char *, ...)))(int, const char *, ...);
size_t estrlcpy(char *, const char *, size_t);
size_t estrlcat(char *, const char *, size_t);
char *estrdup(const char *);
char *estrndup(const char *, size_t);
void *ecalloc(size_t, size_t);
void *emalloc(size_t);
void *erealloc(void *, size_t);
@ -387,6 +388,10 @@ size_t strlcpy(char *, const char *, size_t);
void strmode(mode_t, char *);
#endif
#if !HAVE_STRNDUP
char *strndup(const char *, size_t);
#endif
#if !HAVE_STRSEP || defined(__NetBSD__)
char *strsep(char **, const char *);
#endif

View File

@ -7670,6 +7670,7 @@ fi
for ac_func in atoll asprintf asnprintf basename devname dirfd dirname \
@ -7678,7 +7679,7 @@ for ac_func in atoll asprintf asnprintf basename devname dirfd dirname \
heapsort isblank issetugid lchflags lchmod lchown lutimes mkstemp \
mkdtemp poll pread putc_unlocked pwcache_userdb pwrite random setenv \
setgroupent setprogname setpassent snprintf strlcat strlcpy strmode \
strsep strsuftoll strtoll \
strndup strsep strsuftoll strtoll \
user_from_uid vasprintf vasnprintf vsnprintf
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`

View File

@ -1,4 +1,4 @@
# $NetBSD: configure.ac,v 1.60 2006/10/09 14:59:05 christos Exp $
# $NetBSD: configure.ac,v 1.61 2007/07/03 12:11:10 nakayama Exp $
#
# Autoconf definition file for libnbcompat.
#
@ -8,7 +8,7 @@ AC_CONFIG_HEADERS(nbtool_config.h)
AC_CONFIG_FILES(defs.mk)
# Autoheader header and footer
AH_TOP([/* $NetBSD: configure.ac,v 1.60 2006/10/09 14:59:05 christos Exp $ */
AH_TOP([/* $NetBSD: configure.ac,v 1.61 2007/07/03 12:11:10 nakayama Exp $ */
#ifndef __NETBSD_NBTOOL_CONFIG_H__
#define __NETBSD_NBTOOL_CONFIG_H__])
@ -133,7 +133,7 @@ AC_CHECK_FUNCS(atoll asprintf asnprintf basename devname dirfd dirname \
heapsort isblank issetugid lchflags lchmod lchown lutimes mkstemp \
mkdtemp poll pread putc_unlocked pwcache_userdb pwrite random setenv \
setgroupent setprogname setpassent snprintf strlcat strlcpy strmode \
strsep strsuftoll strtoll \
strndup strsep strsuftoll strtoll \
user_from_uid vasprintf vasnprintf vsnprintf)
AC_CHECK_DECLS([strsuftoll],,,[#include <stdlib.h>])

View File

@ -1,6 +1,6 @@
/* nbtool_config.h.in. Generated from configure.ac by autoheader. */
/* $NetBSD: nbtool_config.h.in,v 1.15 2006/10/09 14:59:41 christos Exp $ */
/* $NetBSD: nbtool_config.h.in,v 1.16 2007/07/03 12:11:10 nakayama Exp $ */
#ifndef __NETBSD_NBTOOL_CONFIG_H__
#define __NETBSD_NBTOOL_CONFIG_H__
@ -337,6 +337,9 @@
/* Define to 1 if you have the `strmode' function. */
#undef HAVE_STRMODE
/* Define to 1 if you have the `strndup' function. */
#undef HAVE_STRNDUP
/* Define to 1 if you have the `strsep' function. */
#undef HAVE_STRSEP