[PATCH/RFA] Internationalize ctype functionality
Jeff Johnston
jjohnstn@redhat.com
Wed Apr 1 01:24:00 GMT 2009
Corinna Vinschen wrote:
> On Mar 26 22:01, Corinna Vinschen wrote:
>
>> Hi,
>>
>> as I threatened this list with already, I've now converted the ctype
>> functionality to an extensible, internationalized variation.
>> [...]
>>
>
> New patch below. I changed the toupper/tolower functions to check for
> islower/isupper before calling the mbtowc/tow{upper,lower}/wctomb
> routine. This should speed up loops using toupper/tolower
> unconditionally on native language input.
>
>
Please change the mbtowc/wctomb stuff in tolower/toupper to only be
enabled for _MB_EXTENDED_CHARSETS_ISO and
_MB_EXTENDED_CHARSETS_WINDOWS. Otherwise, you are linking in unused
functions to pre-existing code that was MB enabled and only cared about
the 3 Japanese code sets.
I am ok with Craig's idea to clean up declspec stuff in ctype_.c using
DLLEXPORT. That define could go in sys/config.h and be used globally.
Other than that, I am fine with the patch.
-- Jeff J.
> Corinna
>
>
> * 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.
> (_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 in _MB_CAPABLE
> case to support any singlebyte charset.
> * 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 in _MB_CAPABLE case.
> (tolower): Ditto.
> * libc/locale/locale.c: Declare __set_ctype unconditionally.
> (loadlocale): Remove __CYGWIN__ guard around __set_ctype call.
>
>
> Index: libc/ctype/Makefile.am
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/ctype/Makefile.am,v
> retrieving revision 1.8
> diff -u -p -r1.8 Makefile.am
> --- libc/ctype/Makefile.am 9 May 2006 21:53:35 -0000 1.8
> +++ libc/ctype/Makefile.am 30 Mar 2009 13:16:29 -0000
> @@ -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
> Index: libc/ctype/_tolower.c
> ===================================================================
> RCS file: libc/ctype/_tolower.c
> diff -N libc/ctype/_tolower.c
> --- libc/ctype/_tolower.c 17 Feb 2000 19:39:46 -0000 1.1.1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -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;
> -}
> Index: libc/ctype/_toupper.c
> ===================================================================
> RCS file: libc/ctype/_toupper.c
> diff -N libc/ctype/_toupper.c
> --- libc/ctype/_toupper.c 17 Feb 2000 19:39:46 -0000 1.1.1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -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;
> -}
> Index: libc/ctype/ctype_.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/ctype/ctype_.c,v
> retrieving revision 1.6
> diff -u -p -r1.6 ctype_.c
> --- libc/ctype/ctype_.c 26 Mar 2009 09:45:11 -0000 1.6
> +++ libc/ctype/ctype_.c 30 Mar 2009 13:16:29 -0000
> @@ -73,58 +73,106 @@ static char sccsid[] = "@(#)ctype_.c 5.6
> 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(_HAVE_ARRAY_ALIASING)
> -
> -# if defined(__CYGWIN__)
> -extern _CONST char __declspec(dllexport) _ctype_[1 + 256] __attribute__ ((alias ("_ctype_b+127")));
> -# else
> +#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
> +
> +#ifdef __CYGWIN__
> +char __declspec(dllexport) *__ctype_ptr__ = _ctype_b + 127;
> +#else
> +char *__ctype_ptr__ = _ctype_b + 127;
> +#endif
> +
> +# ifdef __CYGWIN__
> +
> +__asm__ (" \n\
> + .data \n\
> + .globl __ctype_ \n\
> + .set __ctype_,__ctype_b+127 \n\
> + .text \n\
> +");
> +
> +# elif defined(_HAVE_ARRAY_ALIASING)
> +
> 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;
> + default:
> + break;
> + }
> +#endif
> + __ctype_ptr__ = (char *) _ctype_b + 127;
> +}
> +#endif /* !__CYGWIN__ */
> +#endif /* _MB_CAPABLE */
> Index: libc/ctype/ctype_cp.h
> ===================================================================
> RCS file: libc/ctype/ctype_cp.h
> diff -N libc/ctype/ctype_cp.h
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ libc/ctype/ctype_cp.h 30 Mar 2009 13:16:29 -0000
> @@ -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 */
> Index: libc/ctype/ctype_iso.h
> ===================================================================
> RCS file: libc/ctype/ctype_iso.h
> diff -N libc/ctype/ctype_iso.h
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ libc/ctype/ctype_iso.h 30 Mar 2009 13:16:29 -0000
> @@ -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 */
> Index: libc/ctype/tolower.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/ctype/tolower.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 tolower.c
> --- libc/ctype/tolower.c 28 Oct 2005 21:33:22 -0000 1.2
> +++ libc/ctype/tolower.c 30 Mar 2009 13:16:29 -0000
> @@ -46,10 +46,31 @@ No supporting OS subroutines are require
>
> #include <_ansi.h>
> #include <ctype.h>
> +#ifdef _MB_CAPABLE
> +#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;
> +#ifdef _MB_CAPABLE
> + 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
> }
> Index: libc/ctype/toupper.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/ctype/toupper.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 toupper.c
> --- libc/ctype/toupper.c 28 Oct 2005 21:33:22 -0000 1.2
> +++ libc/ctype/toupper.c 30 Mar 2009 13:16:29 -0000
> @@ -45,10 +45,31 @@ No supporting OS subroutines are require
>
> #include <_ansi.h>
> #include <ctype.h>
> +#ifdef _MB_CAPABLE
> +#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;
> +#ifdef _MB_CAPABLE
> + 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
> }
> Index: libc/include/ctype.h
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/include/ctype.h,v
> retrieving revision 1.14
> diff -u -p -r1.14 ctype.h
> --- libc/include/ctype.h 26 Mar 2009 09:45:11 -0000 1.14
> +++ libc/include/ctype.h 30 Mar 2009 13:16:29 -0000
> @@ -26,8 +26,8 @@ int _EXFUN(isblank, (int __c));
> #ifndef __STRICT_ANSI__
> int _EXFUN(isascii, (int __c));
> int _EXFUN(toascii, (int __c));
> -int _EXFUN(_tolower, (int __c));
> -int _EXFUN(_toupper, (int __c));
> +#define _tolower(c) ((unsigned char)(c) - 'A' + 'a')
> +#define _toupper(c) ((unsigned char)(c) - 'a' + 'A')
> #endif
>
> #define _U 01
> @@ -39,7 +39,7 @@ int _EXFUN(_toupper, (int __c));
> #define _X 0100
> #define _B 0200
>
> -extern __IMPORT _CONST char *__ctype_ptr__;
> +extern __IMPORT char *__ctype_ptr__;
>
> #ifndef __cplusplus
> #define isalpha(c) ((__ctype_ptr__)[(unsigned)((c)+1)]&(_U|_L))
> @@ -60,8 +60,9 @@ extern __IMPORT _CONST char *__ctype_ptr
>
>
> /* Non-gcc versions will get the library versions, and will be
> - slightly slower */
> -#ifdef __GNUC__
> + slightly slower. These macros are not NLS-aware so they are
> + disabled if the system is multibyte capable. */
> +#if defined(__GNUC__) && !defined(_MB_CAPABLE)
> # define toupper(c) \
> __extension__ ({ int __x = (c); islower(__x) ? (__x - 'a' + 'A') : __x;})
> # define tolower(c) \
> Index: libc/locale/locale.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/locale/locale.c,v
> retrieving revision 1.16
> diff -u -p -r1.16 locale.c
> --- libc/locale/locale.c 26 Mar 2009 10:24:38 -0000 1.16
> +++ libc/locale/locale.c 30 Mar 2009 13:16:29 -0000
> @@ -377,9 +377,10 @@ currentlocale()
> #ifdef _MB_CAPABLE
> #ifdef __CYGWIN__
> extern void *__set_charset_from_codepage (unsigned int, char *charset);
> -extern void __set_ctype (const char *charset);
> #endif /* __CYGWIN__ */
>
> +extern void __set_ctype (const char *charset);
> +
> static char *
> loadlocale(struct _reent *p, int category)
> {
> @@ -604,10 +605,8 @@ loadlocale(struct _reent *p, int categor
> #ifdef _MB_CAPABLE
> __wctomb = l_wctomb;
> __mbtowc = l_mbtowc;
> -#ifdef __CYGWIN__
> __set_ctype (charset);
> #endif
> -#endif
> }
> else if (category == LC_MESSAGES)
> strcpy (lc_message_charset, charset);
>
>
>
More information about the Newlib
mailing list