summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC/wchar.cpp
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-12-19 20:51:30 +0330
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-12-21 21:24:36 +0330
commit3b281baf75b2b61028f54aa46fd4c8b62c5c0fec (patch)
treefbb19a51b878ea05d6ae4eed0f5dd635e819688c /Userland/Libraries/LibC/wchar.cpp
parent4f8d095f5ac93d6b1fef54649eae1db2d11b4f65 (diff)
downloadserenity-3b281baf75b2b61028f54aa46fd4c8b62c5c0fec.zip
LibC: Implement wcs{,c}spn()
Diffstat (limited to 'Userland/Libraries/LibC/wchar.cpp')
-rw-r--r--Userland/Libraries/LibC/wchar.cpp26
1 files changed, 26 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);
+ }
+}
}