mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-31 11:30:56 +08:00
Use !__HAVE_LOCALE_INFO__ define to use _ctype_ directly [v2]
When __HAVE_LOCALE_INFO__ is not selected, directly access the existing _ctype_ variable from __locale_ctype_ptr() and __locale_ctype_ptr_l(), eliminating the need for any locale or reent structure Signed-off-by: Keith Packard <keithp@keithp.com> v2: locale: fix conflict with __locale_ctype_ptr macro If we are building without __HAVE_LOCALE_INFO__, there is a macro providing __locale_ctype_ptr which in turn fouls up this declaration. Signed-off-by: Michael Lyle <mlyle@lyle.org>
This commit is contained in:
parent
3b6994ec5f
commit
77f8a6dfab
@ -66,7 +66,12 @@ extern int toascii_l (int __c, locale_t __l);
|
|||||||
#define _X 0100
|
#define _X 0100
|
||||||
#define _B 0200
|
#define _B 0200
|
||||||
|
|
||||||
|
#ifdef __HAVE_LOCALE_INFO__
|
||||||
const char *__locale_ctype_ptr (void);
|
const char *__locale_ctype_ptr (void);
|
||||||
|
#else
|
||||||
|
#define __locale_ctype_ptr() _ctype_
|
||||||
|
#endif
|
||||||
|
|
||||||
# define __CTYPE_PTR (__locale_ctype_ptr ())
|
# define __CTYPE_PTR (__locale_ctype_ptr ())
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
@ -100,7 +105,11 @@ const char *__locale_ctype_ptr (void);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __POSIX_VISIBLE >= 200809
|
#if __POSIX_VISIBLE >= 200809
|
||||||
|
#ifdef __HAVE_LOCALE_INFO__
|
||||||
const char *__locale_ctype_ptr_l (locale_t);
|
const char *__locale_ctype_ptr_l (locale_t);
|
||||||
|
#else
|
||||||
|
#define __locale_ctype_ptr_l(l) _ctype_
|
||||||
|
#endif
|
||||||
#define __ctype_lookup_l(__c,__l) ((__locale_ctype_ptr_l(__l)+sizeof(""[__c]))[(int)(__c)])
|
#define __ctype_lookup_l(__c,__l) ((__locale_ctype_ptr_l(__l)+sizeof(""[__c]))[(int)(__c)])
|
||||||
|
|
||||||
#define isalpha_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_U|_L))
|
#define isalpha_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_U|_L))
|
||||||
|
@ -981,6 +981,7 @@ __locale_mb_cur_max (void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __HAVE_LOCALE_INFO__
|
||||||
const char *
|
const char *
|
||||||
__locale_ctype_ptr_l (struct __locale_t *locale)
|
__locale_ctype_ptr_l (struct __locale_t *locale)
|
||||||
{
|
{
|
||||||
@ -992,6 +993,7 @@ __locale_ctype_ptr (void)
|
|||||||
{
|
{
|
||||||
return __get_current_locale ()->ctype_ptr;
|
return __get_current_locale ()->ctype_ptr;
|
||||||
}
|
}
|
||||||
|
#endif /* __HAVE_LOCALE_INFO__ */
|
||||||
|
|
||||||
#ifndef _REENT_ONLY
|
#ifndef _REENT_ONLY
|
||||||
|
|
||||||
|
@ -217,7 +217,11 @@ __get_global_locale ()
|
|||||||
_ELIDABLE_INLINE struct __locale_t *
|
_ELIDABLE_INLINE struct __locale_t *
|
||||||
__get_locale_r (struct _reent *r)
|
__get_locale_r (struct _reent *r)
|
||||||
{
|
{
|
||||||
|
#ifdef __HAVE_LOCALE_INFO__
|
||||||
return r->_locale;
|
return r->_locale;
|
||||||
|
#else
|
||||||
|
return __get_global_locale();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* In POSIX terms the current locale is the locale used by all functions
|
/* In POSIX terms the current locale is the locale used by all functions
|
||||||
@ -227,7 +231,11 @@ __get_locale_r (struct _reent *r)
|
|||||||
_ELIDABLE_INLINE struct __locale_t *
|
_ELIDABLE_INLINE struct __locale_t *
|
||||||
__get_current_locale (void)
|
__get_current_locale (void)
|
||||||
{
|
{
|
||||||
|
#ifdef __HAVE_LOCALE_INFO__
|
||||||
return _REENT->_locale ?: __get_global_locale ();
|
return _REENT->_locale ?: __get_global_locale ();
|
||||||
|
#else
|
||||||
|
return __get_global_locale();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only access fixed "C" locale using this function. Fake for !_MB_CAPABLE
|
/* Only access fixed "C" locale using this function. Fake for !_MB_CAPABLE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user