summaryrefslogtreecommitdiff
path: root/src/string
diff options
context:
space:
mode:
Diffstat (limited to 'src/string')
-rw-r--r--src/string/wcpcpy.c6
-rw-r--r--src/string/wcpncpy.c6
-rw-r--r--src/string/wcscasecmp.c7
-rw-r--r--src/string/wcscasecmp_l.c6
-rw-r--r--src/string/wcsdup.c11
-rw-r--r--src/string/wcsncasecmp.c9
-rw-r--r--src/string/wcsncasecmp_l.c6
-rw-r--r--src/string/wcsnlen.c8
-rw-r--r--src/string/wcstok.c12
9 files changed, 71 insertions, 0 deletions
diff --git a/src/string/wcpcpy.c b/src/string/wcpcpy.c
new file mode 100644
index 00000000..fdf878f6
--- /dev/null
+++ b/src/string/wcpcpy.c
@@ -0,0 +1,6 @@
+#include <wchar.h>
+
+wchar_t *wcpcpy(wchar_t *d, const wchar_t *s)
+{
+ return wcscpy(d, s) + wcslen(s);
+}
diff --git a/src/string/wcpncpy.c b/src/string/wcpncpy.c
new file mode 100644
index 00000000..aef80962
--- /dev/null
+++ b/src/string/wcpncpy.c
@@ -0,0 +1,6 @@
+#include <wchar.h>
+
+wchar_t *wcpncpy(wchar_t *d, const wchar_t *s, size_t n)
+{
+ return wcsncpy(d, s, n) + wcsnlen(s, n);
+}
diff --git a/src/string/wcscasecmp.c b/src/string/wcscasecmp.c
new file mode 100644
index 00000000..3edeec7d
--- /dev/null
+++ b/src/string/wcscasecmp.c
@@ -0,0 +1,7 @@
+#include <wchar.h>
+#include <wctype.h>
+
+int wcscasecmp(const wchar_t *l, const wchar_t *r)
+{
+ return wcsncasecmp(l, r, -1);
+}
diff --git a/src/string/wcscasecmp_l.c b/src/string/wcscasecmp_l.c
new file mode 100644
index 00000000..065dd0aa
--- /dev/null
+++ b/src/string/wcscasecmp_l.c
@@ -0,0 +1,6 @@
+#include <wchar.h>
+
+int wcscasecmp_l(const wchar_t *l, const wchar_t *r, locale_t locale)
+{
+ return wcscasecmp(l, r);
+}
diff --git a/src/string/wcsdup.c b/src/string/wcsdup.c
new file mode 100644
index 00000000..dd49c1b6
--- /dev/null
+++ b/src/string/wcsdup.c
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+#include <wchar.h>
+#include "libc.h"
+
+wchar_t *wcsdup(const wchar_t *s)
+{
+ size_t l = wcslen(s);
+ wchar_t *d = malloc((l+1)*sizeof(wchar_t));
+ if (!d) return NULL;
+ return wmemcpy(d, s, l+1);
+}
diff --git a/src/string/wcsncasecmp.c b/src/string/wcsncasecmp.c
new file mode 100644
index 00000000..8fefe799
--- /dev/null
+++ b/src/string/wcsncasecmp.c
@@ -0,0 +1,9 @@
+#include <wchar.h>
+#include <wctype.h>
+
+int wcsncasecmp(const wchar_t *l, const wchar_t *r, size_t n)
+{
+ if (!n--) return 0;
+ for (; *l && *r && n && (*l == *r || towlower(*l) == towlower(*r)); l++, r++, n--);
+ return towlower(*l) - towlower(*r);
+}
diff --git a/src/string/wcsncasecmp_l.c b/src/string/wcsncasecmp_l.c
new file mode 100644
index 00000000..63872481
--- /dev/null
+++ b/src/string/wcsncasecmp_l.c
@@ -0,0 +1,6 @@
+#include <wchar.h>
+
+int wcsncasecmp_l(const wchar_t *l, const wchar_t *r, size_t n, locale_t locale)
+{
+ return wcsncasecmp(l, r, n);
+}
diff --git a/src/string/wcsnlen.c b/src/string/wcsnlen.c
new file mode 100644
index 00000000..a7763373
--- /dev/null
+++ b/src/string/wcsnlen.c
@@ -0,0 +1,8 @@
+#include <wchar.h>
+
+size_t wcsnlen(const wchar_t *s, size_t n)
+{
+ const wchar_t *z = wmemchr(s, 0, n);
+ if (z) n = z-s;
+ return n;
+}
diff --git a/src/string/wcstok.c b/src/string/wcstok.c
new file mode 100644
index 00000000..c932d0a0
--- /dev/null
+++ b/src/string/wcstok.c
@@ -0,0 +1,12 @@
+#include <wchar.h>
+
+wchar_t *wcstok(wchar_t *s, const wchar_t *sep, wchar_t **p)
+{
+ if (!s && !(s = *p)) return NULL;
+ s += wcsspn(s, sep);
+ if (!*s) return *p = 0;
+ *p = s + wcscspn(s, sep);
+ if (**p) *(*p)++ = 0;
+ else *p = 0;
+ return s;
+}