about summary refs log tree commit diff
path: root/pkgs/tools/text/gnupatch/darwin-fix.patch
blob: 50d08534814828eb4d1ba0f037a9621c8132200c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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;
+}