summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibC/wchar.cpp26
-rw-r--r--Userland/Libraries/LibC/wchar.h2
2 files changed, 28 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/wchar.cpp b/Userland/Libraries/LibC/wchar.cpp
index f6a08dc719..13c5081317 100644
--- a/Userland/Libraries/LibC/wchar.cpp
+++ b/Userland/Libraries/LibC/wchar.cpp
@@ -626,4 +626,30 @@ size_t mbsrtowcs(wchar_t* dst, char const** src, size_t len, mbstate_t* ps)
// SIZE_MAX is as close as we are going to get to "unlimited".
return mbsnrtowcs(dst, src, SIZE_MAX, len, ps);
}
+
+size_t wcscspn(wchar_t const* wcs, wchar_t const* reject)
+{
+ for (auto const* wc_pointer = wcs;;) {
+ auto c = *wc_pointer++;
+ wchar_t rc;
+ auto const* reject_copy = reject;
+ do {
+ if ((rc = *reject_copy++) == c)
+ return wc_pointer - 1 - wcs;
+ } while (rc != 0);
+ }
+}
+
+size_t wcsspn(wchar_t const* wcs, wchar_t const* accept)
+{
+ for (auto const* wc_pointer = wcs;;) {
+ auto c = *wc_pointer++;
+ wchar_t rc;
+ auto const* accept_copy = accept;
+ do {
+ if ((rc = *accept_copy++) != c)
+ return wc_pointer - 1 - wcs;
+ } while (rc != 0);
+ }
+}
}
diff --git a/Userland/Libraries/LibC/wchar.h b/Userland/Libraries/LibC/wchar.h
index 98423e9b30..3a0adce1e6 100644
--- a/Userland/Libraries/LibC/wchar.h
+++ b/Userland/Libraries/LibC/wchar.h
@@ -66,5 +66,7 @@ size_t mbsrtowcs(wchar_t*, const char**, size_t, mbstate_t*);
int wmemcmp(const wchar_t*, const wchar_t*, size_t);
size_t wcsnrtombs(char*, const wchar_t**, size_t, size_t, mbstate_t*);
size_t mbsnrtowcs(wchar_t*, const char**, size_t, size_t, mbstate_t*);
+size_t wcscspn(const wchar_t* wcs, const wchar_t* reject);
+size_t wcsspn(const wchar_t* wcs, const wchar_t* accept);
__END_DECLS