X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstring%2Fwcsstr.c;h=037d096578e1c647678560169eadb1679a5114c3;hb=2e762105b7b99e258d74e3585fe36161729a2b56;hp=966174f805e55056bc538aa6c527aca6cc8111ca;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/string/wcsstr.c b/src/string/wcsstr.c index 966174f8..037d0965 100644 --- a/src/string/wcsstr.c +++ b/src/string/wcsstr.c @@ -3,14 +3,6 @@ #include #include -static wchar_t *naive_wcsstr(const wchar_t *h, const wchar_t *n) -{ - size_t i; - for (i=0; n[i] && h[i]; i++) - for ( ; n[i] != h[i]; h++, i=0); - return n[i] ? 0 : (wchar_t *)h; -} - #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) @@ -101,7 +93,7 @@ static wchar_t *twoway_wcsstr(const wchar_t *h, const wchar_t *n) } } -wchar_t *wcsstr(const wchar_t *h, const wchar_t *n) +wchar_t *wcsstr(const wchar_t *restrict h, const wchar_t *restrict n) { /* Return immediately on empty needle or haystack */ if (!n[0]) return (wchar_t *)h; @@ -111,7 +103,6 @@ wchar_t *wcsstr(const wchar_t *h, const wchar_t *n) h = wcschr(h, *n); if (!h || !n[1]) return (wchar_t *)h; if (!h[1]) return 0; - if (!n[2] || !n[3] || !n[4]) return naive_wcsstr(h, n); return twoway_wcsstr(h, n); }