aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test-strndup.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-02-27 11:16:23 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-02-27 11:16:23 +0000
commit957f6aafd9fc45fb66da1888378b261ed1209036 (patch)
treead633fa7f56954e3ad4e8d1f586be4e0a9a301b3 /test-strndup.c
parent5dd8c40e5ee7a6f5e3acca5d38042a17760e0cde (diff)
downloadmandoc-957f6aafd9fc45fb66da1888378b261ed1209036.tar.gz
mandoc-957f6aafd9fc45fb66da1888378b261ed1209036.tar.zst
mandoc-957f6aafd9fc45fb66da1888378b261ed1209036.zip
Add strndup(3) compat implementation.
Jan Stary reports that MacOS X Snow Leopard and older lacks it.
Diffstat (limited to 'test-strndup.c')
-rw-r--r--test-strndup.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/test-strndup.c b/test-strndup.c
new file mode 100644
index 00000000..82e4e547
--- /dev/null
+++ b/test-strndup.c
@@ -0,0 +1,10 @@
+#include <string.h>
+
+int
+main(void)
+{
+ char *s;
+
+ s = strndup("123", 2);
+ return s[0] != '1' ? 1 : s[1] != '2' ? 2 : s[2] != '\0' ? 3 : 0;
+}