setlocale.h: Fix current locale handling for !__HAVE_LOCALE_INFO__ targets

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2016-07-28 09:50:43 +02:00
parent beb721cf37
commit 1a5d08014b
3 changed files with 14 additions and 21 deletions

View File

@ -69,13 +69,8 @@ extern int toascii_l (int __c, locale_t __l);
#ifndef _MB_CAPABLE #ifndef _MB_CAPABLE
_CONST _CONST
#endif #endif
#ifdef __HAVE_LOCALE_INFO__
char *__locale_ctype_ptr (void); char *__locale_ctype_ptr (void);
# define __CTYPE_PTR (__locale_ctype_ptr ()) # define __CTYPE_PTR (__locale_ctype_ptr ())
#else
extern __IMPORT char *__ctype_ptr__;
# define __CTYPE_PTR (__ctype_ptr__)
#endif
#ifndef __cplusplus #ifndef __cplusplus
/* These macros are intentionally written in a manner that will trigger /* These macros are intentionally written in a manner that will trigger

View File

@ -978,11 +978,10 @@ _DEFUN_VOID (__locale_mb_cur_max)
#ifdef __HAVE_LOCALE_INFO__ #ifdef __HAVE_LOCALE_INFO__
return __get_current_ctype_locale ()->mb_cur_max[0]; return __get_current_ctype_locale ()->mb_cur_max[0];
#else #else
return __get_global_locale ()->mb_cur_max[0]; return __get_current_locale ()->mb_cur_max[0];
#endif #endif
} }
#ifdef __HAVE_LOCALE_INFO__
char * char *
_DEFUN_VOID (__locale_ctype_ptr) _DEFUN_VOID (__locale_ctype_ptr)
{ {
@ -992,7 +991,6 @@ _DEFUN_VOID (__locale_ctype_ptr)
return __get_locale_r (_REENT) ? __get_locale_r (_REENT)->ctype_ptr return __get_locale_r (_REENT) ? __get_locale_r (_REENT)->ctype_ptr
: __ctype_ptr__; : __ctype_ptr__;
} }
#endif
char * char *
__locale_ctype_ptr_l (struct __locale_t *locale) __locale_ctype_ptr_l (struct __locale_t *locale)

View File

@ -242,12 +242,21 @@ __get_current_collate_locale (void)
} }
#endif #endif
#ifdef __HAVE_LOCALE_INFO__
_ELIDABLE_INLINE const struct lc_ctype_T * _ELIDABLE_INLINE const struct lc_ctype_T *
__get_ctype_locale (struct __locale_t *locale) __get_ctype_locale (struct __locale_t *locale)
{ {
return (const struct lc_ctype_T *) (locale)->lc_cat[LC_CTYPE].ptr; return (const struct lc_ctype_T *) (locale)->lc_cat[LC_CTYPE].ptr;
} }
_ELIDABLE_INLINE const struct lc_ctype_T *
__get_current_ctype_locale (void)
{
return (const struct lc_ctype_T *)
__get_current_locale ()->lc_cat[LC_CTYPE].ptr;
}
#endif
_ELIDABLE_INLINE int _ELIDABLE_INLINE int
__locale_mb_cur_max_l (struct __locale_t *locale) __locale_mb_cur_max_l (struct __locale_t *locale)
{ {
@ -258,13 +267,7 @@ __locale_mb_cur_max_l (struct __locale_t *locale)
#endif #endif
} }
_ELIDABLE_INLINE const struct lc_ctype_T * #ifdef __HAVE_LOCALE_INFO__
__get_current_ctype_locale (void)
{
return (const struct lc_ctype_T *)
__get_current_locale ()->lc_cat[LC_CTYPE].ptr;
}
_ELIDABLE_INLINE const struct lc_monetary_T * _ELIDABLE_INLINE const struct lc_monetary_T *
__get_monetary_locale (struct __locale_t *locale) __get_monetary_locale (struct __locale_t *locale)
{ {
@ -316,6 +319,7 @@ __get_current_messages_locale (void)
return (const struct lc_messages_T *) return (const struct lc_messages_T *)
__get_current_locale ()->lc_cat[LC_MESSAGES].ptr; __get_current_locale ()->lc_cat[LC_MESSAGES].ptr;
} }
#endif
_ELIDABLE_INLINE const char * _ELIDABLE_INLINE const char *
__locale_charset (void) __locale_charset (void)
@ -323,7 +327,7 @@ __locale_charset (void)
#ifdef __HAVE_LOCALE_INFO__ #ifdef __HAVE_LOCALE_INFO__
return __get_current_ctype_locale ()->codeset; return __get_current_ctype_locale ()->codeset;
#else #else
return __global_locale.ctype_codeset; return __get_current_locale ()->ctype_codeset;
#endif #endif
} }
@ -333,18 +337,14 @@ __locale_msgcharset (void)
#ifdef __HAVE_LOCALE_INFO__ #ifdef __HAVE_LOCALE_INFO__
return (char *) __get_current_messages_locale ()->codeset; return (char *) __get_current_messages_locale ()->codeset;
#else #else
return (char *) __global_locale.message_codeset; return (char *) __get_current_locale ()->message_codeset;
#endif #endif
} }
_ELIDABLE_INLINE int _ELIDABLE_INLINE int
__locale_cjk_lang (void) __locale_cjk_lang (void)
{ {
#ifdef __HAVE_LOCALE_INFO__
return __get_current_locale ()->cjk_lang; return __get_current_locale ()->cjk_lang;
#else
return __global_locale.cjk_lang;
#endif
} }
int __ctype_load_locale (struct __locale_t *, const char *, void *, int __ctype_load_locale (struct __locale_t *, const char *, void *,