diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2009-05-14 19:49:37 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2009-05-14 19:49:37 +0000 |
commit | 6f401eccfb260b64a35a55e54e0e403324921690 (patch) | |
tree | 2438b25becaba143df2ce7bb2ad0708aa41e1c94 /winsup/cygwin/syscalls.cc | |
parent | ef5da523a94f878fbe95aac85eeb82d9a129ab6b (diff) | |
download | cygnal-6f401eccfb260b64a35a55e54e0e403324921690.tar.gz cygnal-6f401eccfb260b64a35a55e54e0e403324921690.tar.bz2 cygnal-6f401eccfb260b64a35a55e54e0e403324921690.zip |
* cygheap.cc (cygheap_init): Set Cygwin default locale values.
* cygheap.h (struct cygheap_locale): New structure.
(struct user_heap_info): Add cygheap_locale member locale.
* dcrt0.cc (dll_crt0_1): Revert to calling _setlocale_r so that only
the applications locale is reverted to "C".
* environ.cc (environ_init): Remove unused got_lc variable.
* fhandler.h (class dev_console): Remove now unsed locale variables.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Remove
setting dev_console's locale members.
(dev_console::con_to_str): Use internal locale settings. Default to
__ascii_wctomb if charset is "ASCII".
(fhandler_console::write_normal): Ditto.
* strfuncs.cc (__ascii_wctomb): Drop declaration.
(__db_wctomb): Use fixed value 2 instead of not
necessarily matching MB_CUR_MAX.
(__eucjp_wctomb): Use 3 instead of MB_CUR_MAX.
(sys_cp_wcstombs): Remove special case for "C" locale.
(sys_wcstombs): Implement here. Use internal locale data stored on
cygheap.
(sys_cp_mbstowcs): Remove special case for "C" locale.
(sys_mbstowcs): Implement here. Use internal locale data stored on
cygheap.
* syscalls.cc (internal_setlocale): New function to set cygheap locale
data and to reset CWD posix path.
(setlocale): Just call internal_setlocale from here if necessary.
* wchar.h (__ascii_wctomb): Declare.
(sys_wcstombs): Don't define inline, just declare.
(sys_mbstowcs): Ditto.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r-- | winsup/cygwin/syscalls.cc | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index ab319225c..fa0c607a6 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -4006,15 +4006,32 @@ unlinkat (int dirfd, const char *pathname, int flags) return (flags & AT_REMOVEDIR) ? rmdir (path) : unlink (path); } -extern "C" char * -setlocale (int category, const char *locale) +static void +internal_setlocale () { + if (*cygheap->locale.charset == 'A') + { + cygheap->locale.mbtowc = __utf8_mbtowc; + cygheap->locale.wctomb = __utf8_wctomb; + } + else + { + cygheap->locale.mbtowc = __mbtowc; + cygheap->locale.wctomb = __wctomb; + } + strcpy (cygheap->locale.charset, __locale_charset ()); /* Each setlocale potentially changes the multibyte representation of the CWD. Therefore we have to rest the CWD's posix path and reevaluate the next time it's used. */ /* FIXME: Other buffered paths might be affected as well. */ + cygheap->cwd.reset_posix (); +} + +extern "C" char * +setlocale (int category, const char *locale) +{ char *ret = _setlocale_r (_REENT, category, locale); - if (ret) - cygheap->cwd.reset_posix (); + if (ret && locale && (category == LC_ALL || category == LC_CTYPE)) + internal_setlocale (); return ret; } |