Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/locale/setrunelocale.c
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <wchar.h> | #include <wchar.h> | ||||
#include "ldpart.h" | #include "ldpart.h" | ||||
#include "mblocal.h" | #include "mblocal.h" | ||||
#include "setlocale.h" | #include "setlocale.h" | ||||
#undef _CurrentRuneLocale | #undef _CurrentRuneLocale | ||||
extern _RuneLocale const *_CurrentRuneLocale; | extern _RuneLocale const *_CurrentRuneLocale; | ||||
#ifndef __NO_TLS | |||||
/* | /* | ||||
* A cached version of the runes for this thread. Used by ctype.h | * A cached version of the runes for this thread. Used by ctype.h | ||||
*/ | */ | ||||
_Thread_local const _RuneLocale *_ThreadRuneLocale; | _Thread_local const _RuneLocale *_ThreadRuneLocale; | ||||
#endif | |||||
extern int __mb_sb_limit; | extern int __mb_sb_limit; | ||||
extern _RuneLocale *_Read_RuneMagi(const char *); | extern _RuneLocale *_Read_RuneMagi(const char *); | ||||
static int __setrunelocale(struct xlocale_ctype *l, const char *); | static int __setrunelocale(struct xlocale_ctype *l, const char *); | ||||
static void | static void | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | if (ret != 0) { | ||||
return (_LDP_ERROR); | return (_LDP_ERROR); | ||||
} | } | ||||
__mb_cur_max = __xlocale_global_ctype.__mb_cur_max; | __mb_cur_max = __xlocale_global_ctype.__mb_cur_max; | ||||
__mb_sb_limit = __xlocale_global_ctype.__mb_sb_limit; | __mb_sb_limit = __xlocale_global_ctype.__mb_sb_limit; | ||||
_CurrentRuneLocale = __xlocale_global_ctype.runes; | _CurrentRuneLocale = __xlocale_global_ctype.runes; | ||||
return (_LDP_LOADED); | return (_LDP_LOADED); | ||||
} | } | ||||
#ifndef __NO_TLS | |||||
void | void | ||||
__set_thread_rune_locale(locale_t loc) | __set_thread_rune_locale(locale_t loc) | ||||
{ | { | ||||
if (loc == NULL) { | if (loc == NULL) { | ||||
_ThreadRuneLocale = &_DefaultRuneLocale; | _ThreadRuneLocale = &_DefaultRuneLocale; | ||||
} else if (loc == LC_GLOBAL_LOCALE) { | } else if (loc == LC_GLOBAL_LOCALE) { | ||||
_ThreadRuneLocale = 0; | _ThreadRuneLocale = 0; | ||||
} else { | } else { | ||||
_ThreadRuneLocale = XLOCALE_CTYPE(loc)->runes; | _ThreadRuneLocale = XLOCALE_CTYPE(loc)->runes; | ||||
} | } | ||||
} | } | ||||
#endif | |||||
void * | void * | ||||
__ctype_load(const char *locale, locale_t unused __unused) | __ctype_load(const char *locale, locale_t unused __unused) | ||||
{ | { | ||||
struct xlocale_ctype *l = calloc(sizeof(struct xlocale_ctype), 1); | struct xlocale_ctype *l = calloc(sizeof(struct xlocale_ctype), 1); | ||||
l->header.header.destructor = destruct_ctype; | l->header.header.destructor = destruct_ctype; | ||||
if (__setrunelocale(l, locale)) { | if (__setrunelocale(l, locale)) { | ||||
free(l); | free(l); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
return (l); | return (l); | ||||
} | } |