mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:47:35 +00:00
LibC: Implement wcsstr
This commit is contained in:
parent
1b078f87b7
commit
5ac2e84264
3 changed files with 51 additions and 0 deletions
|
@ -355,4 +355,24 @@ wchar_t* wcspbrk(const wchar_t* wcs, const wchar_t* accept)
|
|||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
wchar_t* wcsstr(const wchar_t* haystack, const wchar_t* needle)
|
||||
{
|
||||
size_t nlen = wcslen(needle);
|
||||
|
||||
if (nlen == 0)
|
||||
return const_cast<wchar_t*>(haystack);
|
||||
|
||||
size_t hlen = wcslen(haystack);
|
||||
|
||||
while (hlen >= nlen) {
|
||||
if (wcsncmp(haystack, needle, nlen) == 0)
|
||||
return const_cast<wchar_t*>(haystack);
|
||||
|
||||
haystack++;
|
||||
hlen--;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue