fix negated return value of ns_skiprr, breakage in related functions
[musl] / src / multibyte / mbrtowc.c
index e7b3654..ca7da70 100644 (file)
@@ -4,6 +4,7 @@
  * unnecessary.
  */
 
+#include <stdlib.h>
 #include <wchar.h>
 #include <errno.h>
 #include "internal.h"
@@ -27,6 +28,7 @@ size_t mbrtowc(wchar_t *restrict wc, const char *restrict src, size_t n, mbstate
        if (!n) return -2;
        if (!c) {
                if (*s < 0x80) return !!(*wc = *s);
+               if (MB_CUR_MAX==1) return (*wc = CODEUNIT(*s)), 1;
                if (*s-SA > SB-SA) goto ilseq;
                c = bittab[*s++-SA]; n--;
        }