diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2016-07-13 17:51:33 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2016-08-15 11:56:56 +0300 |
commit | a6a477fa8190b13d4ef0150875e2bd114cb5b132 (patch) | |
tree | 0a4902cd997922c684b4ad4488f31eb2bde66f22 /winsup/cygwin/ctype.cc | |
parent | 51b669f679119556a12798096794845cd1049d95 (diff) |
POSIX-1.2008 per-thread locales, groundwork part 1
Introduce first cut of struct _thr_locale_t used for the locale_t definition.
Introduce global instance called __global_locale used by default.
Introduce internal inline functions __get_global_locale, __get_locale_r,
__get_current_locale.
Remove usage of global variables in favor of accessor functions pointing to
__global_locale for now. Include all local headers in locale subdir from
setlocale.h to get single include for internal locale access.
Introduce __CTYPE_PTR macro to replace direct access to __ctype_ptr__
and use throughout in isxxx functions.
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/ctype.cc')
-rw-r--r-- | winsup/cygwin/ctype.cc | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/winsup/cygwin/ctype.cc b/winsup/cygwin/ctype.cc index fa8aad3eb..94de81e6c 100644 --- a/winsup/cygwin/ctype.cc +++ b/winsup/cygwin/ctype.cc @@ -1,6 +1,7 @@ #include "winsup.h" extern "C" { #include <ctype.h> +#include "../locale/setlocale.h" #include <stdlib.h> #include <wctype.h> @@ -18,9 +19,10 @@ extern const char __ctype_cp[22][128 + 256]; /* Newlib */ extern const char __ctype_iso[15][128 + 256]; /* Newlib */ void -__set_ctype (const char *charset) +__set_ctype (struct _reent *reent, const char *charset) { int idx; + char *ctype_ptr = NULL; switch (*charset) { @@ -36,8 +38,8 @@ __set_ctype (const char *charset) memcpy (_ctype_b, __ctype_iso[idx], 128); memcpy (_ctype_b + 256, __ctype_iso[idx] + 256, 128); } - __ctype_ptr__ = (char *) (__ctype_iso[idx] + 127); - return; + ctype_ptr = (char *) __ctype_iso[idx]; + break; case 'C': idx = __cp_index (charset + 2); if (idx < 0) @@ -47,17 +49,24 @@ __set_ctype (const char *charset) memcpy (_ctype_b, __ctype_cp[idx], 128); memcpy (_ctype_b + 256, __ctype_cp[idx] + 256, 128); } - __ctype_ptr__ = (char *) (__ctype_cp[idx] + 127); - return; + ctype_ptr = (char *) __ctype_cp[idx]; + break; default: break; } - if (CYGWIN_VERSION_CHECK_FOR_OLD_CTYPE) + if (!ctype_ptr) { - memset (_ctype_b, 0, 128); - memset (_ctype_b + 256, 0, 128); + if (CYGWIN_VERSION_CHECK_FOR_OLD_CTYPE) + { + memset (_ctype_b, 0, 128); + memset (_ctype_b + 256, 0, 128); + } + ctype_ptr = (char *) _ctype_b; } - __ctype_ptr__ = (char *) _ctype_b + 127; + if (reent) + __get_locale_r (reent)->ctype_ptr = ctype_ptr + 127; + else + __ctype_ptr__ = ctype_ptr + 127; } } /* extern "C" */ |