mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-28 16:43:09 +00:00
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) MFC after: 1 month
This commit is contained in:
parent
f3215338ef
commit
45256214eb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=296278
@ -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…
Reference in New Issue
Block a user