0a9d954bc6
svn path=/nixpkgs/trunk/; revision=33892
61 lines
2.0 KiB
Diff
61 lines
2.0 KiB
Diff
Fix builds on Darwin:
|
|
http://lists.gnu.org/archive/html/bug-patch/2010-01/msg00004.html .
|
|
|
|
|
|
commit 2c4e3ecddec8a686bd50d238f4cefebb950298b7
|
|
Author: Andreas Gruenbacher <agruen@suse.de>
|
|
Date: Fri Jan 1 15:58:15 2010 +0100
|
|
|
|
* Makefile.in (LIBSRCS, LIBM4FILES): Add the missing files strnlen.c,
|
|
strnlen.m4, and safe-read.m4.
|
|
|
|
diff --git a/Makefile.in b/Makefile.in
|
|
index 3b3d78a..26dc281 100644
|
|
--- a/Makefile.in
|
|
+++ b/Makefile.in
|
|
@@ -91,6 +91,7 @@ LIBSRCS = \
|
|
gl/lib/stripslash.c \
|
|
gl/lib/strncasecmp.c \
|
|
gl/lib/strndup.c \
|
|
+ gl/lib/strnlen.c \
|
|
gl/lib/xmalloc.c \
|
|
gl/lib/xstrndup.c
|
|
|
|
|
|
Add the missing bits from Gnulib.
|
|
|
|
--- /dev/null 2012-04-23 08:54:35.747205543 +0200
|
|
+++ b/gl/lib/strnlen.c 2012-01-16 22:35:02.000000000 +0100
|
|
@@ -0,0 +1,31 @@
|
|
+/* Find the length of STRING, but scan at most MAXLEN characters.
|
|
+ Copyright (C) 2005-2007, 2009-2012 Free Software Foundation, Inc.
|
|
+ Written by Simon Josefsson.
|
|
+
|
|
+ This program is free software; you can redistribute it and/or modify
|
|
+ it under the terms of the GNU General Public License as published by
|
|
+ the Free Software Foundation; either version 2, or (at your option)
|
|
+ any later version.
|
|
+
|
|
+ This program is distributed in the hope that it will be useful,
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
+ GNU General Public License for more details.
|
|
+
|
|
+ You should have received a copy of the GNU General Public License
|
|
+ along with this program; if not, write to the Free Software Foundation,
|
|
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
|
+
|
|
+#include <config.h>
|
|
+
|
|
+#include <string.h>
|
|
+
|
|
+/* Find the length of STRING, but scan at most MAXLEN characters.
|
|
+ If no '\0' terminator is found in that many characters, return MAXLEN. */
|
|
+
|
|
+size_t
|
|
+strnlen (const char *string, size_t maxlen)
|
|
+{
|
|
+ const char *end = memchr (string, '\0', maxlen);
|
|
+ return end ? (size_t) (end - string) : maxlen;
|
|
+}
|