diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2008-02-05 17:37:10 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2008-02-05 17:37:10 +0000 |
commit | a7197550f31c8db32c671bc43401c1b90c78ed74 (patch) | |
tree | 4250d45f44ad6d7a7fa5d1e4da95842d04097530 /winsup/cygwin/environ.cc | |
parent | 58d470721bb00194763cc7cb32abac80ddc9253a (diff) | |
download | cygnal-a7197550f31c8db32c671bc43401c1b90c78ed74.tar.gz cygnal-a7197550f31c8db32c671bc43401c1b90c78ed74.tar.bz2 cygnal-a7197550f31c8db32c671bc43401c1b90c78ed74.zip |
* autoload.cc (CharToOemA): Remove.
(CharNextExA): Define.
* environ.cc (codepage_init): Un-static. Set active_codepage to
active codepage. Default to ansi regardless of buf pointer.
* fhandler.h (dev_console::get_console_cp): New method.
(dev_console::con_to_str): Change declaration according to new
implementation.
(dev_console::str_to_con): Ditto.
* fhandler_console.cc (cp_convert): Remove.
(dev_console::con_to_str): Redefine to take WCHAR as incoming console
char.
(dev_console::get_console_cp): Return correct codepage according to
alternate_charset_active setting.
(dev_console::str_to_con): Redefine to create WCHAR buffer for console
output.
(fhandler_console::read): Read console input as WCHARs.
(base_chars): Fix typo in comment.
(fhandler_console::char_command): Save and restore console output
buffer using UNICODE functions.
(fhandler_console::write_normal): Convert to write output in UNICODE.
Use CharNextExA to recognize multibyte characters in input. Workaround
problem with UTF-8 and MultiByteToWideChar. Simplify the loop for
printing "normal" characters.
* strfuncs.cc (active_codepage): New variable to store active codepage.
(get_cp): Call codepage_init() if active_codepage is uninitialized.
Just return active_codepage.
(is_cp_multibyte): New function.
* winsup.h (active_codepage): Declare.
(codepage_init): Declare.
(is_cp_multibyte): Declare.
Diffstat (limited to 'winsup/cygwin/environ.cc')
-rw-r--r-- | winsup/cygwin/environ.cc | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index de6de9b9e..3e0765bcf 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -16,6 +16,7 @@ details. */ #include <assert.h> #include <sys/cygwin.h> #include <cygwin/version.h> +#include <winnls.h> #include "pinfo.h" #include "perprocess.h" #include "security.h" @@ -513,20 +514,30 @@ set_file_api_mode (codepage_type cp) } } -static void +void codepage_init (const char *buf) { - if (!buf || !*buf) - return; + if (!buf) + buf = "ansi"; if (ascii_strcasematch (buf, "oem")) - current_codepage = oem_cp; - else if (ascii_strcasematch (buf, "ansi")) - current_codepage = ansi_cp; + { + current_codepage = oem_cp; + active_codepage = GetOEMCP (); + } else if (ascii_strcasematch (buf, "utf8")) - current_codepage = utf8_cp; + { + current_codepage = utf8_cp; + active_codepage = CP_UTF8; + } else - debug_printf ("Wrong codepage name: %s", buf); + { + if (!ascii_strcasematch (buf, "ansi")) + debug_printf ("Wrong codepage name: %s", buf); + /* Fallback to ANSI */ + current_codepage = ansi_cp; + active_codepage = GetACP (); + } set_file_api_mode (current_codepage); } |