diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2009-03-24 15:18:34 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2009-03-24 15:18:34 +0300 |
commit | 161211d186a16e4f090b8b3c63040f0b9aee25d4 (patch) | |
tree | 4ac0e1154417f3b0119ba79407a8c5687d96bf83 /winsup/cygwin/ctype.cc | |
parent | 6a32d500a9d601b4f25cee0e1ec6b2ac5195a7e9 (diff) |
* ctype.cc (_CTYPE_DATA_0_127): Add _B class to TAB character.
(__ctype_default): New character class array for default ASCII
character set.
(__ctype_iso): New array of character class array for ISO charsets.
(__ctype_cp): Ditto for singlebyte Windows codepages.
(tolower): Implement as distinct function to support any singlebyte
charset.
(toupper): Ditto.
(__set_ctype): New function to copy singlebyte character classes
corresponding to current charset to ctype_b array.
Align copyright text to upstream.
* dcrt0.cc (dll_crt0_1): Reset current locale to "C" per POSIX.
* environ.cc (set_file_api_mode): Remove.
(codepage_init): Remove.
(parse_thing): Remove "codepage" setting.
(environ_init): Set locale according to environment settings, or
to current codepage, before converting environment to multibyte.
* fhandler.h (fhandler_console::write_replacement_char): Drop argument.
* fhandler_console.cc (dev_console::str_to_con): Call sys_cp_mbstowcs
rather than MultiByteToWideChar.
(fhandler_console::write_replacement_char): Always print a funny
half filled square if a character isn't in the current charset.
(fhandler_console::write_normal): Convert to using __mbtowc
rather than next_char.
* fork.cc (frok::child): Drop call to set_file_api_mode.
* globals.cc (enum codepage_type) Remove.
(current_codepage): Remove.
* miscfuncs.cc (cygwin_wcslwr): Unused, dangerous. Remove.
(cygwin_wcsupr): Ditto.
(is_cp_multibyte): Remove.
(next_char): Remove.
* miscfuncs.h (is_cp_multibyte): Drop declaration.
(next_char): Ditto.
* strfuncs.cc (get_cp): Remove.
(__db_wctomb): New function to implement _wctomb_r functionality for
doublebyte charsets using WideCharToMultiByte.
(__sjis_wctomb): New function to replace unusable newlib function.
(__jis_wctomb): Ditto.
(__eucjp_wctomb): Ditto.
(__gbk_wctomb): New function.
(__kr_wctomb): Ditto.
(__big5_wctomb): Ditto.
(__db_mbtowc): New function to implement _mbtowc_r functionality for
doublebyte charsets using MultiByteToWideChar.
(__sjis_mbtowc): New function to replace unusable newlib function.
(__jis_mbtowc): Ditto.
(__eucjp_mbtowc): Ditto.
(__gbk_mbtowc): New function.
(__kr_mbtowc): New function
(__big5_mbtowc): New function
(__set_charset_from_codepage): New function.
(sys_wcstombs): Reimplement, basically using same wide char to multibyte
conversion as newlib's application level functions. Plus extras.
Add lengthy comment to explain. Change return type to size_t.
(sys_wcstombs_alloc): Just use sys_wcstombs. Change return type to
size_t.
(sys_cp_mbstowcs): Replace sys_mbstowcs, take additional codepage
argument. Explain why. Change return type to size_t.
(sys_mbstowcs_alloc): Just use sys_mbstowcs. Change return type to
size_t.
* wchar.h: Declare internal functions implemented in strfuncs.cc.
(wcscasecmp): Remove.
(wcsncasecmp): Remove.
(wcslwr): Remove.
(wcsupr): Remove.
* winsup.h (codepage_init): Remove declaration.
(get_cp): Ditto.
(sys_wcstombs): Align declaration to new implementation.
(sys_wcstombs_alloc): Ditto.
(sys_cp_mbstowcs): Add declaration.
(sys_mbstowcs): Define as inline function.
(sys_mbstowcs_alloc): Align declaration to new implementation.
(set_file_api_mode): Remove declaration.
* include/ctype.h (isblank): Redefine to use _B character class.
(toupper): Remove ASCII-only definition.
(tolower): Ditto.
Diffstat (limited to 'winsup/cygwin/ctype.cc')
-rw-r--r-- | winsup/cygwin/ctype.cc | 724 |
1 files changed, 713 insertions, 11 deletions
diff --git a/winsup/cygwin/ctype.cc b/winsup/cygwin/ctype.cc index b656d3e08..5d70b6118 100644 --- a/winsup/cygwin/ctype.cc +++ b/winsup/cygwin/ctype.cc @@ -1,10 +1,12 @@ #include "winsup.h" extern "C" { #include <ctype.h> +#include <stdlib.h> +#include <wctype.h> #define _CTYPE_DATA_0_127 \ _C, _C, _C, _C, _C, _C, _C, _C, \ - _C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C, \ + _C, _B|_C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C, \ _C, _C, _C, _C, _C, _C, _C, _C, \ _C, _C, _C, _C, _C, _C, _C, _C, \ _S|_B, _P, _P, _P, _P, _P, _P, _P, \ @@ -36,7 +38,645 @@ extern "C" { 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0 + +/* FIXME: These tables should rather be defined in newlib and we should + switch to the newer __ctype_ptr method from newlib for new applications. */ + +static char __ctype_default[128] = { _CTYPE_DATA_128_256 }; +static char __ctype_iso[15][128] = { + /* ISO-8859-1 */ + { _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _P, + _U, _U, _U, _U, _U, _U, _U, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _P, + _L, _L, _L, _L, _L, _L, _L, _L }, + /* ISO-8859-2 */ + { _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, _U, _P, _U, _P, _U, _U, _P, + _P, _U, _U, _U, _U, _P, _U, _U, + _P, _L, _P, _L, _P, _L, _L, _P, + _P, _L, _L, _L, _L, _P, _L, _L, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _P, + _U, _U, _U, _U, _U, _U, _U, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _P, + _L, _L, _L, _L, _L, _L, _L, _L }, + /* ISO-8859-3 */ + { _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, _U, _P, _P, _P, 0, _U, _P, + _P, _U, _U, _U, _U, _P, 0, _U, + _P, _L, _P, _P, _P, _L, _L, _P, + _P, _L, _L, _L, _L, _P, 0, _L, + _U, _U, _U, 0, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + 0, _U, _U, _U, _U, _U, _U, _P, + _U, _U, _U, _U, _U, _U, _U, _L, + _L, _L, _L, 0, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + 0, _L, _L, _L, _L, _L, _L, _P, + _L, _L, _L, _L, _L, _L, _L, _P }, + /* ISO-8859-4 */ + { _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, _U, _L, _U, _P, _U, _U, _P, + _P, _U, _U, _U, _U, _P, _U, _P, + _P, _L, _P, _L, _P, _L, _L, _P, + _P, _L, _L, _L, _L, _P, _L, _L, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _P, + _U, _U, _U, _U, _U, _U, _U, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _P, + _L, _L, _L, _L, _L, _L, _L, _L }, + /* ISO-8859-5 */ + { _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _P, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _P, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _P, _L, _L }, + /* ISO-8859-6 */ + { _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, 0, 0, 0, _P, 0, 0, 0, + 0, 0, 0, 0, _P, _P, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, _P, 0, 0, 0, _P, + 0, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + 0, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, 0, 0, 0, 0, 0, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _P, _P, _P, _P, _P, + _P, _P, _P, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 }, + /* ISO-8859-7 */ + { _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _U, _P, + _U, _U, _U, _P, _U, _P, _U, _U, + _L, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _P }, + /* ISO-8859-8 */ + { _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, 0, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, 0, 0, _P, _P, 0 }, + /* ISO-8859-9 */ + { _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _P, + _U, _U, _U, _U, _U, _U, _U, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _P, + _L, _L, _L, _L, _L, _L, _L, _L }, + /* ISO-8859-10 */ + { _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, _U, _U, _U, _U, _U, _U, _P, + _U, _U, _U, _U, _U, _P, _U, _U, + _P, _L, _L, _L, _L, _L, _L, _P, + _L, _L, _L, _L, _L, _P, _L, _L, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L }, + /* ISO-8859-11 */ + { _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _P, _L, _L, _P, _P, _P, _P, + _P, _P, _P, 0, 0, 0, 0, _P, + _L, _L, _L, _L, _L, _L, _L, _P, + _P, _P, _P, _P, _P, _P, _P, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, 0, 0, 0, 0 }, + /* ISO-8859-13 */ + { _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _U, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _L, _P, _P, _P, _P, _P, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _P, + _U, _U, _U, _U, _U, _U, _U, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _P, + _L, _L, _L, _L, _L, _L, _L, _P }, + /* ISO-8859-14 */ + { _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, _U, _L, _P, _U, _L, _U, _P, + _U, _P, _U, _L, _U, _P, _P, _U, + _U, _L, _U, _L, _U, _L, _P, _U, + _L, _L, _L, _U, _L, _U, _L, _L, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L }, + /* ISO-8859-15 */ + { _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _P, + _U, _U, _U, _U, _U, _U, _U, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _P, + _L, _L, _L, _L, _L, _L, _L, _L }, + /* ISO-8859-16 */ + { _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, _U, _L, _U, _P, _P, _U, _P, + _L, _P, _U, _P, _U, _P, _L, _U, + _P, _P, _U, _U, _U, _P, _P, _P, + _L, _L, _L, _P, _U, _L, _U, _L, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L } +}; +static char __ctype_cp[22][128] = { + /* CP437 */ + { _U, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _U, _U, + _U, _L, _U, _L, _L, _L, _L, _L, + _L, _U, _U, _P, _P, _P, _P, _P, + _L, _L, _L, _L, _L, _L, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _L, _L, _U, _L, _U, _L, _P, _L, + _U, _U, _U, _L, _P, _L, _L, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _S|_B }, + /* CP720 */ + { 0, 0, _L, _L, 0, _L, 0, _L, + _L, _L, _L, _L, _L, 0, 0, 0, + 0, _P, _P, _L, _P, _P, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + 0, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _S|_B }, + /* CP737 */ + { _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _U, _U, _U, _U, _U, _U, + _U, _P, _P, _P, _P, _U, _U, _P, + _P, _P, _P, _P, _P, _P, _P, _S|_B }, + /* CP775 */ + { _U, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _U, _L, _L, _U, _U, _U, + _U, _L, _U, _L, _L, _U, _P, _U, + _L, _U, _U, _P, _P, _P, _P, _P, + _U, _U, _L, _U, _L, _L, _P, _P, + _P, _P, _P, _P, _P, _U, _P, _P, + _P, _P, _P, _P, _P, _U, _U, _U, + _U, _P, _P, _P, _P, _U, _U, _P, + _P, _P, _P, _P, _P, _P, _U, _U, + _P, _P, _P, _P, _P, _P, _P, _U, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _P, _P, _P, _P, _P, _P, _P, + _U, _L, _U, _U, _L, _U, _L, _L, + _U, _L, _U, _L, _L, _U, _U, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _S|_B }, + /* CP850 */ + { _U, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _U, _U, + _U, _L, _U, _L, _L, _L, _L, _L, + _L, _U, _U, _L, _P, _U, _P, _P, + _L, _L, _L, _L, _L, _U, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _U, _U, _U, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _L, _U, + _P, _P, _P, _P, _P, _P, _P, _P, + _L, _U, _U, _U, _U, _L, _U, _U, + _U, _P, _P, _P, _P, _P, _U, _P, + _U, _L, _U, _U, _L, _U, _L, _U, + _L, _U, _U, _U, _L, _U, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _S|_B }, + /* CP852 */ + { _U, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _U, _L, _L, _U, _U, _U, + _U, _U, _L, _L, _L, _U, _L, _U, + _L, _U, _U, _U, _L, _U, _P, _L, + _L, _L, _L, _L, _U, _L, _U, _L, + _U, _L, _P, _L, _U, _L, _P, _P, + _P, _P, _P, _P, _P, _U, _U, _U, + _U, _P, _P, _P, _P, _U, _L, _P, + _P, _P, _P, _P, _P, _P, _U, _L, + _P, _P, _P, _P, _P, _P, _P, _P, + _L, _U, _U, _U, _L, _U, _U, _U, + _L, _P, _P, _P, _P, _U, _U, _P, + _U, _L, _U, _U, _L, _L, _U, _L, + _U, _U, _L, _U, _L, _U, _L, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _L, _U, _L, _P, _S|_B }, + /* CP855 */ + { _L, _U, _L, _U, _L, _U, _L, _U, + _L, _U, _L, _U, _L, _U, _L, _U, + _L, _U, _L, _U, _L, _U, _L, _U, + _L, _U, _L, _U, _L, _U, _L, _U, + _L, _U, _L, _U, _L, _U, _L, _U, + _L, _U, _L, _U, _L, _U, _P, _P, + _P, _P, _P, _P, _P, _L, _U, _L, + _U, _P, _P, _P, _P, _L, _U, _P, + _P, _P, _P, _P, _P, _P, _L, _U, + _P, _P, _P, _P, _P, _P, _P, _P, + _L, _U, _L, _U, _L, _U, _L, _U, + _L, _P, _P, _P, _P, _U, _L, _P, + _U, _L, _U, _L, _U, _L, _U, _L, + _U, _L, _U, _L, _U, _L, _U, _P, + _P, _L, _U, _L, _U, _L, _U, _L, + _U, _L, _U, _L, _U, _P, _P, _S|_B }, + /* CP857 */ + { _U, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _U, _U, + _U, _L, _U, _L, _L, _L, _L, _L, + _U, _U, _U, _L, _P, _U, _U, _L, + _L, _L, _L, _L, _L, _U, _U, _L, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _U, _U, _U, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _L, _U, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _U, _U, _U, _L, _U, _U, + _U, _P, _P, _P, _P, _P, _U, _P, + _U, _L, _U, _U, _L, _U, _L, _L, + _P, _U, _U, _U, _L, _L, _P, _P, + _P, _P, _L, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _S|_B }, + /* CP858 */ + { _U, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _U, _U, + _U, _L, _U, _L, _L, _L, _L, _L, + _L, _U, _U, _L, _P, _U, _P, _P, + _L, _L, _L, _L, _L, _U, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _U, _U, _U, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _L, _U, + _P, _P, _P, _P, _P, _P, _P, _P, + _L, _U, _U, _U, _U, _P, _U, _U, + _U, _P, _P, _P, _P, _P, _U, _P, + _U, _L, _U, _U, _L, _U, _L, _U, + _L, _U, _U, _U, _L, _U, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _S|_B }, + /* CP862 */ + { _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _P, _P, _P, _P, _P, + _L, _L, _L, _L, _L, _U, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _L, _L, _U, _L, _U, _L, _P, _L, + _U, _U, _U, _L, _P, _L, _L, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _S|_B }, + /* CP866 */ + { _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _U, _L, _U, _L, _U, _L, _U, _L, + _P, _P, _P, _P, _P, _P, _P, _S|_B }, + /* CP874 */ + { _P, 0, 0, 0, 0, _P, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, _P, _P, _P, _P, _P, _P, _P, + 0, 0, 0, 0, 0, 0, 0, 0, + _S|_B, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, 0, 0, 0, 0, _P, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _L, _L, 0, 0, 0, 0 }, + /* CP1125 */ + { _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _U, _L, _U, _L, _U, _L, _U, _L, + _U, _L, _P, _P, _P, _P, _P, _S|_B }, + /* CP1250 */ + { _P, 0, _P, 0, _P, _P, _P, _P, + 0, _P, _U, _P, _U, _U, _U, _U, + 0, _P, _P, _P, _P, _P, _P, _P, + 0, _P, _L, _P, _L, _L, _L, _L, + _S|_B, _P, _P, _U, _P, _U, _P, _P, + _P, _P, _U, _P, _P, _P, _P, _U, + _P, _P, _P, _L, _P, _P, _P, _P, + _P, _L, _L, _P, _U, _P, _L, _L, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _P, + _U, _U, _U, _U, _U, _U, _U, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _P, + _L, _L, _L, _L, _L, _L, _L, _P }, + /* CP1251 */ + { _U, _U, _P, _L, _P, _P, _P, _P, + _P, _P, _U, _P, _U, _U, _U, _U, + _L, _P, _P, _P, _P, _P, _P, _P, + _L, _P, _L, _L, _L, _L, _P, _U, + _S|_B, _U, _L, _U, _P, _U, _P, _P, + _U, _P, _U, _P, _P, _P, _P, _U, + _P, _P, _U, _L, _L, _P, _P, _P, + _L, _P, _L, _P, _L, _U, _L, _L, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L }, + /* CP1252 */ + { _P, 0, _P, _L, _P, _P, _P, _P, + _P, _P, _U, _P, _U, _U, 0, 0, + 0, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _L, _P, _L, 0, _L, _U, + _S|_B, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _P, + _U, _U, _U, _U, _U, _U, _U, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _P, + _L, _L, _L, _L, _L, _L, _L, _L }, + /* CP1253 */ + { _P, 0, _P, _L, _P, _P, _P, _P, + 0, _P, 0, _P, 0, 0, 0, 0, + 0, _P, _P, _P, _P, _P, _P, _P, + 0, _P, _P, 0, 0, 0, 0, 0, + _S|_B, _P, _U, _P, _P, _P, _P, _P, + _P, _P, 0, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _U, _U, _U, _P, _U, _P, _U, _U, + _L, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L }, + /* CP1254 */ + { _P, 0, _P, _L, _P, _P, _P, _P, + _P, _P, _U, _P, _U, 0, 0, 0, + 0, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _L, _P, _L, 0, 0, _U, + _S|_B, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _P, + _U, _U, _U, _U, _U, _U, _U, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _P, + _L, _L, _L, _L, _L, _L, _L, _L }, + /* CP1255 */ + { _P, 0, _P, _L, _P, _P, _P, _P, + _P, _P, 0, _P, 0, 0, 0, 0, + 0, _P, _P, _P, _P, _P, _P, _P, + _P, _P, 0, _P, 0, 0, 0, 0, + _S|_B, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, 0, 0, 0, 0, 0, 0, 0, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, 0, 0, _P, _P, 0 }, + /* CP1256 */ + { _P, _L, _P, _L, _P, _P, _P, _P, + _P, _P, _L, _P, _U, _L, _L, _L, + _L, _P, _P, _P, _P, _P, _P, _P, + _L, _P, _L, _P, _L, _P, _P, _L, + _S|_B, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _L, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _P, + _L, _L, _L, _L, _P, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _P, _P, _P, _P, _L, _P, _P, _P, + _P, _L, _P, _L, _L, _P, _P, _L }, + /* CP1257 */ + { _P, 0, _P, 0, _P, _P, _P, _P, + 0, _P, 0, _P, 0, _P, _P, _P, + 0, _P, _P, _P, _P, _P, _P, _P, + 0, _P, 0, _P, 0, _P, _P, 0, + _S|_B, 0, _P, _P, _P, 0, _P, _P, + _U, _P, _U, _P, _P, _P, _P, _U, + _P, _P, _P, _P, _P, _P, _P, _P, + _L, _P, _L, _P, _P, _P, _P, _L, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _P, + _U, _U, _U, _U, _U, _U, _U, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _P, + _L, _L, _L, _L, _L, _L, _L, _P }, + /* CP1258 */ + { _P, 0, _P, _L, _P, _P, _P, _P, + _P, _P, 0, _P, _U, 0, 0, 0, + 0, _P, _P, _P, _P, _P, _P, _P, + _P, _P, 0, _P, _L, 0, 0, _U, + _S|_B, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _P, _U, _U, _U, + _U, _U, _P, _U, _U, _U, _U, _P, + _U, _U, _U, _U, _U, _U, _P, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _P, _L, _L, _L, + _L, _L, _P, _L, _L, _L, _L, _P, + _L, _L, _L, _L, _L, _L, _P, _L } +}; char ctype_b[128 + 256] = { _CTYPE_DATA_128_256, @@ -70,12 +710,81 @@ makefunc(ispunct) makefunc(isspace) makefunc(isupper) makefunc(isxdigit) -makefunc(tolower) -makefunc(toupper) makefunc(isblank) makefunc(isascii) makefunc(toascii) + +static int __cdecl +c_tolower (int c) +{ + if ((unsigned char) c <= 0x7f) + return isupper (c) ? c + 0x20 : c; + + char s[8] = { c, '\0' }; + wchar_t wc; + if (mbtowc (&wc, s, 1) >= 0 + && wctomb (s, (wchar_t) towlower ((wint_t) wc)) == 1) + c = s[0]; + return c; +} +EXPORT_ALIAS(c_tolower, tolower) + +static int __cdecl +c_toupper (int c) +{ + if ((unsigned char) c <= 0x7f) + return islower (c) ? c - 0x20 : c; + + char s[8] = { c, '\0' }; + wchar_t wc; + if (mbtowc (&wc, s, 1) >= 0 + && wctomb (s, (wchar_t) towupper ((wint_t) wc)) == 1) + c = s[0]; + return c; } +EXPORT_ALIAS(c_toupper, toupper) + +/* Called from newlib's setlocale(). What we do here is to copy the + 128 bytes of charset specific ctype data into the array at _ctype_b. + Given that the functionality is usually implemented locally in the + application, that's the only backward compatible way to do it. + Setlocale is usually only called once in an application, so this isn't + time-critical anyway. */ +int __iso_8859_index (const char *charset_ext); /* Newlib */ +int __cp_index (const char *charset_ext); /* Newlib */ + +void +__set_ctype (const char *charset) +{ + int idx; + + switch (*charset) + { + case 'I': + idx = __iso_8859_index (charset + 9); + /* Our ctype table has a leading ISO-8859-1 element. */ + if (idx < 0) + idx = 0; + else + ++idx; + memcpy (ctype_b, __ctype_iso[idx], 128); + memcpy (ctype_b + 256, __ctype_iso[idx], 128); + return; + case 'C': + idx = __cp_index (charset + 2); + if (idx < 0) + break; + memcpy (ctype_b, __ctype_cp[idx], 128); + memcpy (ctype_b + 256, __ctype_cp[idx], 128); + return; + default: + break; + } + memcpy (ctype_b, __ctype_default, 128); + memcpy (ctype_b + 256, __ctype_default, 128); +} + +} /* extern "C" */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -89,13 +798,6 @@ makefunc(toascii) * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |