summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc/port/locale/mbsinit.c
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@fingolfin.org>2020-04-19 11:34:35 +0000
committerRobert Mustacchi <rm@fingolfin.org>2020-06-07 00:49:08 +0000
commiteda3ef2de2d15b389090f6ef953edaea3daaace4 (patch)
tree0b56560d5acc9cedb2dae078f5398d84158e546d /usr/src/lib/libc/port/locale/mbsinit.c
parente214b19eaa16fec1fa60a97227778103f598336f (diff)
downloadillumos-gate-eda3ef2de2d15b389090f6ef953edaea3daaace4.tar.gz
12689 Want c11 uchar.h
Reviewed by: Yuri Pankov <ypankov@tintri.com> Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> Reviewed by: Toomas Soome <tsoome@me.com> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/lib/libc/port/locale/mbsinit.c')
-rw-r--r--usr/src/lib/libc/port/locale/mbsinit.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/usr/src/lib/libc/port/locale/mbsinit.c b/usr/src/lib/libc/port/locale/mbsinit.c
index ae956d0f15..e6227ee62e 100644
--- a/usr/src/lib/libc/port/locale/mbsinit.c
+++ b/usr/src/lib/libc/port/locale/mbsinit.c
@@ -17,10 +17,28 @@
#include <locale.h>
#include "localeimpl.h"
#include "lctype.h"
+#include "mblocal.h"
int
mbsinit_l(const mbstate_t *s, locale_t loc)
{
+
+ /*
+ * To implement support for the C11 char16_t conversion functions
+ * (mbrtoc16() and c16rtomb()) we opted to leverage all of the existing
+ * conversion infrastructure, including the per-locale conversion
+ * structures. The char16_t conversion functions tack an extra member in
+ * the mbstate_t that occurs after all others have placed their data.
+ * Therefore, before we go to the per-locale backend we need to see if
+ * there is any outstanding state in the char16_t specific state.
+ */
+ if (s != NULL) {
+ const _CHAR16State *c16s = (const _CHAR16State *)s;
+ if (c16s->c16_surrogate != 0) {
+ return (0);
+ }
+ }
+
return (loc->ctype->lc_mbsinit(s));
}