summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2017-11-11 16:38:15 -0500
committermidipix <writeonce@midipix.org>2017-11-25 11:30:32 -0500
commitd3eab70036c0b1ae6f9958158b820f770893b2cb (patch)
tree46a2912094a3b34c67075315f231dd995fe6f319
parentb96f72d394c70d45e1ed9f38e864e1ff23700c7f (diff)
downloadu16ports-d3eab70036c0b1ae6f9958158b820f770893b2cb.tar.bz2
u16ports-d3eab70036c0b1ae6f9958158b820f770893b2cb.tar.xz
added u16_wcsnlen().
-rw-r--r--project/common.mk1
-rw-r--r--src/u16_wcsnlen.c19
2 files changed, 20 insertions, 0 deletions
diff --git a/project/common.mk b/project/common.mk
index 66ff3ab..3115329 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -4,6 +4,7 @@ API_SRCS = \
src/u16_mbstowcs.c \
src/u16_wcstombs.c \
src/u16_wcslen.c \
+ src/u16_wcsnlen.c \
INTERNAL_SRCS = \
diff --git a/src/u16_wcsnlen.c b/src/u16_wcsnlen.c
new file mode 100644
index 0000000..d155f89
--- /dev/null
+++ b/src/u16_wcsnlen.c
@@ -0,0 +1,19 @@
+/*******************************************************************/
+/* u16ports: u16 variants of wide character string functions. */
+/* Copyright (C) 2017 Z. Gilboa */
+/* Released under the Standard MIT License; see COPYING.U16PORTS. */
+/*******************************************************************/
+
+#include <stdint.h>
+#include <u16ports/u16ports.h>
+
+size_t u16_wcsnlen(const uint16_t * src, size_t len)
+{
+ const uint16_t * wch = src;
+ const uint16_t * cap = &src[len];
+
+ for (; (wch < cap) && *wch; )
+ wch++;
+
+ return wch - src;
+}