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-03 12:28:45 +0300
committerCorinna Vinschen <corinna@vinschen.de>2009-03-03 12:28:45 +0300
commitd6cd9169dcb6d5f276c43fefe91428240d7552d3 (patch)
tree2d19fe80bda68861de179acfe4dd049e43d4caad /newlib/libc/ctype
parente81ae92910761df9451d7513d9357ccf35b334c0 (diff)
* libc/locale/locale.c (_setlocale_r): New implementation based on
FreeBSD's setlocale. (currentlocale): New helper function. (loadlocale): Ditto. (__locale_charset): New function. (__locale_msgcharset): Rename from __locale_charset. * libc/ctype/local.h (__lc_ctype): Remove declaration. (__locale_charset): Declare. * libc/ctype/iswalpha.c (iswalpha): Call __locale_charset instead of using __lc_ctype directly. Only compare against the charset alone. * libc/ctype/iswblank.c (iswblank): Ditto. * libc/ctype/iswcntrl.c (iswcntrl): Ditto. * libc/ctype/iswprint.c (iswprint): Ditto. * libc/ctype/iswpunct.c (iswpunct): Ditto. * libc/ctype/iswspace.c (iswspace): Ditto. * libc/ctype/towlower.c (towlower): Ditto. * libc/ctype/towupper.c (towupper): Ditto. * libc/stdlib/mbtowc_r.c (_mbtowc_r): Ditto. * libc/stdlib/wctomb_r.c (_wctomb_r): Ditto. * libc/sys/linux/intl/loadmsgcat.c (_nl_init_domain_conv): Call __locale_msgcharset instead of __locale_charset.
Diffstat (limited to 'newlib/libc/ctype')
-rw-r--r--newlib/libc/ctype/iswalpha.c16
-rw-r--r--newlib/libc/ctype/iswblank.c16
-rw-r--r--newlib/libc/ctype/iswcntrl.c16
-rw-r--r--newlib/libc/ctype/iswprint.c16
-rw-r--r--newlib/libc/ctype/iswpunct.c16
-rw-r--r--newlib/libc/ctype/iswspace.c16
-rw-r--r--newlib/libc/ctype/local.h2
-rw-r--r--newlib/libc/ctype/towlower.c15
-rw-r--r--newlib/libc/ctype/towupper.c15
9 files changed, 47 insertions, 81 deletions
diff --git a/newlib/libc/ctype/iswalpha.c b/newlib/libc/ctype/iswalpha.c
index 7f8de8e59..a2c9cf9b9 100644
--- a/newlib/libc/ctype/iswalpha.c
+++ b/newlib/libc/ctype/iswalpha.c
@@ -69,29 +69,25 @@ No supporting OS subroutines are required.
int
_DEFUN(iswalpha,(c), wint_t c)
{
- int unicode = 0;
- if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
- {
- unicode = 0;
- /* fall-through */
- }
#ifdef _MB_CAPABLE
- else if (!strcmp (__lc_ctype, "C-JIS"))
+ int unicode = 0;
+
+ if (!strcmp (__locale_charset (), "JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-SJIS"))
+ else if (!strcmp (__locale_charset (), "SJIS"))
{
c = __jp2uc (c, JP_SJIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-EUCJP"))
+ else if (!strcmp (__locale_charset (), "EUCJP"))
{
c = __jp2uc (c, JP_EUCJP);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-UTF-8"))
+ else if (!strcmp (__locale_charset (), "UTF-8"))
{
unicode = 1;
}
diff --git a/newlib/libc/ctype/iswblank.c b/newlib/libc/ctype/iswblank.c
index 48205bb17..4db8ae013 100644
--- a/newlib/libc/ctype/iswblank.c
+++ b/newlib/libc/ctype/iswblank.c
@@ -65,29 +65,25 @@ No supporting OS subroutines are required.
int
_DEFUN(iswblank,(c), wint_t c)
{
- int unicode = 0;
- if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
- {
- unicode = 0;
- /* fall-through */
- }
#ifdef _MB_CAPABLE
- else if (!strcmp (__lc_ctype, "C-JIS"))
+ int unicode = 0;
+
+ if (!strcmp (__locale_charset (), "JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-SJIS"))
+ else if (!strcmp (__locale_charset (), "SJIS"))
{
c = __jp2uc (c, JP_SJIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-EUCJP"))
+ else if (!strcmp (__locale_charset (), "EUCJP"))
{
c = __jp2uc (c, JP_EUCJP);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-UTF-8"))
+ else if (!strcmp (__locale_charset (), "UTF-8"))
{
unicode = 1;
}
diff --git a/newlib/libc/ctype/iswcntrl.c b/newlib/libc/ctype/iswcntrl.c
index 15ff1fa67..b9f946072 100644
--- a/newlib/libc/ctype/iswcntrl.c
+++ b/newlib/libc/ctype/iswcntrl.c
@@ -65,29 +65,25 @@ No supporting OS subroutines are required.
int
_DEFUN(iswcntrl,(c), wint_t c)
{
- int unicode = 0;
- if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
- {
- unicode = 0;
- /* fall-through */
- }
#ifdef _MB_CAPABLE
- else if (!strcmp (__lc_ctype, "C-JIS"))
+ int unicode = 0;
+
+ if (!strcmp (__locale_charset (), "JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-SJIS"))
+ else if (!strcmp (__locale_charset (), "SJIS"))
{
c = __jp2uc (c, JP_SJIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-EUCJP"))
+ else if (!strcmp (__locale_charset (), "EUCJP"))
{
c = __jp2uc (c, JP_EUCJP);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-UTF-8"))
+ else if (!strcmp (__locale_charset (), "UTF-8"))
{
unicode = 1;
}
diff --git a/newlib/libc/ctype/iswprint.c b/newlib/libc/ctype/iswprint.c
index 6c0cc553d..814a26bfd 100644
--- a/newlib/libc/ctype/iswprint.c
+++ b/newlib/libc/ctype/iswprint.c
@@ -69,29 +69,25 @@ No supporting OS subroutines are required.
int
_DEFUN(iswprint,(c), wint_t c)
{
- int unicode = 0;
- if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
- {
- unicode = 0;
- /* fall-through */
- }
#ifdef _MB_CAPABLE
- else if (!strcmp (__lc_ctype, "C-JIS"))
+ int unicode = 0;
+
+ if (!strcmp (__locale_charset (), "JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-SJIS"))
+ else if (!strcmp (__locale_charset (), "SJIS"))
{
c = __jp2uc (c, JP_SJIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-EUCJP"))
+ else if (!strcmp (__locale_charset (), "EUCJP"))
{
c = __jp2uc (c, JP_EUCJP);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-UTF-8"))
+ else if (!strcmp (__locale_charset (), "UTF-8"))
{
unicode = 1;
}
diff --git a/newlib/libc/ctype/iswpunct.c b/newlib/libc/ctype/iswpunct.c
index c6a4eda83..1f19b66b8 100644
--- a/newlib/libc/ctype/iswpunct.c
+++ b/newlib/libc/ctype/iswpunct.c
@@ -69,29 +69,25 @@ No supporting OS subroutines are required.
int
_DEFUN(iswpunct,(c), wint_t c)
{
- int unicode = 0;
- if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
- {
- unicode = 0;
- /* fall-through */
- }
#ifdef _MB_CAPABLE
- else if (!strcmp (__lc_ctype, "C-JIS"))
+ int unicode = 0;
+
+ if (!strcmp (__locale_charset (), "JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-SJIS"))
+ else if (!strcmp (__locale_charset (), "SJIS"))
{
c = __jp2uc (c, JP_SJIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-EUCJP"))
+ else if (!strcmp (__locale_charset (), "EUCJP"))
{
c = __jp2uc (c, JP_EUCJP);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-UTF-8"))
+ else if (!strcmp (__locale_charset (), "UTF-8"))
{
unicode = 1;
}
diff --git a/newlib/libc/ctype/iswspace.c b/newlib/libc/ctype/iswspace.c
index e10a35df6..b9c74395a 100644
--- a/newlib/libc/ctype/iswspace.c
+++ b/newlib/libc/ctype/iswspace.c
@@ -65,29 +65,25 @@ No supporting OS subroutines are required.
int
_DEFUN(iswspace,(c), wint_t c)
{
- int unicode = 0;
- if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
- {
- unicode = 0;
- /* fall-through */
- }
#ifdef _MB_CAPABLE
- else if (!strcmp (__lc_ctype, "C-JIS"))
+ int unicode = 0;
+
+ if (!strcmp (__locale_charset (), "JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-SJIS"))
+ else if (!strcmp (__locale_charset (), "SJIS"))
{
c = __jp2uc (c, JP_SJIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-EUCJP"))
+ else if (!strcmp (__locale_charset (), "EUCJP"))
{
c = __jp2uc (c, JP_EUCJP);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-UTF-8"))
+ else if (!strcmp (__locale_charset (), "UTF-8"))
{
unicode = 1;
}
diff --git a/newlib/libc/ctype/local.h b/newlib/libc/ctype/local.h
index b1eca42e6..9471607cf 100644
--- a/newlib/libc/ctype/local.h
+++ b/newlib/libc/ctype/local.h
@@ -20,7 +20,7 @@
#define WC_UPPER 11
#define WC_XDIGIT 12
-extern char __lc_ctype[12];
+extern char *__locale_charset ();
/* Japanese encoding types supported */
#define JP_JIS 1
diff --git a/newlib/libc/ctype/towlower.c b/newlib/libc/ctype/towlower.c
index 89873c2f1..c3fcb77ba 100644
--- a/newlib/libc/ctype/towlower.c
+++ b/newlib/libc/ctype/towlower.c
@@ -69,30 +69,25 @@ No supporting OS subroutines are required.
wint_t
_DEFUN(towlower,(c), wint_t c)
{
+#ifdef _MB_CAPABLE
int unicode = 0;
- if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
- {
- unicode = 0;
- /* fall-through */
- }
-#ifdef _MB_CAPABLE
- else if (!strcmp (__lc_ctype, "C-JIS"))
+ if (!strcmp (__locale_charset (), "JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-SJIS"))
+ else if (!strcmp (__locale_charset (), "SJIS"))
{
c = __jp2uc (c, JP_SJIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-EUCJP"))
+ else if (!strcmp (__locale_charset (), "EUCJP"))
{
c = __jp2uc (c, JP_EUCJP);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-UTF-8"))
+ else if (!strcmp (__locale_charset (), "UTF-8"))
{
unicode = 1;
}
diff --git a/newlib/libc/ctype/towupper.c b/newlib/libc/ctype/towupper.c
index ec6c4ffa4..385dc9ba6 100644
--- a/newlib/libc/ctype/towupper.c
+++ b/newlib/libc/ctype/towupper.c
@@ -69,30 +69,25 @@ No supporting OS subroutines are required.
wint_t
_DEFUN(towupper,(c), wint_t c)
{
+#ifdef _MB_CAPABLE
int unicode = 0;
- if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
- {
- unicode = 0;
- /* fall-through */
- }
-#ifdef _MB_CAPABLE
- else if (!strcmp (__lc_ctype, "C-JIS"))
+ if (!strcmp (__locale_charset (), "JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-SJIS"))
+ else if (!strcmp (__locale_charset (), "SJIS"))
{
c = __jp2uc (c, JP_SJIS);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-EUCJP"))
+ else if (!strcmp (__locale_charset (), "EUCJP"))
{
c = __jp2uc (c, JP_EUCJP);
unicode = 1;
}
- else if (!strcmp (__lc_ctype, "C-UTF-8"))
+ else if (!strcmp (__locale_charset (), "UTF-8"))
{
unicode = 1;
}