Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2009-03-31 13:31:38 +0400
committerCorinna Vinschen <corinna@vinschen.de>2009-03-31 13:31:38 +0400
commit4bc42c05aa0921f57e401985458ef8e584fa8777 (patch)
tree68783798c495590d87169ccb42807fcd8da9d401 /newlib/libc/ctype
parent24bd1f86c27b5d25a12e42da286ba983cc4d7ef8 (diff)
* libc/ctype/Makefile.am: Remove _tolower.c and _toupper.c
source files. Add a dependency rule for ctype_o to note changes in ctype_iso.h and ctype_cp.h. * libc/ctype/Makefile.in: Regenerate. * libc/ctype/_tolower.c: Remove file. * libc/ctype/_toupper.c: Remove file. * libc/ctype/ctype_.c: Make sure ALLOW_NEGATIVE_CTYPE_INDEX is always defined on Cygwin. (_ctype_b): Don't make `static const' on Cygwin. (ctype_iso.h): Include if _MB_EXTENDED_CHARSETS_ISO is set. (ctype_cp.h): Include if _MB_EXTENDED_CHARSETS_WINDOWS is set. (__ctype_ptr): Drop definition. (__ctype_ptr__): De-constify. Mark as __EXPORT symbol. (_ctype_): Add Cygwin-specifc asm define. (__set_ctype): New function to set __ctype_ptr__ according to current charset. * libc/ctype/ctype_cp.h: New file containing Windows codepage specific character class tables. * libc/ctype/ctype_iso.h: New file containing ISO-8859-x specific character class tables. * libc/ctype/tolower.c (tolower): Reimplement to support any singlebyte charset if one of the extended charsets is enabled. * libc/ctype/toupper.c (toupper): Ditto. * libc/include/ctype.h (_tolower): Define as macro per POSIX. (_toupper): Ditto. (__ctype_ptr__): De-constify. (toupper): Disable macro on systems supporting extended charsets. (tolower): Ditto. * libc/include/sys/config.h (__EXPORT): Define empty if not defined. * libc/locale/locale.c (__mb_cur_max): Mark as __EXPORT symbol. (__set_ctype): Declare unconditionally. (loadlocale): Remove __CYGWIN__ guard around __set_ctype call.
Diffstat (limited to 'newlib/libc/ctype')
-rw-r--r--newlib/libc/ctype/Makefile.am4
-rw-r--r--newlib/libc/ctype/Makefile.in46
-rw-r--r--newlib/libc/ctype/_tolower.c9
-rw-r--r--newlib/libc/ctype/_toupper.c9
-rw-r--r--newlib/libc/ctype/ctype_.c92
-rw-r--r--newlib/libc/ctype/ctype_cp.h570
-rw-r--r--newlib/libc/ctype/ctype_iso.h395
-rw-r--r--newlib/libc/ctype/tolower.c23
-rw-r--r--newlib/libc/ctype/toupper.c23
9 files changed, 1093 insertions, 78 deletions
diff --git a/newlib/libc/ctype/Makefile.am b/newlib/libc/ctype/Makefile.am
index eba35ef95..3d351aeca 100644
--- a/newlib/libc/ctype/Makefile.am
+++ b/newlib/libc/ctype/Makefile.am
@@ -41,8 +41,6 @@ ELIX_SOURCES = \
iswxdigit.c \
jp2uc.c \
toascii.c \
- _tolower.c \
- _toupper.c \
towctrans.c \
towlower.c \
towupper.c \
@@ -113,3 +111,5 @@ doc: $(CHEWOUT_FILES)
cat $(srcdir)/ctype.tex >> $(TARGETDOC)
CLEANFILES = $(CHEWOUT_FILES) *.ref
+
+$(lpfx)ctype_.$(oext): ctype_.c ctype_iso.h ctype_cp.h
diff --git a/newlib/libc/ctype/Makefile.in b/newlib/libc/ctype/Makefile.in
index a2bf61e19..5cbeed6ab 100644
--- a/newlib/libc/ctype/Makefile.in
+++ b/newlib/libc/ctype/Makefile.in
@@ -38,6 +38,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
+LIBOBJDIR =
DIST_COMMON = $(srcdir)/../../Makefile.shared $(srcdir)/Makefile.in \
$(srcdir)/Makefile.am
subdir = ctype
@@ -81,8 +82,6 @@ am__objects_1 = lib_a-ctype_.$(OBJEXT) lib_a-isalnum.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@ lib_a-iswxdigit.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@ lib_a-jp2uc.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@ lib_a-toascii.$(OBJEXT) \
-@ELIX_LEVEL_1_FALSE@ lib_a-_tolower.$(OBJEXT) \
-@ELIX_LEVEL_1_FALSE@ lib_a-_toupper.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@ lib_a-towctrans.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@ lib_a-towlower.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@ lib_a-towupper.$(OBJEXT) \
@@ -101,9 +100,9 @@ am__objects_3 = ctype_.lo isalnum.lo isalpha.lo iscntrl.lo isdigit.lo \
@ELIX_LEVEL_1_FALSE@ iswctype.lo iswdigit.lo iswgraph.lo \
@ELIX_LEVEL_1_FALSE@ iswlower.lo iswprint.lo iswpunct.lo \
@ELIX_LEVEL_1_FALSE@ iswspace.lo iswupper.lo iswxdigit.lo \
-@ELIX_LEVEL_1_FALSE@ jp2uc.lo toascii.lo _tolower.lo \
-@ELIX_LEVEL_1_FALSE@ _toupper.lo towctrans.lo towlower.lo \
-@ELIX_LEVEL_1_FALSE@ towupper.lo wctrans.lo wctype.lo
+@ELIX_LEVEL_1_FALSE@ jp2uc.lo toascii.lo towctrans.lo \
+@ELIX_LEVEL_1_FALSE@ towlower.lo towupper.lo wctrans.lo \
+@ELIX_LEVEL_1_FALSE@ wctype.lo
@USE_LIBTOOL_TRUE@am_libctype_la_OBJECTS = $(am__objects_3) \
@USE_LIBTOOL_TRUE@ $(am__objects_4)
libctype_la_OBJECTS = $(am_libctype_la_OBJECTS)
@@ -232,20 +231,8 @@ STRIP = @STRIP@
USE_LIBTOOL_FALSE = @USE_LIBTOOL_FALSE@
USE_LIBTOOL_TRUE = @USE_LIBTOOL_TRUE@
VERSION = @VERSION@
-ac_ct_AR = @ac_ct_AR@
-ac_ct_AS = @ac_ct_AS@
ac_ct_CC = @ac_ct_CC@
-ac_ct_DLLTOOL = @ac_ct_DLLTOOL@
-ac_ct_DSYMUTIL = @ac_ct_DSYMUTIL@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
-ac_ct_LIPO = @ac_ct_LIPO@
-ac_ct_NMEDIT = @ac_ct_NMEDIT@
-ac_ct_OBJDUMP = @ac_ct_OBJDUMP@
-ac_ct_OTOOL = @ac_ct_OTOOL@
-ac_ct_OTOOL64 = @ac_ct_OTOOL64@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_READELF = @ac_ct_READELF@
-ac_ct_STRIP = @ac_ct_STRIP@
aext = @aext@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
@@ -261,6 +248,9 @@ build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
exec_prefix = @exec_prefix@
extra_dir = @extra_dir@
host = @host@
@@ -268,12 +258,14 @@ host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
+htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
libm_machine_dir = @libm_machine_dir@
+localedir = @localedir@
localstatedir = @localstatedir@
lpfx = @lpfx@
lt_ECHO = @lt_ECHO@
@@ -283,8 +275,10 @@ mkdir_p = @mkdir_p@
newlib_basedir = @newlib_basedir@
oext = @oext@
oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
+psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
subdirs = @subdirs@
@@ -326,8 +320,6 @@ GENERAL_SOURCES = \
@ELIX_LEVEL_1_FALSE@ iswxdigit.c \
@ELIX_LEVEL_1_FALSE@ jp2uc.c \
@ELIX_LEVEL_1_FALSE@ toascii.c \
-@ELIX_LEVEL_1_FALSE@ _tolower.c \
-@ELIX_LEVEL_1_FALSE@ _toupper.c \
@ELIX_LEVEL_1_FALSE@ towctrans.c \
@ELIX_LEVEL_1_FALSE@ towlower.c \
@ELIX_LEVEL_1_FALSE@ towupper.c \
@@ -628,18 +620,6 @@ lib_a-toascii.o: toascii.c
lib_a-toascii.obj: toascii.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-toascii.obj `if test -f 'toascii.c'; then $(CYGPATH_W) 'toascii.c'; else $(CYGPATH_W) '$(srcdir)/toascii.c'; fi`
-lib_a-_tolower.o: _tolower.c
- $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-_tolower.o `test -f '_tolower.c' || echo '$(srcdir)/'`_tolower.c
-
-lib_a-_tolower.obj: _tolower.c
- $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-_tolower.obj `if test -f '_tolower.c'; then $(CYGPATH_W) '_tolower.c'; else $(CYGPATH_W) '$(srcdir)/_tolower.c'; fi`
-
-lib_a-_toupper.o: _toupper.c
- $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-_toupper.o `test -f '_toupper.c' || echo '$(srcdir)/'`_toupper.c
-
-lib_a-_toupper.obj: _toupper.c
- $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-_toupper.obj `if test -f '_toupper.c'; then $(CYGPATH_W) '_toupper.c'; else $(CYGPATH_W) '$(srcdir)/_toupper.c'; fi`
-
lib_a-towctrans.o: towctrans.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-towctrans.o `test -f 'towctrans.c' || echo '$(srcdir)/'`towctrans.c
@@ -677,7 +657,7 @@ clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
- -rm -f libtool
+ -rm -f libtool config.lt
uninstall-info-am:
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
@@ -830,6 +810,8 @@ objectlist.awk.in: $(noinst_LTLIBRARIES)
doc: $(CHEWOUT_FILES)
cat $(srcdir)/ctype.tex >> $(TARGETDOC)
+
+$(lpfx)ctype_.$(oext): ctype_.c ctype_iso.h ctype_cp.h
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/newlib/libc/ctype/_tolower.c b/newlib/libc/ctype/_tolower.c
deleted file mode 100644
index 968dcf738..000000000
--- a/newlib/libc/ctype/_tolower.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <_ansi.h>
-#include <ctype.h>
-
-#undef _tolower
-int
-_DEFUN(_tolower,(c),int c)
-{
- return isupper(c) ? (c) - 'A' + 'a' : c;
-}
diff --git a/newlib/libc/ctype/_toupper.c b/newlib/libc/ctype/_toupper.c
deleted file mode 100644
index db4e00dd0..000000000
--- a/newlib/libc/ctype/_toupper.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <_ansi.h>
-#include <ctype.h>
-
-#undef _toupper
-int
-_DEFUN(_toupper,(c),int c)
-{
- return islower(c) ? c - 'a' + 'A' : c;
-}
diff --git a/newlib/libc/ctype/ctype_.c b/newlib/libc/ctype/ctype_.c
index 71756431b..f5d5300b3 100644
--- a/newlib/libc/ctype/ctype_.c
+++ b/newlib/libc/ctype/ctype_.c
@@ -73,58 +73,102 @@ static char sccsid[] = "@(#)ctype_.c 5.6 (Berkeley) 6/1/90";
0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0
-#if defined(__GNUC__) && !defined(__CHAR_UNSIGNED__) && !defined(COMPACT_CTYPE)
+#if (defined(__GNUC__) && !defined(__CHAR_UNSIGNED__) && !defined(COMPACT_CTYPE)) || defined (__CYGWIN__)
#define ALLOW_NEGATIVE_CTYPE_INDEX
#endif
#if defined(ALLOW_NEGATIVE_CTYPE_INDEX)
-static _CONST char _ctype_b[128 + 256] = {
+/* No static const on Cygwin since it's referenced and potentially overwritten
+ for compatibility with older applications. */
+#ifndef __CYGWIN__
+static _CONST
+#endif
+char _ctype_b[128 + 256] = {
_CTYPE_DATA_128_256,
_CTYPE_DATA_0_127,
_CTYPE_DATA_128_256
};
-# if defined(__CYGWIN__)
-_CONST char __declspec(dllexport) *__ctype_ptr = _ctype_b + 128;
-_CONST char __declspec(dllexport) *__ctype_ptr__ = _ctype_b + 127;
-# else
-_CONST char *__ctype_ptr = _ctype_b + 128;
-_CONST char *__ctype_ptr__ = _ctype_b + 127;
-# endif
+#if defined(_MB_CAPABLE)
+#if defined(_MB_EXTENDED_CHARSETS_ISO)
+#include "ctype_iso.h"
+#endif
+#if defined(_MB_EXTENDED_CHARSETS_WINDOWS)
+#include "ctype_cp.h"
+#endif
+#endif
+
+char __EXPORT *__ctype_ptr__ = _ctype_b + 127;
+
+# ifdef __CYGWIN__
-# if defined(_HAVE_ARRAY_ALIASING)
+__asm__ (" \n\
+ .data \n\
+ .globl __ctype_ \n\
+ .set __ctype_,__ctype_b+127 \n\
+ .text \n\
+");
+
+# elif defined(_HAVE_ARRAY_ALIASING)
-# if defined(__CYGWIN__)
-extern _CONST char __declspec(dllexport) _ctype_[1 + 256] __attribute__ ((alias ("_ctype_b+127")));
-# else
extern _CONST char _ctype_[1 + 256] __attribute__ ((alias ("_ctype_b+127")));
-# endif
# else /* !_HAVE_ARRAY_ALIASING */
-# if defined(__CYGWIN__)
-_CONST char __declspec(dllexport) _ctype_[1 + 256] = {
-# else
_CONST char _ctype_[1 + 256] = {
-# endif
0,
_CTYPE_DATA_0_127,
_CTYPE_DATA_128_256
};
-# endif /* !_HAVE_ARRAY_ALIASING */
+# endif /* !_HAVE_ARRAY_ALIASING */
#else /* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */
-# if defined(__CYGWIN__)
-_CONST char __declspec(dllexport) _ctype_[1 + 256] = {
-# else
_CONST char _ctype_[1 + 256] = {
-# endif
0,
_CTYPE_DATA_0_127,
_CTYPE_DATA_128_256
};
-_CONST char *__ctype_ptr = _ctype_ + 1;
_CONST char *__ctype_ptr__ = _ctype_;
#endif
+
+#if defined(_MB_CAPABLE)
+/* Cygwin has its own implementation which additionally maintains backward
+ compatibility with applications built under older Cygwin releases. */
+#ifndef __CYGWIN__
+void
+__set_ctype (const char *charset)
+{
+ int idx;
+
+ switch (*charset)
+ {
+#if defined(_MB_EXTENDED_CHARSETS_ISO)
+ case 'I':
+ idx = __iso_8859_index (charset + 9);
+ /* The ctype table has a leading ISO-8859-1 element so we have to add
+ 1 to the index returned by __iso_8859_index. If __iso_8859_index
+ returns < 0, it's ISO-8859-1. */
+ if (idx < 0)
+ idx = 0;
+ else
+ ++idx;
+ __ctype_ptr__ = (char *) (__ctype_iso[idx] + 127);
+ return;
+#endif
+#if defined(_MB_EXTENDED_CHARSETS_WINDOWS)
+ case 'C':
+ idx = __cp_index (charset + 2);
+ if (idx < 0)
+ break;
+ __ctype_ptr__ = (char *) (__ctype_cp[idx] + 127);
+ return;
+#endif
+ default:
+ break;
+ }
+ __ctype_ptr__ = (char *) _ctype_b + 127;
+}
+#endif /* !__CYGWIN__ */
+#endif /* _MB_CAPABLE */
diff --git a/newlib/libc/ctype/ctype_cp.h b/newlib/libc/ctype/ctype_cp.h
new file mode 100644
index 000000000..389a6207b
--- /dev/null
+++ b/newlib/libc/ctype/ctype_cp.h
@@ -0,0 +1,570 @@
+/* ctype table definitions for Windows codepage charsets.
+ Included by ctype_.c. */
+
+#define _CTYPE_CP437_128_256 \
+ _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
+#define _CTYPE_CP720_128_256 \
+ 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
+#define _CTYPE_CP737_128_256 \
+ _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
+#define _CTYPE_CP775_128_256 \
+ _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
+#define _CTYPE_CP850_128_256 \
+ _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
+#define _CTYPE_CP852_128_256 \
+ _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
+#define _CTYPE_CP855_128_256 \
+ _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
+#define _CTYPE_CP857_128_256 \
+ _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
+#define _CTYPE_CP858_128_256 \
+ _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
+#define _CTYPE_CP862_128_256 \
+ _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
+#define _CTYPE_CP866_128_256 \
+ _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
+#define _CTYPE_CP874_128_256 \
+ _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
+#define _CTYPE_CP1125_128_256 \
+ _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
+#define _CTYPE_CP1250_128_256 \
+ _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
+#define _CTYPE_CP1251_128_256 \
+ _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
+#define _CTYPE_CP1252_128_256 \
+ _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
+#define _CTYPE_CP1253_128_256 \
+ _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
+#define _CTYPE_CP1254_128_256 \
+ _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
+#define _CTYPE_CP1255_128_256 \
+ _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
+#define _CTYPE_CP1256_128_256 \
+ _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
+#define _CTYPE_CP1257_128_256 \
+ _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
+#define _CTYPE_CP1258_128_256 \
+ _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
+
+extern int __cp_index (const char *charset_ext);
+
+#if defined(ALLOW_NEGATIVE_CTYPE_INDEX)
+
+#ifndef __CYGWIN__
+static _CONST
+#endif
+char __ctype_cp[22][128 + 256] = {
+ { _CTYPE_CP437_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP437_128_256
+ },
+ { _CTYPE_CP720_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP720_128_256
+ },
+ { _CTYPE_CP737_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP737_128_256
+ },
+ { _CTYPE_CP775_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP775_128_256
+ },
+ { _CTYPE_CP850_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP850_128_256
+ },
+ { _CTYPE_CP852_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP852_128_256
+ },
+ { _CTYPE_CP855_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP855_128_256
+ },
+ { _CTYPE_CP857_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP857_128_256
+ },
+ { _CTYPE_CP858_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP858_128_256
+ },
+ { _CTYPE_CP862_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP862_128_256
+ },
+ { _CTYPE_CP866_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP866_128_256
+ },
+ { _CTYPE_CP874_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP874_128_256
+ },
+ { _CTYPE_CP1125_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1125_128_256
+ },
+ { _CTYPE_CP1250_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1250_128_256
+ },
+ { _CTYPE_CP1251_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1251_128_256
+ },
+ { _CTYPE_CP1252_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1252_128_256
+ },
+ { _CTYPE_CP1253_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1253_128_256
+ },
+ { _CTYPE_CP1254_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1254_128_256
+ },
+ { _CTYPE_CP1255_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1255_128_256
+ },
+ { _CTYPE_CP1256_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1256_128_256
+ },
+ { _CTYPE_CP1257_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1257_128_256
+ },
+ { _CTYPE_CP1258_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1258_128_256
+ },
+};
+
+#else /* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */
+
+static _CONST char __ctype_cp[22][1 + 256] = {
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP437_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP720_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP737_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP775_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP850_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP852_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP855_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP857_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP858_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP862_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP866_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP874_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1125_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1250_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1251_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1252_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1253_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1254_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1255_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1256_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1257_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_CP1258_128_256
+ },
+};
+
+#endif /* ALLOW_NEGATIVE_CTYPE_INDEX */
diff --git a/newlib/libc/ctype/ctype_iso.h b/newlib/libc/ctype/ctype_iso.h
new file mode 100644
index 000000000..3bd96c45b
--- /dev/null
+++ b/newlib/libc/ctype/ctype_iso.h
@@ -0,0 +1,395 @@
+/* ctype table definitions for ISO-8859-x charsets.
+ Included by ctype_.c. */
+
+#define _CTYPE_ISO_8859_1_128_256 \
+ _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
+#define _CTYPE_ISO_8859_2_128_256 \
+ _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
+#define _CTYPE_ISO_8859_3_128_256 \
+ _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
+#define _CTYPE_ISO_8859_4_128_256 \
+ _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
+#define _CTYPE_ISO_8859_5_128_256 \
+ _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
+#define _CTYPE_ISO_8859_6_128_256 \
+ _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
+#define _CTYPE_ISO_8859_7_128_256 \
+ _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
+#define _CTYPE_ISO_8859_8_128_256 \
+ _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
+#define _CTYPE_ISO_8859_9_128_256 \
+ _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
+#define _CTYPE_ISO_8859_10_128_256 \
+ _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
+#define _CTYPE_ISO_8859_11_128_256 \
+ _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
+#define _CTYPE_ISO_8859_13_128_256 \
+ _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
+#define _CTYPE_ISO_8859_14_128_256 \
+ _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
+#define _CTYPE_ISO_8859_15_128_256 \
+ _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
+#define _CTYPE_ISO_8859_16_128_256 \
+ _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
+
+extern int __iso_8859_index (const char *charset_ext);
+
+#if defined(ALLOW_NEGATIVE_CTYPE_INDEX)
+
+#ifndef __CYGWIN__
+static _CONST
+#endif
+char __ctype_iso[15][128 + 256] = {
+ { _CTYPE_ISO_8859_1_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_1_128_256
+ },
+ { _CTYPE_ISO_8859_2_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_2_128_256
+ },
+ { _CTYPE_ISO_8859_3_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_3_128_256
+ },
+ { _CTYPE_ISO_8859_4_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_4_128_256
+ },
+ { _CTYPE_ISO_8859_5_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_5_128_256
+ },
+ { _CTYPE_ISO_8859_6_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_6_128_256
+ },
+ { _CTYPE_ISO_8859_7_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_7_128_256
+ },
+ { _CTYPE_ISO_8859_8_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_8_128_256
+ },
+ { _CTYPE_ISO_8859_9_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_9_128_256
+ },
+ { _CTYPE_ISO_8859_10_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_10_128_256
+ },
+ { _CTYPE_ISO_8859_11_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_11_128_256
+ },
+ { _CTYPE_ISO_8859_13_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_13_128_256
+ },
+ { _CTYPE_ISO_8859_14_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_14_128_256
+ },
+ { _CTYPE_ISO_8859_15_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_15_128_256
+ },
+ { _CTYPE_ISO_8859_16_128_256,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_16_128_256
+ },
+};
+
+#else /* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */
+
+static _CONST char __ctype_iso[15][1 + 256] = {
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_1_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_2_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_3_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_4_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_5_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_6_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_7_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_8_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_9_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_10_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_11_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_13_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_14_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_15_128_256
+ },
+ { 0,
+ _CTYPE_DATA_0_127,
+ _CTYPE_ISO_8859_16_128_256
+ },
+};
+
+#endif /* ALLOW_NEGATIVE_CTYPE_INDEX */
diff --git a/newlib/libc/ctype/tolower.c b/newlib/libc/ctype/tolower.c
index bdd22bfc5..66ba7233c 100644
--- a/newlib/libc/ctype/tolower.c
+++ b/newlib/libc/ctype/tolower.c
@@ -46,10 +46,31 @@ No supporting OS subroutines are required.
#include <_ansi.h>
#include <ctype.h>
+#if defined (_MB_EXTENDED_CHARSETS_ISO) || defined (_MB_EXTENDED_CHARSETS_WINDOWS)
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <wctype.h>
+#include <wchar.h>
+#endif
#undef tolower
int
_DEFUN(tolower,(c),int c)
{
- return isupper(c) ? (c) - 'A' + 'a' : c;
+#if defined (_MB_EXTENDED_CHARSETS_ISO) || defined (_MB_EXTENDED_CHARSETS_WINDOWS)
+ if ((unsigned char) c <= 0x7f)
+ return isupper (c) ? c - 'A' + 'a' : c;
+ else if (c != EOF && MB_CUR_MAX == 1 && isupper (c))
+ {
+ char s[MB_LEN_MAX] = { 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;
+#else
+ return isupper(c) ? (c) - 'A' + 'a' : c;
+#endif
}
diff --git a/newlib/libc/ctype/toupper.c b/newlib/libc/ctype/toupper.c
index 26f64b6dc..1b298d508 100644
--- a/newlib/libc/ctype/toupper.c
+++ b/newlib/libc/ctype/toupper.c
@@ -45,10 +45,31 @@ No supporting OS subroutines are required.
#include <_ansi.h>
#include <ctype.h>
+#if defined (_MB_EXTENDED_CHARSETS_ISO) || defined (_MB_EXTENDED_CHARSETS_WINDOWS)
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <wctype.h>
+#include <wchar.h>
+#endif
#undef toupper
int
_DEFUN(toupper,(c),int c)
{
- return islower(c) ? c - 'a' + 'A' : c;
+#if defined (_MB_EXTENDED_CHARSETS_ISO) || defined (_MB_EXTENDED_CHARSETS_WINDOWS)
+ if ((unsigned char) c <= 0x7f)
+ return islower (c) ? c - 'a' + 'A' : c;
+ else if (c != EOF && MB_CUR_MAX == 1 && islower (c))
+ {
+ char s[MB_LEN_MAX] = { 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;
+#else
+ return islower (c) ? c - 'a' + 'A' : c;
+#endif
}