X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstring%2Fwcsstr.c;h=4caaef3c94bf1a43ec462264fad90ca914c82da0;hb=d4f987e4ac44e4e5ca2bcf68365b4c2b77bdf2d0;hp=fc4bacece5d6f891650574b3054fbff05dcbd4be;hpb=35c16933f03a3db49f3e2048759d850460c8a509;p=musl diff --git a/src/string/wcsstr.c b/src/string/wcsstr.c index fc4bacec..4caaef3c 100644 --- a/src/string/wcsstr.c +++ b/src/string/wcsstr.c @@ -1,7 +1,4 @@ #include -#include -#include -#include #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) @@ -87,13 +84,13 @@ static wchar_t *twoway_wcsstr(const wchar_t *h, const wchar_t *n) } /* Compare left half */ for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--); - if (k == mem) return (wchar_t *)h; + if (k <= mem) return (wchar_t *)h; h += p; mem = mem0; } } -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;