Add Musl multibyte functions

These are standard functions that are needed to help support the Skull
language. Note that normally this codebase uses libc/str/thompike.h

See #105
This commit is contained in:
Justine Tunney 2021-03-06 09:52:29 -08:00
parent cfd453d125
commit 11ec99931b
28 changed files with 1064 additions and 131 deletions

View file

@ -28,6 +28,15 @@
* @see memmem()
*/
wchar_t *wcsstr(const wchar_t *haystack, const wchar_t *needle) {
return memmem(haystack, wcslen(haystack) * sizeof(wchar_t), needle,
wcslen(needle) * sizeof(wchar_t));
size_t i;
for (;;) {
for (i = 0;;) {
if (!needle[i]) return (/*unconst*/ wchar_t *)haystack;
if (!haystack[i]) break;
if (needle[i] != haystack[i]) break;
++i;
}
if (!*haystack++) break;
}
return NULL;
}