Subject: Re: CVS commit: src
To: None <source-changes@NetBSD.org>
From: Takeshi Nakayama <tn@catvmics.ne.jp>
List: source-changes
Date: 07/03/2007 04:56:32
>>> Antti Kantee <pooka@netbsd.org> wrote

> Module Name:	src
> Committed By:	pooka
> Date:		Sun Jul  1 21:41:18 UTC 2007
> 
> Modified Files:
> 	src/distrib/sets/lists/base: shl.mi
> 	src/distrib/sets/lists/comp: mi
> 	src/include: util.h
> 	src/lib/libutil: Makefile efun.3 efun.c shlib_version
> 
> Log Message:
> add estrndup()

This change breaks -current build on NetBSD 3.1 host since 3.1 has
no strndup(3).

Can I commit the following patch to fix this?

-- Takeshi Nakayama

Index: lib/libc/string/strndup.c
===================================================================
RCS file: /cvsroot/src/lib/libc/string/strndup.c,v
retrieving revision 1.3
diff -u -d -r1.3 strndup.c
--- lib/libc/string/strndup.c	14 Jan 2007 23:41:24 -0000	1.3
+++ lib/libc/string/strndup.c	2 Jul 2007 19:33:52 -0000
@@ -29,6 +29,10 @@
  * SUCH DAMAGE.
  */
 
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
 #if 0
@@ -49,6 +53,7 @@
 __weak_alias(strndup,_strndup)
 #endif
 
+#if !HAVE_STRNDUP
 char *
 strndup(const char *str, size_t n)
 {
@@ -66,3 +71,4 @@
 	copy[len] = '\0';
 	return (copy);
 }
+#endif /* !HAVE_STRNDUP */
Index: tools/compat/Makefile
===================================================================
RCS file: /cvsroot/src/tools/compat/Makefile,v
retrieving revision 1.48
diff -u -d -r1.48 Makefile
--- tools/compat/Makefile	14 Dec 2006 20:09:36 -0000	1.48
+++ tools/compat/Makefile	2 Jul 2007 19:33:52 -0000
@@ -10,7 +10,7 @@
 		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
 
Index: tools/compat/compat_defs.h
===================================================================
RCS file: /cvsroot/src/tools/compat/compat_defs.h,v
retrieving revision 1.58
diff -u -d -r1.58 compat_defs.h
--- tools/compat/compat_defs.h	9 Jan 2007 17:34:27 -0000	1.58
+++ tools/compat/compat_defs.h	2 Jul 2007 19:33:52 -0000
@@ -236,6 +236,7 @@
 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 @@
 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
Index: tools/compat/configure
===================================================================
RCS file: /cvsroot/src/tools/compat/configure,v
retrieving revision 1.61
diff -u -d -r1.61 configure
--- tools/compat/configure	9 Oct 2006 14:59:41 -0000	1.61
+++ tools/compat/configure	2 Jul 2007 19:33:53 -0000
@@ -7672,13 +7672,14 @@
 
 
 
+
 for ac_func in atoll asprintf asnprintf basename devname dirfd dirname \
 	esetfunc fgetln flock fparseln futimes getopt getopt_long \
 	group_from_gid \
 	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`
Index: tools/compat/configure.ac
===================================================================
RCS file: /cvsroot/src/tools/compat/configure.ac,v
retrieving revision 1.60
diff -u -d -r1.60 configure.ac
--- tools/compat/configure.ac	9 Oct 2006 14:59:05 -0000	1.60
+++ tools/compat/configure.ac	2 Jul 2007 19:33:53 -0000
@@ -133,7 +133,7 @@
 	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>])
Index: tools/compat/nbtool_config.h.in
===================================================================
RCS file: /cvsroot/src/tools/compat/nbtool_config.h.in,v
retrieving revision 1.15
diff -u -d -r1.15 nbtool_config.h.in
--- tools/compat/nbtool_config.h.in	9 Oct 2006 14:59:41 -0000	1.15
+++ tools/compat/nbtool_config.h.in	2 Jul 2007 19:33:53 -0000
@@ -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