X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmultibyte%2Fwcrtomb.c;h=ddc37a57b5c4b54dab0887b739c48cde7fe365c5;hb=b98414732d230c236b9a79c709c2b035ca67be12;hp=36180c8f00fa2fa49208ef18e8710c013a2eaba9;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/multibyte/wcrtomb.c b/src/multibyte/wcrtomb.c index 36180c8f..ddc37a57 100644 --- a/src/multibyte/wcrtomb.c +++ b/src/multibyte/wcrtomb.c @@ -5,18 +5,23 @@ */ #include -#include #include #include - #include "internal.h" -size_t wcrtomb(char *s, wchar_t wc, mbstate_t *st) +size_t wcrtomb(char *restrict s, wchar_t wc, mbstate_t *restrict st) { if (!s) return 1; if ((unsigned)wc < 0x80) { *s = wc; return 1; + } else if (MB_CUR_MAX == 1) { + if (!IS_CODEUNIT(wc)) { + errno = EILSEQ; + return -1; + } + *s = wc; + return 1; } else if ((unsigned)wc < 0x800) { *s++ = 0xc0 | (wc>>6); *s = 0x80 | (wc&0x3f);