Solaris, Mingw32 & OS X prior to 10.7 are missing strnlen, so provide an

implementation.  Sent request for similar fix upstream.
This commit is contained in:
tez 2014-01-06 17:43:50 +00:00
parent 632c9b4bb2
commit 93cbe22f60
3 changed files with 36 additions and 2 deletions

View file

@ -1,6 +1,7 @@
# $NetBSD: Makefile,v 1.41 2013/12/31 11:06:29 wiz Exp $
# $NetBSD: Makefile,v 1.42 2014/01/06 17:43:50 tez Exp $
DISTNAME= mdocml-1.12.3
PKGREVISION= 1
CATEGORIES= textproc devel
MASTER_SITES= http://mdocml.bsd.lv/snapshots/

View file

@ -1,9 +1,10 @@
$NetBSD: distinfo,v 1.32 2013/12/31 11:06:29 wiz Exp $
$NetBSD: distinfo,v 1.33 2014/01/06 17:43:50 tez Exp $
SHA1 (mdocml-1.12.3.tar.gz) = 6a74b4e4b54a20b8022f05236e2294ad2915e5d7
RMD160 (mdocml-1.12.3.tar.gz) = 0a9a717ddf9d32c4ce1be8e51659932c5ccf2b8b
Size (mdocml-1.12.3.tar.gz) = 292544 bytes
SHA1 (patch-Makefile) = 569fdf24dff306c6c7222a3807e99d9ae1bb0ce6
SHA1 (patch-apropos__db.c) = efde1e020c84307e8549cf8b3e25668023fb4d34
SHA1 (patch-mdoc_validate.c) = 270d754613fa4f1e079cc047593d1eb05c9fc7a9
SHA1 (patch-preconv.1) = 92787c58f451e1d247a25bbe136f188bf42e4c73
SHA1 (patch-roff.7) = 9b6033b5ec92c8e8c827fe79aff30228f7c2fc2f

View file

@ -0,0 +1,32 @@
$NetBSD: patch-mdoc_validate.c,v 1.1 2014/01/06 17:43:50 tez Exp $
Solaris, Mingw32 & OS X prior to 10.7 are missing strnlen
--- mdoc_validate.c.orig Mon Jan 6 10:25:04 2014
+++ mdoc_validate.c Mon Jan 6 10:36:31 2014
@@ -1863,6 +1863,15 @@
return(1);
}
+#if defined(__MINGW32__) ||defined(__sun) || defined(__APPLE__)
+static size_t p_strnlen(const char *s, size_t maxlen) {
+ const char *end = memchr(s, 0, maxlen);
+ return end ? (size_t)(end - s) : maxlen;
+}
+#else
+ # define p_strnlen strnlen
+#endif
+
/*
* For some arguments of some macros,
* convert all breakable hyphens into ASCII_HYPH.
@@ -1893,7 +1902,7 @@
if (MDOC_TEXT != nch->type)
continue;
cp = nch->string;
- if (3 > strnlen(cp, 3))
+ if (3 > p_strnlen(cp, 3))
continue;
while ('\0' != *(++cp))
if ('-' == *cp &&