https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2fb5e3dfb2603988640c87d69596f470900e1ff5
commit 2fb5e3dfb2603988640c87d69596f470900e1ff5 Author: Corinna Vinschen <cori...@vinschen.de> Date: Tue Aug 23 12:38:28 2016 +0200 Reference __global_locale only via __get_global_locale. Signed-off-by: Corinna Vinschen <cori...@vinschen.de> Diff: --- newlib/libc/locale/setlocale.h | 6 +++--- winsup/cygwin/nlsfuncs.cc | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/newlib/libc/locale/setlocale.h b/newlib/libc/locale/setlocale.h index 99bd466..5bf9edc 100644 --- a/newlib/libc/locale/setlocale.h +++ b/newlib/libc/locale/setlocale.h @@ -195,8 +195,6 @@ struct __locale_t }; extern const struct __locale_t __C_locale; -extern struct __locale_t __global_locale; - extern char *__loadlocale (struct __locale_t *, int, const char *); extern const char *__get_locale_env(struct _reent *, int); @@ -210,6 +208,7 @@ extern size_t _wcsnrtombs_l (struct _reent *, char *, const wchar_t **, _ELIDABLE_INLINE struct __locale_t * __get_global_locale () { + extern struct __locale_t __global_locale; return &__global_locale; } @@ -227,7 +226,8 @@ __get_locale_r (struct _reent *r) _ELIDABLE_INLINE struct __locale_t * __get_current_locale () { - return _REENT->_locale ?: &__global_locale; + return _REENT->_locale ?: __get_global_locale (); +} } #ifdef __CYGWIN__ diff --git a/winsup/cygwin/nlsfuncs.cc b/winsup/cygwin/nlsfuncs.cc index 3e3b5f4..60ad2d3 100644 --- a/winsup/cygwin/nlsfuncs.cc +++ b/winsup/cygwin/nlsfuncs.cc @@ -1524,11 +1524,11 @@ internal_setlocale () wchar_t *w_path = NULL, *w_cwd; /* Don't do anything if the charset hasn't actually changed. */ - if (cygheap->locale.mbtowc == __global_locale.mbtowc) + if (cygheap->locale.mbtowc == __get_global_locale ()->mbtowc) return; debug_printf ("Global charset set to %s", - __locale_charset (&__global_locale)); + __locale_charset (__get_global_locale ())); /* Fetch PATH and CWD and convert to wchar_t in previous charset. */ path = getenv ("PATH"); if (path && *path) /* $PATH can be potentially unset. */ @@ -1541,7 +1541,7 @@ internal_setlocale () sys_cp_mbstowcs (cygheap->locale.mbtowc, w_cwd, 32768, cygheap->cwd.get_posix ()); /* Set charset for internal conversion functions. */ - cygheap->locale.mbtowc = __global_locale.mbtowc; + cygheap->locale.mbtowc = __get_global_locale ()->mbtowc; if (cygheap->locale.mbtowc == __ascii_mbtowc) cygheap->locale.mbtowc = __utf8_mbtowc; /* Restore CWD and PATH in new charset. */