Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libc/locale/wctomb.c
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
wctomb_l(char *s, wchar_t wchar, locale_t locale) | wctomb_l(char *s, wchar_t wchar, locale_t locale) | ||||
{ | { | ||||
static const mbstate_t initial; | static const mbstate_t initial; | ||||
size_t rval; | size_t rval; | ||||
FIX_LOCALE(locale); | FIX_LOCALE(locale); | ||||
if (s == NULL) { | if (s == NULL) { | ||||
/* No support for state dependent encodings. */ | /* No support for state dependent encodings. */ | ||||
locale->wctomb = initial; | XLOCALE_CTYPE(locale)->wctomb = initial; | ||||
return (0); | return (0); | ||||
} | } | ||||
if ((rval = XLOCALE_CTYPE(locale)->__wcrtomb(s, wchar, &locale->wctomb)) == (size_t)-1) | if ((rval = XLOCALE_CTYPE(locale)->__wcrtomb(s, wchar, | ||||
&(XLOCALE_CTYPE(locale)->wctomb))) == (size_t)-1) | |||||
return (-1); | return (-1); | ||||
return ((int)rval); | return ((int)rval); | ||||
} | } | ||||
int | int | ||||
wctomb(char *s, wchar_t wchar) | wctomb(char *s, wchar_t wchar) | ||||
{ | { | ||||
return wctomb_l(s, wchar, __get_locale()); | return wctomb_l(s, wchar, __get_locale()); | ||||
} | } |