* 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.
This commit is contained in:
@ -99,25 +99,6 @@ fhandler_console::get_tty_stuff (int flags = 0)
|
||||
dev_state->meta_mask |= RIGHT_ALT_PRESSED;
|
||||
dev_state->set_default_attr ();
|
||||
shared_console_info->tty_min_state.sethwnd ((HWND) INVALID_HANDLE_VALUE);
|
||||
|
||||
/* Set the console charset and the mb<->wc conversion functions from
|
||||
the current locale the first time the shared console info is created.
|
||||
When this initialization is called, the current locale is the one
|
||||
used when reading the environment. This way we get a console setting
|
||||
which matches the setting of LC_ALL/LC_CTYPE/LANG at the time the
|
||||
first Cygwin process in this console starts.
|
||||
|
||||
This has an interesting effect. If none of the above environment
|
||||
variables is set, the setting is equivalent to before when
|
||||
CYGWIN=codepage was not set: The console charset will be the
|
||||
default ANSI codepage. So it's sort of backward compatible.
|
||||
|
||||
TODO: Find out if that's a feasible approach. It might be better
|
||||
in the long run to have a distinct console charset environment
|
||||
variable. */
|
||||
dev_state->con_mbtowc = __mbtowc;
|
||||
dev_state->con_wctomb = __wctomb;
|
||||
strcpy (dev_state->con_charset, __locale_charset ());
|
||||
}
|
||||
|
||||
return &shared_console_info->tty_min_state;
|
||||
@ -146,7 +127,9 @@ tty_list::get_tty (int n)
|
||||
inline DWORD
|
||||
dev_console::con_to_str (char *d, int dlen, WCHAR w)
|
||||
{
|
||||
return sys_cp_wcstombs (con_wctomb, con_charset, d, dlen, &w, 1);
|
||||
return sys_cp_wcstombs (*cygheap->locale.charset == 'A'
|
||||
? __ascii_wctomb : cygheap->locale.wctomb,
|
||||
cygheap->locale.charset, d, dlen, &w, 1);
|
||||
}
|
||||
|
||||
inline UINT
|
||||
@ -1467,8 +1450,8 @@ fhandler_console::write_normal (const unsigned char *src,
|
||||
f_mbtowc = __set_charset_from_codepage (cp, charset = charsetbuf);
|
||||
else
|
||||
{
|
||||
f_mbtowc = dev_state->con_mbtowc;
|
||||
charset = dev_state->con_charset;
|
||||
charset = cygheap->locale.charset;
|
||||
f_mbtowc = (*charset == 'A') ? __ascii_mbtowc : cygheap->locale.mbtowc;
|
||||
}
|
||||
|
||||
/* First check if we have cached lead bytes of a former try to write
|
||||
|
Reference in New Issue
Block a user