mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 02:08:12 +03:00
LibC: Implement wcs{,c}spn()
This commit is contained in:
parent
4f8d095f5a
commit
3b281baf75
Notes:
sideshowbarker
2024-07-18 03:20:18 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/3b281baf75b Pull-request: https://github.com/SerenityOS/serenity/pull/11324 Reviewed-by: https://github.com/BertalanD
@ -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".
|
// SIZE_MAX is as close as we are going to get to "unlimited".
|
||||||
return mbsnrtowcs(dst, src, SIZE_MAX, len, ps);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
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 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 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
|
__END_DECLS
|
||||||
|
Loading…
Reference in New Issue
Block a user