X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmultibyte%2Fmbsrtowcs.c;h=3c1343aea81f82d30dd055a5406b5ef63267ffc7;hb=700e08993c3f6a808773d56424aa7e633da13e2e;hp=75a493c4f5f383cab76c2d8b708509954f42cb92;hpb=50d9661d9b231f503b21e9d8787d1411b864d58a;p=musl diff --git a/src/multibyte/mbsrtowcs.c b/src/multibyte/mbsrtowcs.c index 75a493c4..3c1343ae 100644 --- a/src/multibyte/mbsrtowcs.c +++ b/src/multibyte/mbsrtowcs.c @@ -4,11 +4,9 @@ * unnecessary. */ -#include -#include +#include #include #include - #include "internal.h" size_t mbsrtowcs(wchar_t *restrict ws, const char **restrict src, size_t wn, mbstate_t *restrict st) @@ -54,9 +52,12 @@ resume0: wn--; c = 0; } else for (;;) { - if (!wn) return wn0; + if (!wn) { + *src = (const void *)s; + return wn0; + } if (*s-1u < 0x7f && (uintptr_t)s%4 == 0) { - while (wn>=4 && !(( *(uint32_t*)s | *(uint32_t*)s-0x01010101) & 0x80808080)) { + while (wn>=5 && !(( *(uint32_t*)s | *(uint32_t*)s-0x01010101) & 0x80808080)) { *ws++ = *s++; *ws++ = *s++; *ws++ = *s++;