summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/wchar.h2
-rw-r--r--lib/wchar.c9
2 files changed, 11 insertions, 0 deletions
diff --git a/include/wchar.h b/include/wchar.h
index fb9b127a8c..392211039a 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -17,6 +17,8 @@ char *strdup_wchar_to_char(const wchar_t *src);
size_t wcslen(const wchar_t *s);
+size_t wcsnlen(const wchar_t *s, size_t maxlen);
+
#define MB_CUR_MAX 4
int mbtowc(wchar_t *pwc, const char *s, size_t n);
diff --git a/lib/wchar.c b/lib/wchar.c
index 3be228b5a7..250538dd85 100644
--- a/lib/wchar.c
+++ b/lib/wchar.c
@@ -28,6 +28,15 @@ size_t wcslen(const wchar_t *s)
return len;
}
+size_t wcsnlen(const wchar_t * s, size_t count)
+{
+ const wchar_t *sc;
+
+ for (sc = s; count-- && *sc != L'\0'; ++sc)
+ /* nothing */;
+ return sc - s;
+}
+
wchar_t *strdup_wchar(const wchar_t *src)
{
int len = wcslen(src);