MFC r296278:
mbtowc(3): set errno to EILSEQ if an incomplete character is passed. According to POSIX, The mbtowc() function shall fail if: [EILSEQ] An invalid character sequence is detected. Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D5496 Obtained from: OpenBSD (Ingo Schwarze)
This commit is contained in:
parent
4cef198587
commit
e2f5e1b2b4
@ -32,6 +32,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include "mblocal.h"
|
||||
@ -49,9 +50,15 @@ mbtowc_l(wchar_t * __restrict pwc, const char * __restrict s, size_t n, locale_t
|
||||
return (0);
|
||||
}
|
||||
rval = XLOCALE_CTYPE(locale)->__mbrtowc(pwc, s, n, &locale->mbtowc);
|
||||
if (rval == (size_t)-1 || rval == (size_t)-2)
|
||||
switch (rval) {
|
||||
case (size_t)-2:
|
||||
errno = EILSEQ;
|
||||
/* FALLTHROUGH */
|
||||
case (size_t)-1:
|
||||
return (-1);
|
||||
return ((int)rval);
|
||||
default:
|
||||
return ((int)rval);
|
||||
}
|
||||
}
|
||||
int
|
||||
mbtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n)
|
||||
|
Loading…
x
Reference in New Issue
Block a user