From 1cf38d075c0df8728237b1ef27d9cfc8876abf16 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 14 May 2009 20:16:21 +0000 Subject: [PATCH] * libc/ctype/local.h (JP_JIS, JP_SJIS, JP_EUCJP): Move definition to jp2uc.c. (__jp2uc): Remove declaration. (_jp2uc): Declare. * libc/ctype/jp2uc.c (JP_JIS, JP_SJIS, JP_EUCJP): Define. (__jp2uc): Remove Cygwin special case. (_jp2uc): New function. On Cygwin, just return c. * libc/ctype/iswalpha.c (iswalpha): Just call _jp2uc. * libc/ctype/iswblank.c (iswblank): Ditto. * libc/ctype/iswcntrl.c (iswcntrl): Ditto. * libc/ctype/iswprint.c (iswprint): Ditto. * libc/ctype/iswpunct.c (iswpunt): Ditto. * libc/ctype/iswspace.c (iswspace): Ditto. * libc/ctype/towlower.c (towlower): Ditto. * libc/ctype/towupper.c (towupper): Ditto. --- newlib/ChangeLog | 18 ++++++++++++++++++ newlib/libc/ctype/iswalpha.c | 7 +------ newlib/libc/ctype/iswblank.c | 7 +------ newlib/libc/ctype/iswcntrl.c | 7 +------ newlib/libc/ctype/iswprint.c | 7 +------ newlib/libc/ctype/iswpunct.c | 7 +------ newlib/libc/ctype/iswspace.c | 7 +------ newlib/libc/ctype/jp2uc.c | 25 ++++++++++++++++++++----- newlib/libc/ctype/local.h | 7 +------ newlib/libc/ctype/towlower.c | 8 +------- newlib/libc/ctype/towupper.c | 8 +------- 11 files changed, 47 insertions(+), 61 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index e7b3680d1..642ecec61 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,21 @@ +2009-05-14 Corinna Vinschen + + * libc/ctype/local.h (JP_JIS, JP_SJIS, JP_EUCJP): Move definition + to jp2uc.c. + (__jp2uc): Remove declaration. + (_jp2uc): Declare. + * libc/ctype/jp2uc.c (JP_JIS, JP_SJIS, JP_EUCJP): Define. + (__jp2uc): Remove Cygwin special case. + (_jp2uc): New function. On Cygwin, just return c. + * libc/ctype/iswalpha.c (iswalpha): Just call _jp2uc. + * libc/ctype/iswblank.c (iswblank): Ditto. + * libc/ctype/iswcntrl.c (iswcntrl): Ditto. + * libc/ctype/iswprint.c (iswprint): Ditto. + * libc/ctype/iswpunct.c (iswpunt): Ditto. + * libc/ctype/iswspace.c (iswspace): Ditto. + * libc/ctype/towlower.c (towlower): Ditto. + * libc/ctype/towupper.c (towupper): Ditto. + 2009-05-13 Paul Brook * libc/machine/arm/setjmp.S: Don't bother saving IP. Copy SP to diff --git a/newlib/libc/ctype/iswalpha.c b/newlib/libc/ctype/iswalpha.c index 4e2ad6b0d..ab67857fb 100644 --- a/newlib/libc/ctype/iswalpha.c +++ b/newlib/libc/ctype/iswalpha.c @@ -76,12 +76,7 @@ _DEFUN(iswalpha,(c), wint_t c) int size; wint_t x; - if (!strcmp (__locale_charset (), "JIS")) - c = __jp2uc (c, JP_JIS); - else if (!strcmp (__locale_charset (), "SJIS")) - c = __jp2uc (c, JP_SJIS); - else if (!strcmp (__locale_charset (), "EUCJP")) - c = __jp2uc (c, JP_EUCJP); + c = _jp2uc (c); x = (c >> 8); /* for some large sections, all characters are alphabetic so handle them here */ diff --git a/newlib/libc/ctype/iswblank.c b/newlib/libc/ctype/iswblank.c index e0601e945..5cd37016f 100644 --- a/newlib/libc/ctype/iswblank.c +++ b/newlib/libc/ctype/iswblank.c @@ -66,12 +66,7 @@ int _DEFUN(iswblank,(c), wint_t c) { #ifdef _MB_CAPABLE - if (!strcmp (__locale_charset (), "JIS")) - c = __jp2uc (c, JP_JIS); - else if (!strcmp (__locale_charset (), "SJIS")) - c = __jp2uc (c, JP_SJIS); - else if (!strcmp (__locale_charset (), "EUCJP")) - c = __jp2uc (c, JP_EUCJP); + c = _jp2uc (c); return (c == 0x0009 || c == 0x0020 || c == 0x1680 || (c >= 0x2000 && c <= 0x2006) || (c >= 0x2008 && c <= 0x200b) || diff --git a/newlib/libc/ctype/iswcntrl.c b/newlib/libc/ctype/iswcntrl.c index 2d8a1ddd6..94439784f 100644 --- a/newlib/libc/ctype/iswcntrl.c +++ b/newlib/libc/ctype/iswcntrl.c @@ -66,12 +66,7 @@ int _DEFUN(iswcntrl,(c), wint_t c) { #ifdef _MB_CAPABLE - if (!strcmp (__locale_charset (), "JIS")) - c = __jp2uc (c, JP_JIS); - else if (!strcmp (__locale_charset (), "SJIS")) - c = __jp2uc (c, JP_SJIS); - else if (!strcmp (__locale_charset (), "EUCJP")) - c = __jp2uc (c, JP_EUCJP); + c = _jp2uc (c); return ((c >= 0x0000 && c <= 0x001f) || (c >= 0x007f && c <= 0x009f) || c == 0x2028 || c == 0x2029); diff --git a/newlib/libc/ctype/iswprint.c b/newlib/libc/ctype/iswprint.c index a632aa405..055855e78 100644 --- a/newlib/libc/ctype/iswprint.c +++ b/newlib/libc/ctype/iswprint.c @@ -76,12 +76,7 @@ _DEFUN(iswprint,(c), wint_t c) int size; wint_t x; - if (!strcmp (__locale_charset (), "JIS")) - c = __jp2uc (c, JP_JIS); - else if (!strcmp (__locale_charset (), "SJIS")) - c = __jp2uc (c, JP_SJIS); - else if (!strcmp (__locale_charset (), "EUCJP")) - c = __jp2uc (c, JP_EUCJP); + c = _jp2uc (c); x = (c >> 8); /* for some large sections, all characters are printuation so handle them here */ diff --git a/newlib/libc/ctype/iswpunct.c b/newlib/libc/ctype/iswpunct.c index fc0bd630f..4e9dd88d2 100644 --- a/newlib/libc/ctype/iswpunct.c +++ b/newlib/libc/ctype/iswpunct.c @@ -76,12 +76,7 @@ _DEFUN(iswpunct,(c), wint_t c) int size; wint_t x; - if (!strcmp (__locale_charset (), "JIS")) - c = __jp2uc (c, JP_JIS); - else if (!strcmp (__locale_charset (), "SJIS")) - c = __jp2uc (c, JP_SJIS); - else if (!strcmp (__locale_charset (), "EUCJP")) - c = __jp2uc (c, JP_EUCJP); + c = _jp2uc (c); x = (c >> 8); /* for some large sections, all characters are punctuation so handle them here */ diff --git a/newlib/libc/ctype/iswspace.c b/newlib/libc/ctype/iswspace.c index 100e7822a..a1edbdcef 100644 --- a/newlib/libc/ctype/iswspace.c +++ b/newlib/libc/ctype/iswspace.c @@ -66,12 +66,7 @@ int _DEFUN(iswspace,(c), wint_t c) { #ifdef _MB_CAPABLE - if (!strcmp (__locale_charset (), "JIS")) - c = __jp2uc (c, JP_JIS); - else if (!strcmp (__locale_charset (), "SJIS")) - c = __jp2uc (c, JP_SJIS); - else if (!strcmp (__locale_charset (), "EUCJP")) - c = __jp2uc (c, JP_EUCJP); + c = _jp2uc (c); return ((c >= 0x0009 && c <= 0x000d) || c == 0x0020 || c == 0x1680 || (c >= 0x2000 && c <= 0x2006) || (c >= 0x2008 && c <= 0x200b) || diff --git a/newlib/libc/ctype/jp2uc.c b/newlib/libc/ctype/jp2uc.c index d1096442e..77443b8ff 100644 --- a/newlib/libc/ctype/jp2uc.c +++ b/newlib/libc/ctype/jp2uc.c @@ -38,14 +38,14 @@ #include "local.h" #include "jp2uc.h" +/* Japanese encoding types supported */ +#define JP_JIS 1 +#define JP_SJIS 2 +#define JP_EUCJP 3 + wint_t _DEFUN (__jp2uc, (c, type), wint_t c _AND int type) { -/* Under Cygwin, the incoming wide character is already given in UTF due - to the requirements of the underlying OS. */ -#ifdef __CYGWIN__ - return c; -#else int index, adj; unsigned char byte1, byte2; wint_t ret; @@ -145,7 +145,22 @@ _DEFUN (__jp2uc, (c, type), wint_t c _AND int type) } return WEOF; +} + +wint_t +_DEFUN (_jp2uc, (c), wint_t c) +{ +/* Under Cygwin, the incoming wide character is already given in UTF due + to the requirements of the underlying OS. */ +#ifndef __CYGWIN__ + if (!strcmp (__locale_charset (), "JIS")) + c = __jp2uc (c, JP_JIS); + else if (!strcmp (__locale_charset (), "SJIS")) + c = __jp2uc (c, JP_SJIS); + else if (!strcmp (__locale_charset (), "EUCJP")) + c = __jp2uc (c, JP_EUCJP); #endif + return c; } #endif /* _MB_CAPABLE */ diff --git a/newlib/libc/ctype/local.h b/newlib/libc/ctype/local.h index 9471607cf..ab1c7db71 100644 --- a/newlib/libc/ctype/local.h +++ b/newlib/libc/ctype/local.h @@ -22,11 +22,6 @@ extern char *__locale_charset (); -/* Japanese encoding types supported */ -#define JP_JIS 1 -#define JP_SJIS 2 -#define JP_EUCJP 3 - /* internal function to translate JP to Unicode */ -wint_t _EXFUN (__jp2uc, (wint_t, int)); +wint_t _EXFUN (_jp2uc, (wint_t)); diff --git a/newlib/libc/ctype/towlower.c b/newlib/libc/ctype/towlower.c index edda8ca34..f1ce1f5e0 100644 --- a/newlib/libc/ctype/towlower.c +++ b/newlib/libc/ctype/towlower.c @@ -70,13 +70,7 @@ wint_t _DEFUN(towlower,(c), wint_t c) { #ifdef _MB_CAPABLE - if (!strcmp (__locale_charset (), "JIS")) - c = __jp2uc (c, JP_JIS); - else if (!strcmp (__locale_charset (), "SJIS")) - c = __jp2uc (c, JP_SJIS); - else if (!strcmp (__locale_charset (), "EUCJP")) - c = __jp2uc (c, JP_EUCJP); - + c = _jp2uc (c); if (c < 0x100) { if ((c >= 0x0041 && c <= 0x005a) || diff --git a/newlib/libc/ctype/towupper.c b/newlib/libc/ctype/towupper.c index dee9468bd..945266fea 100644 --- a/newlib/libc/ctype/towupper.c +++ b/newlib/libc/ctype/towupper.c @@ -70,13 +70,7 @@ wint_t _DEFUN(towupper,(c), wint_t c) { #ifdef _MB_CAPABLE - if (!strcmp (__locale_charset (), "JIS")) - c = __jp2uc (c, JP_JIS); - else if (!strcmp (__locale_charset (), "SJIS")) - c = __jp2uc (c, JP_SJIS); - else if (!strcmp (__locale_charset (), "EUCJP")) - c = __jp2uc (c, JP_EUCJP); - + c = _jp2uc (c); if (c < 0x100) { if (c == 0x00b5) -- 2.43.5