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/strfuncs.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/strfuncs.cc')
-rw-r--r-- | winsup/cygwin/strfuncs.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/winsup/cygwin/strfuncs.cc b/winsup/cygwin/strfuncs.cc index 150f51ff4..965bdeefd 100644 --- a/winsup/cygwin/strfuncs.cc +++ b/winsup/cygwin/strfuncs.cc @@ -50,7 +50,7 @@ __db_wctomb (struct _reent *r, char *s, wchar_t wchar, UINT cp) BOOL def_used = false; int ret = WideCharToMultiByte (cp, WC_NO_BEST_FIT_CHARS, &wchar, 1, s, - MB_CUR_MAX, NULL, &def_used); + 2, NULL, &def_used); if (ret > 0 && !def_used) return ret; @@ -65,8 +65,6 @@ __sjis_wctomb (struct _reent *r, char *s, wchar_t wchar, const char *charset, return __db_wctomb (r,s, wchar, 932); } -extern "C" int __ascii_wctomb (struct _reent *, char *, wchar_t, const char *, - mbstate_t *); extern "C" int __jis_wctomb (struct _reent *r, char *s, wchar_t wchar, const char *charset, mbstate_t *state) @@ -101,7 +99,7 @@ __eucjp_wctomb (struct _reent *r, char *s, wchar_t wchar, const char *charset, BOOL def_used = false; int ret = WideCharToMultiByte (20932, WC_NO_BEST_FIT_CHARS, &wchar, 1, s, - MB_CUR_MAX, NULL, &def_used); + 3, NULL, &def_used); if (ret > 0 && !def_used) { /* CP20932 representation of JIS-X-0212 character? */ @@ -418,8 +416,6 @@ sys_cp_wcstombs (wctomb_p f_wctomb, char *charset, char *dst, size_t len, mbstate_t ps; save_errno save; - if (f_wctomb == __ascii_wctomb) - f_wctomb = __utf8_wctomb; memset (&ps, 0, sizeof ps); if (dst == NULL) len = (size_t) -1; @@ -479,6 +475,13 @@ sys_cp_wcstombs (wctomb_p f_wctomb, char *charset, char *dst, size_t len, return n; } +size_t __stdcall +sys_wcstombs (char *dst, size_t len, const wchar_t * src, size_t nwc) +{ + return sys_cp_wcstombs (cygheap->locale.wctomb, cygheap->locale.charset, + dst, len, src, nwc); +} + /* Allocate a buffer big enough for the string, always including the terminating '\0'. The buffer pointer is returned in *dst_p, the return value is the number of bytes written to the buffer, as usual. @@ -527,8 +530,6 @@ sys_cp_mbstowcs (mbtowc_p f_mbtowc, char *charset, wchar_t *dst, size_t dlen, mbstate_t ps; save_errno save; - if (f_mbtowc == __ascii_mbtowc) - f_mbtowc = __utf8_mbtowc; memset (&ps, 0, sizeof ps); if (dst == NULL) len = (size_t)-1; @@ -597,6 +598,13 @@ sys_cp_mbstowcs (mbtowc_p f_mbtowc, char *charset, wchar_t *dst, size_t dlen, return count; } +size_t __stdcall +sys_mbstowcs (wchar_t * dst, size_t dlen, const char *src, size_t nms) +{ + return sys_cp_mbstowcs (cygheap->locale.mbtowc, cygheap->locale.charset, + dst, dlen, src, nms); +} + /* Same as sys_wcstombs_alloc, just backwards. */ size_t __stdcall sys_mbstowcs_alloc (wchar_t **dst_p, int type, const char *src, size_t nms) |