Index: libc/locale/lmessages.c =================================================================== RCS file: /cvs/src/src/newlib/libc/locale/lmessages.c,v retrieving revision 1.2 diff -u -p -r1.2 lmessages.c --- libc/locale/lmessages.c 9 Feb 2010 08:58:38 -0000 1.2 +++ libc/locale/lmessages.c 29 Mar 2010 18:10:12 -0000 @@ -49,19 +49,19 @@ static int _messages_using_locale; static char *_messages_locale_buf; int -__messages_load_locale (const char *name, void *f_wctomb, const char *charset) +__messages_load_locale (const char *name, void *f_wctomb, int cs_idx) { #ifdef __CYGWIN__ extern int __set_lc_messages_from_win (const char *, struct lc_messages_T *, char **, - void *, const char *); + void *, int cs_idx); int ret; int old_messages_using_locale = _messages_using_locale; _messages_using_locale = 0; ret = __set_lc_messages_from_win (name, &_messages_locale, &_messages_locale_buf, - f_wctomb, charset); + f_wctomb, cs_idx); /* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ if (ret < 0) _messages_using_locale = old_messages_using_locale; Index: libc/locale/lmessages.h =================================================================== RCS file: /cvs/src/src/newlib/libc/locale/lmessages.h,v retrieving revision 1.2 diff -u -p -r1.2 lmessages.h --- libc/locale/lmessages.h 9 Feb 2010 08:58:38 -0000 1.2 +++ libc/locale/lmessages.h 29 Mar 2010 18:10:12 -0000 @@ -41,7 +41,7 @@ struct lc_messages_T { }; struct lc_messages_T *__get_current_messages_locale(void); -int __numeric_load_locale(const char *, void *, const char *); +int __numeric_load_locale(const char *, void *, int cs_idx); __END_DECLS Index: libc/locale/lmonetary.c =================================================================== RCS file: /cvs/src/src/newlib/libc/locale/lmonetary.c,v retrieving revision 1.3 diff -u -p -r1.3 lmonetary.c --- libc/locale/lmonetary.c 9 Feb 2010 08:58:38 -0000 1.3 +++ libc/locale/lmonetary.c 29 Mar 2010 18:10:12 -0000 @@ -70,19 +70,19 @@ cnv(const char *str) { } int -__monetary_load_locale(const char *name , void *f_wctomb, const char *charset) +__monetary_load_locale(const char *name , void *f_wctomb, int cs_idx) { int ret; #ifdef __CYGWIN__ extern int __set_lc_monetary_from_win (const char *, struct lc_monetary_T *, char **, - void *, const char *); + void *, int cs_idx); int old_monetary_using_locale = _monetary_using_locale; _monetary_using_locale = 0; ret = __set_lc_monetary_from_win (name, &_monetary_locale, &_monetary_locale_buf, - f_wctomb, charset); + f_wctomb, cs_idx); /* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ if (ret < 0) _monetary_using_locale = old_monetary_using_locale; Index: libc/locale/lmonetary.h =================================================================== RCS file: /cvs/src/src/newlib/libc/locale/lmonetary.h,v retrieving revision 1.2 diff -u -p -r1.2 lmonetary.h --- libc/locale/lmonetary.h 22 Jan 2010 13:03:42 -0000 1.2 +++ libc/locale/lmonetary.h 29 Mar 2010 18:10:12 -0000 @@ -52,7 +52,7 @@ struct lc_monetary_T { }; struct lc_monetary_T *__get_current_monetary_locale(void); -int __monetary_load_locale(const char *, void *, const char *); +int __monetary_load_locale(const char *, void *, int); __END_DECLS Index: libc/locale/lnumeric.c =================================================================== RCS file: /cvs/src/src/newlib/libc/locale/lnumeric.c,v retrieving revision 1.3 diff -u -p -r1.3 lnumeric.c --- libc/locale/lnumeric.c 9 Feb 2010 08:58:38 -0000 1.3 +++ libc/locale/lnumeric.c 29 Mar 2010 18:10:12 -0000 @@ -48,19 +48,19 @@ static int _numeric_using_locale; static char *_numeric_locale_buf; int -__numeric_load_locale(const char *name , void *f_wctomb, const char *charset) +__numeric_load_locale(const char *name , void *f_wctomb, int cs_idx) { int ret; #ifdef __CYGWIN__ extern int __set_lc_numeric_from_win (const char *, struct lc_numeric_T *, char **, - void *, const char *); + void *, int cs_idx); int old_numeric_using_locale = _numeric_using_locale; _numeric_using_locale = 0; ret = __set_lc_numeric_from_win (name, &_numeric_locale, &_numeric_locale_buf, - f_wctomb, charset); + f_wctomb, cs_idx); /* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ if (ret < 0) _numeric_using_locale = old_numeric_using_locale; Index: libc/locale/lnumeric.h =================================================================== RCS file: /cvs/src/src/newlib/libc/locale/lnumeric.h,v retrieving revision 1.2 diff -u -p -r1.2 lnumeric.h --- libc/locale/lnumeric.h 22 Jan 2010 13:03:42 -0000 1.2 +++ libc/locale/lnumeric.h 29 Mar 2010 18:10:12 -0000 @@ -40,7 +40,7 @@ struct lc_numeric_T { }; struct lc_numeric_T *__get_current_numeric_locale(void); -int __numeric_load_locale(const char *, void *, const char *); +int __numeric_load_locale(const char *, void *, int cs_idx); __END_DECLS Index: libc/locale/locale.c =================================================================== RCS file: /cvs/src/src/newlib/libc/locale/locale.c,v retrieving revision 1.43 diff -u -p -r1.43 locale.c --- libc/locale/locale.c 27 Mar 2010 21:04:49 -0000 1.43 +++ libc/locale/locale.c 29 Mar 2010 18:10:13 -0000 @@ -262,6 +262,7 @@ static char lc_ctype_charset[ENCODING_LE static char lc_message_charset[ENCODING_LEN + 1] = "ASCII"; #endif static int lc_ctype_cjk_lang = 0; +int __charset_index = 0; char * _DEFUN(_setlocale_r, (p, category, locale), @@ -430,9 +431,9 @@ currentlocale() #ifdef _MB_CAPABLE #ifdef __CYGWIN__ -extern void __set_charset_from_locale (const char *locale, char *charset); +extern void __set_charset_from_locale (const char *locale, int cs_idx); extern int __set_locale_from_locale_alias (const char *, char *); -extern int __collate_load_locale (const char *, void *, const char *); +extern int __collate_load_locale (const char *, void *, int cs_idx); #endif /* __CYGWIN__ */ extern void __set_ctype (const char *charset); @@ -450,6 +451,7 @@ loadlocale(struct _reent *p, int categor dependent on the cateogry. */ char *locale = NULL; char charset[ENCODING_LEN + 1]; + int cs_idx = 0; unsigned long val; char *end, *c; int mbc_max; @@ -599,6 +601,7 @@ restart: mbc_max = 3; l_wctomb = __eucjp_wctomb; l_mbtowc = __eucjp_mbtowc; + } #ifdef __CYGWIN__ /* Newlib does neither provide EUC-KR nor EUC-CN, and Cygwin's @@ -657,6 +660,7 @@ restart: #ifdef _MB_EXTENDED_CHARSETS_ISO l_wctomb = __iso_wctomb; l_mbtowc = __iso_mbtowc; + cs_idx = __iso_8859_index (charset + 9); #else /* !_MB_EXTENDED_CHARSETS_ISO */ l_wctomb = __ascii_wctomb; l_mbtowc = __ascii_mbtowc; @@ -698,6 +702,7 @@ restart: #ifdef _MB_EXTENDED_CHARSETS_WINDOWS l_wctomb = __cp_wctomb; l_mbtowc = __cp_mbtowc; + cs_idx = __cp_index (charset + 2); #else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ l_wctomb = __ascii_wctomb; l_mbtowc = __ascii_mbtowc; @@ -730,6 +735,7 @@ restart: #ifdef _MB_EXTENDED_CHARSETS_WINDOWS l_wctomb = __cp_wctomb; l_mbtowc = __cp_mbtowc; + cs_idx = __cp_index (charset + 2); #else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ l_wctomb = __ascii_wctomb; l_mbtowc = __ascii_mbtowc; @@ -772,6 +778,7 @@ restart: #ifdef _MB_EXTENDED_CHARSETS_WINDOWS l_wctomb = __cp_wctomb; l_mbtowc = __cp_mbtowc; + cs_idx = __cp_index (charset + 2); #else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ l_wctomb = __ascii_wctomb; l_mbtowc = __ascii_mbtowc; @@ -790,6 +797,7 @@ restart: #ifdef _MB_EXTENDED_CHARSETS_WINDOWS l_wctomb = __cp_wctomb; l_mbtowc = __cp_mbtowc; + cs_idx = __cp_index (charset + 2); #else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ l_wctomb = __ascii_wctomb; l_mbtowc = __ascii_mbtowc; @@ -809,6 +817,7 @@ restart: #ifdef _MB_EXTENDED_CHARSETS_WINDOWS l_wctomb = __cp_wctomb; l_mbtowc = __cp_mbtowc; + cs_idx = __cp_index (charset + 2); #else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ l_wctomb = __ascii_wctomb; l_mbtowc = __ascii_mbtowc; @@ -836,6 +845,7 @@ restart: __mb_cur_max = mbc_max; __wctomb = l_wctomb; __mbtowc = l_mbtowc; + __charset_index = cs_idx; __set_ctype (charset); /* Check for the language part of the locale specifier. In case of "ja", "ko", or "zh", assume the use of CJK fonts, unless the @@ -851,7 +861,7 @@ restart: else if (category == LC_MESSAGES) { #ifdef __HAVE_LOCALE_INFO__ - ret = __messages_load_locale (locale, (void *) l_wctomb, charset); + ret = __messages_load_locale (locale, (void *) l_wctomb, cs_idx); if (!ret) #endif /* __HAVE_LOCALE_INFO__ */ strcpy (lc_message_charset, charset); @@ -860,14 +870,14 @@ restart: #ifdef __CYGWIN__ /* Right now only Cygwin supports a __collate_load_locale function at all. */ else if (category == LC_COLLATE) - ret = __collate_load_locale (locale, (void *) l_mbtowc, charset); + ret = __collate_load_locale (locale, (void *) l_mbtowc, cs_idx); #endif else if (category == LC_MONETARY) - ret = __monetary_load_locale (locale, (void *) l_wctomb, charset); + ret = __monetary_load_locale (locale, (void *) l_wctomb, cs_idx); else if (category == LC_NUMERIC) - ret = __numeric_load_locale (locale, (void *) l_wctomb, charset); + ret = __numeric_load_locale (locale, (void *) l_wctomb, cs_idx); else if (category == LC_TIME) - ret = __time_load_locale (locale, (void *) l_wctomb, charset); + ret = __time_load_locale (locale, (void *) l_wctomb, cs_idx); if (ret) FAIL; #endif /* __HAVE_LOCALE_INFO__ */ Index: libc/locale/timelocal.c =================================================================== RCS file: /cvs/src/src/newlib/libc/locale/timelocal.c,v retrieving revision 1.4 diff -u -p -r1.4 timelocal.c --- libc/locale/timelocal.c 18 Feb 2010 17:35:15 -0000 1.4 +++ libc/locale/timelocal.c 29 Mar 2010 18:10:13 -0000 @@ -129,17 +129,17 @@ __get_current_time_locale(void) { } int -__time_load_locale(const char *name, void *f_wctomb, const char *charset) { +__time_load_locale(const char *name, void *f_wctomb, int cs_idx) { int ret; #ifdef __CYGWIN__ extern int __set_lc_time_from_win (const char *, struct lc_time_T *, - char **, void *, const char *); + char **, void *, int cs_idx); int old_time_using_locale = _time_using_locale; _time_using_locale = 0; ret = __set_lc_time_from_win (name, &_time_locale, &time_locale_buf, - f_wctomb, charset); + f_wctomb, cs_idx); /* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ if (ret < 0) _time_using_locale = old_time_using_locale; Index: libc/locale/timelocal.h =================================================================== RCS file: /cvs/src/src/newlib/libc/locale/timelocal.h,v retrieving revision 1.3 diff -u -p -r1.3 timelocal.h --- libc/locale/timelocal.h 18 Feb 2010 17:35:15 -0000 1.3 +++ libc/locale/timelocal.h 29 Mar 2010 18:10:13 -0000 @@ -58,7 +58,7 @@ struct lc_time_T { }; struct lc_time_T *__get_current_time_locale(void); -int __time_load_locale(const char *, void *, const char *); +int __time_load_locale(const char *, void *, int cs_idx); __END_DECLS Index: libc/stdio/vfprintf.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdio/vfprintf.c,v retrieving revision 1.79 diff -u -p -r1.79 vfprintf.c --- libc/stdio/vfprintf.c 15 Feb 2010 16:10:28 -0000 1.79 +++ libc/stdio/vfprintf.c 29 Mar 2010 18:10:15 -0000 @@ -758,7 +758,7 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap) cp = fmt; #ifdef _MB_CAPABLE while ((n = __mbtowc (data, &wc, fmt, MB_CUR_MAX, - __locale_charset (), &state)) != 0) { + __charset_index, &state)) != 0) { if (n < 0) { /* Wave invalid chars through. */ memset (&state, 0, sizeof state); @@ -1915,7 +1915,7 @@ _DEFUN(get_arg, (data, n, fmt, ap, numar { # ifdef _MB_CAPABLE while ((nbytes = __mbtowc (data, &wc, fmt, MB_CUR_MAX, - __locale_charset (), &wc_state)) > 0) + __charset_index, &wc_state)) > 0) { fmt += nbytes; if (wc == '%') Index: libc/stdio/vfscanf.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdio/vfscanf.c,v retrieving revision 1.49 diff -u -p -r1.49 vfscanf.c --- libc/stdio/vfscanf.c 19 Jan 2010 23:16:45 -0000 1.49 +++ libc/stdio/vfscanf.c 29 Mar 2010 18:10:15 -0000 @@ -510,8 +510,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap #ifndef _MB_CAPABLE wc = *fmt; #else - nbytes = __mbtowc (rptr, &wc, fmt, MB_CUR_MAX, __locale_charset (), - &state); + nbytes = __mbtowc (rptr, &wc, fmt, MB_CUR_MAX, __charset_index, &state); if (nbytes < 0) { wc = 0xFFFD; /* Unicode replacement character */ nbytes = 1; Index: libc/stdlib/btowc.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/btowc.c,v retrieving revision 1.3 diff -u -p -r1.3 btowc.c --- libc/stdlib/btowc.c 18 Nov 2009 09:49:57 -0000 1.3 +++ libc/stdlib/btowc.c 29 Mar 2010 18:10:15 -0000 @@ -20,7 +20,7 @@ btowc (int c) _REENT_CHECK_MISC(_REENT); - retval = __mbtowc (_REENT, &pwc, &b, 1, __locale_charset (), &mbs); + retval = __mbtowc (_REENT, &pwc, &b, 1, __charset_index, &mbs); if (c == EOF || retval != 1) return WEOF; Index: libc/stdlib/local.h =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/local.h,v retrieving revision 1.8 diff -u -p -r1.8 local.h --- libc/stdlib/local.h 25 Aug 2009 18:47:24 -0000 1.8 +++ libc/stdlib/local.h 29 Mar 2010 18:10:15 -0000 @@ -5,55 +5,52 @@ char * _EXFUN(_gcvt,(struct _reent *, double , int , char *, char, int)); -char *__locale_charset(_NOARGS); +extern int __charset_index; #ifndef __mbstate_t_defined #include #endif -extern int (*__wctomb) (struct _reent *, char *, wchar_t, const char *, - mbstate_t *); -int __ascii_wctomb (struct _reent *, char *, wchar_t, const char *, - mbstate_t *); +extern int (*__wctomb) (struct _reent *, char *, wchar_t, int, mbstate_t *); +int __ascii_wctomb (struct _reent *, char *, wchar_t, int, mbstate_t *); #ifdef _MB_CAPABLE -int __utf8_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); -int __sjis_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); -int __eucjp_wctomb (struct _reent *, char *, wchar_t, const char *, - mbstate_t *); -int __jis_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); -int __iso_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); -int __cp_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); +int __utf8_wctomb (struct _reent *, char *, wchar_t, int, mbstate_t *); +int __sjis_wctomb (struct _reent *, char *, wchar_t, int, mbstate_t *); +int __eucjp_wctomb (struct _reent *, char *, wchar_t, int, mbstate_t *); +int __jis_wctomb (struct _reent *, char *, wchar_t, int, mbstate_t *); +int __iso_wctomb (struct _reent *, char *, wchar_t, int, mbstate_t *); +int __cp_wctomb (struct _reent *, char *, wchar_t, int, mbstate_t *); #ifdef __CYGWIN__ -int __gbk_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); -int __kr_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); -int __big5_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); +int __gbk_wctomb (struct _reent *, char *, wchar_t, int, mbstate_t *); +int __kr_wctomb (struct _reent *, char *, wchar_t, int, mbstate_t *); +int __big5_wctomb (struct _reent *, char *, wchar_t, int, mbstate_t *); #endif #endif extern int (*__mbtowc) (struct _reent *, wchar_t *, const char *, size_t, - const char *, mbstate_t *); + int, mbstate_t *); int __ascii_mbtowc (struct _reent *, wchar_t *, const char *, size_t, - const char *, mbstate_t *); + int, mbstate_t *); #ifdef _MB_CAPABLE int __utf8_mbtowc (struct _reent *, wchar_t *, const char *, size_t, - const char *, mbstate_t *); + int, mbstate_t *); int __sjis_mbtowc (struct _reent *, wchar_t *, const char *, size_t, - const char *, mbstate_t *); + int, mbstate_t *); int __eucjp_mbtowc (struct _reent *, wchar_t *, const char *, size_t, - const char *, mbstate_t *); + int, mbstate_t *); int __jis_mbtowc (struct _reent *, wchar_t *, const char *, size_t, - const char *, mbstate_t *); + int, mbstate_t *); int __iso_mbtowc (struct _reent *, wchar_t *, const char *, size_t, - const char *, mbstate_t *); + int, mbstate_t *); int __cp_mbtowc (struct _reent *, wchar_t *, const char *, size_t, - const char *, mbstate_t *); + int, mbstate_t *); #ifdef __CYGWIN__ int __gbk_mbtowc (struct _reent *, wchar_t *, const char *, size_t, - const char *, mbstate_t *); + int, mbstate_t *); int __kr_mbtowc (struct _reent *, wchar_t *, const char *, size_t, - const char *, mbstate_t *); + int, mbstate_t *); int __big5_mbtowc (struct _reent *, wchar_t *, const char *, size_t, - const char *, mbstate_t *); + int, mbstate_t *); #endif #endif Index: libc/stdlib/mblen.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/mblen.c,v retrieving revision 1.6 diff -u -p -r1.6 mblen.c --- libc/stdlib/mblen.c 18 Nov 2009 09:49:57 -0000 1.6 +++ libc/stdlib/mblen.c 29 Mar 2010 18:10:15 -0000 @@ -59,7 +59,7 @@ _DEFUN (mblen, (s, n), _REENT_CHECK_MISC(_REENT); state = &(_REENT_MBLEN_STATE(_REENT)); - retval = __mbtowc (_REENT, NULL, s, n, __locale_charset (), state); + retval = __mbtowc (_REENT, NULL, s, n, __charset_index, state); if (retval < 0) { state->__count = 0; Index: libc/stdlib/mblen_r.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/mblen_r.c,v retrieving revision 1.5 diff -u -p -r1.5 mblen_r.c --- libc/stdlib/mblen_r.c 18 Nov 2009 09:49:57 -0000 1.5 +++ libc/stdlib/mblen_r.c 29 Mar 2010 18:10:15 -0000 @@ -57,7 +57,7 @@ _DEFUN (_mblen_r, (r, s, n, state), { #ifdef _MB_CAPABLE int retval; - retval = __mbtowc (r, NULL, s, n, __locale_charset (), state); + retval = __mbtowc (r, NULL, s, n, __charset_index, state); if (retval < 0) { Index: libc/stdlib/mbrtowc.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/mbrtowc.c,v retrieving revision 1.6 diff -u -p -r1.6 mbrtowc.c --- libc/stdlib/mbrtowc.c 18 Nov 2009 09:49:57 -0000 1.6 +++ libc/stdlib/mbrtowc.c 29 Mar 2010 18:10:15 -0000 @@ -26,9 +26,9 @@ _DEFUN (_mbrtowc_r, (ptr, pwc, s, n, ps) #endif if (s == NULL) - retval = __mbtowc (ptr, NULL, "", 1, __locale_charset (), ps); + retval = __mbtowc (ptr, NULL, "", 1, __charset_index, ps); else - retval = __mbtowc (ptr, pwc, s, n, __locale_charset (), ps); + retval = __mbtowc (ptr, pwc, s, n, __charset_index, ps); if (retval == -1) { @@ -62,9 +62,9 @@ _DEFUN (mbrtowc, (pwc, s, n, ps), #endif if (s == NULL) - retval = __mbtowc (_REENT, NULL, "", 1, __locale_charset (), ps); + retval = __mbtowc (_REENT, NULL, "", 1, __charset_index, ps); else - retval = __mbtowc (_REENT, pwc, s, n, __locale_charset (), ps); + retval = __mbtowc (_REENT, pwc, s, n, __charset_index, ps); if (retval == -1) { Index: libc/stdlib/mbstowcs_r.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/mbstowcs_r.c,v retrieving revision 1.5 diff -u -p -r1.5 mbstowcs_r.c --- libc/stdlib/mbstowcs_r.c 18 Nov 2009 09:49:57 -0000 1.5 +++ libc/stdlib/mbstowcs_r.c 29 Mar 2010 18:10:15 -0000 @@ -18,7 +18,7 @@ _DEFUN (_mbstowcs_r, (reent, pwcs, s, n, n = (size_t) 1; /* Value doesn't matter as long as it's not 0. */ while (n > 0) { - bytes = __mbtowc (r, pwcs, t, MB_CUR_MAX, __locale_charset (), state); + bytes = __mbtowc (r, pwcs, t, MB_CUR_MAX, __charset_index, state); if (bytes < 0) { state->__count = 0; Index: libc/stdlib/mbtowc.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/mbtowc.c,v retrieving revision 1.6 diff -u -p -r1.6 mbtowc.c --- libc/stdlib/mbtowc.c 18 Nov 2009 09:49:57 -0000 1.6 +++ libc/stdlib/mbtowc.c 29 Mar 2010 18:10:16 -0000 @@ -69,7 +69,7 @@ _DEFUN (mbtowc, (pwc, s, n), _REENT_CHECK_MISC(_REENT); ps = &(_REENT_MBTOWC_STATE(_REENT)); - retval = __mbtowc (_REENT, pwc, s, n, __locale_charset (), ps); + retval = __mbtowc (_REENT, pwc, s, n, __charset_index, ps); if (retval < 0) { Index: libc/stdlib/mbtowc_r.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/mbtowc_r.c,v retrieving revision 1.20 diff -u -p -r1.20 mbtowc_r.c --- libc/stdlib/mbtowc_r.c 17 Jan 2010 09:39:06 -0000 1.20 +++ libc/stdlib/mbtowc_r.c 29 Mar 2010 18:10:16 -0000 @@ -8,7 +8,7 @@ #include "local.h" int (*__mbtowc) (struct _reent *, wchar_t *, const char *, size_t, - const char *, mbstate_t *) + int cs_idx, mbstate_t *) #ifdef __CYGWIN__ /* Cygwin starts up in UTF-8 mode. */ = __utf8_mbtowc; @@ -24,16 +24,16 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state) size_t n _AND mbstate_t *state) { - return __mbtowc (r, pwc, s, n, __locale_charset (), state); + return __mbtowc (r, pwc, s, n, __charset_index, state); } int -_DEFUN (__ascii_mbtowc, (r, pwc, s, n, charset, state), +_DEFUN (__ascii_mbtowc, (r, pwc, s, n, idx, state), struct _reent *r _AND wchar_t *pwc _AND const char *s _AND size_t n _AND - const char *charset _AND + int idx _AND mbstate_t *state) { wchar_t dummy; @@ -105,12 +105,12 @@ static JIS_ACTION JIS_action_table[JIS_S #ifdef _MB_EXTENDED_CHARSETS_ISO int -_DEFUN (__iso_mbtowc, (r, pwc, s, n, charset, state), +_DEFUN (__iso_mbtowc, (r, pwc, s, n, iso_idx, state), struct _reent *r _AND wchar_t *pwc _AND const char *s _AND size_t n _AND - const char *charset _AND + int iso_idx _AND mbstate_t *state) { wchar_t dummy; @@ -127,7 +127,6 @@ _DEFUN (__iso_mbtowc, (r, pwc, s, n, cha if (*t >= 0xa0) { - int iso_idx = __iso_8859_index (charset + 9); if (iso_idx >= 0) { *pwc = __iso_8859_conv[iso_idx][*t - 0xa0]; @@ -151,12 +150,12 @@ _DEFUN (__iso_mbtowc, (r, pwc, s, n, cha #ifdef _MB_EXTENDED_CHARSETS_WINDOWS int -_DEFUN (__cp_mbtowc, (r, pwc, s, n, charset, state), +_DEFUN (__cp_mbtowc, (r, pwc, s, n, cp_idx, state), struct _reent *r _AND wchar_t *pwc _AND const char *s _AND size_t n _AND - const char *charset _AND + int cp_idx _AND mbstate_t *state) { wchar_t dummy; @@ -173,7 +172,6 @@ _DEFUN (__cp_mbtowc, (r, pwc, s, n, char if (*t >= 0x80) { - int cp_idx = __cp_index (charset + 2); if (cp_idx >= 0) { *pwc = __cp_conv[cp_idx][*t - 0x80]; @@ -196,12 +194,12 @@ _DEFUN (__cp_mbtowc, (r, pwc, s, n, char #endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ int -_DEFUN (__utf8_mbtowc, (r, pwc, s, n, charset, state), +_DEFUN (__utf8_mbtowc, (r, pwc, s, n, idx, state), struct _reent *r _AND wchar_t *pwc _AND const char *s _AND size_t n _AND - const char *charset _AND + int idx _AND mbstate_t *state) { wchar_t dummy; @@ -399,12 +397,12 @@ _DEFUN (__utf8_mbtowc, (r, pwc, s, n, ch because the underlying OS requires wchar_t == UTF-16. */ #ifndef __CYGWIN__ int -_DEFUN (__sjis_mbtowc, (r, pwc, s, n, charset, state), +_DEFUN (__sjis_mbtowc, (r, pwc, s, n, idx, state), struct _reent *r _AND wchar_t *pwc _AND const char *s _AND size_t n _AND - const char *charset _AND + int idx _AND mbstate_t *state) { wchar_t dummy; @@ -457,12 +455,12 @@ _DEFUN (__sjis_mbtowc, (r, pwc, s, n, ch } int -_DEFUN (__eucjp_mbtowc, (r, pwc, s, n, charset, state), +_DEFUN (__eucjp_mbtowc, (r, pwc, s, n, idx, state), struct _reent *r _AND wchar_t *pwc _AND const char *s _AND size_t n _AND - const char *charset _AND + int idx _AND mbstate_t *state) { wchar_t dummy; @@ -541,12 +539,12 @@ _DEFUN (__eucjp_mbtowc, (r, pwc, s, n, c } int -_DEFUN (__jis_mbtowc, (r, pwc, s, n, charset, state), +_DEFUN (__jis_mbtowc, (r, pwc, s, n, idx, state), struct _reent *r _AND wchar_t *pwc _AND const char *s _AND size_t n _AND - const char *charset _AND + int idx _AND mbstate_t *state) { wchar_t dummy; Index: libc/stdlib/sb_charsets.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/sb_charsets.c,v retrieving revision 1.5 diff -u -p -r1.5 sb_charsets.c --- libc/stdlib/sb_charsets.c 6 Feb 2010 18:28:33 -0000 1.5 +++ libc/stdlib/sb_charsets.c 29 Mar 2010 18:10:17 -0000 @@ -2,7 +2,6 @@ #include #ifdef _MB_CAPABLE -extern char *__locale_charset (); #ifdef _MB_EXTENDED_CHARSETS_ISO /* Tables for the ISO-8859-x to UTF conversion. The first index into the Index: libc/stdlib/wcrtomb.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/wcrtomb.c,v retrieving revision 1.5 diff -u -p -r1.5 wcrtomb.c --- libc/stdlib/wcrtomb.c 18 Nov 2009 09:49:57 -0000 1.5 +++ libc/stdlib/wcrtomb.c 29 Mar 2010 18:10:17 -0000 @@ -25,9 +25,9 @@ _DEFUN (_wcrtomb_r, (ptr, s, wc, ps), #endif if (s == NULL) - retval = __wctomb (ptr, buf, L'\0', __locale_charset (), ps); + retval = __wctomb (ptr, buf, L'\0', __charset_index, ps); else - retval = __wctomb (ptr, s, wc, __locale_charset (), ps); + retval = __wctomb (ptr, s, wc, __charset_index, ps); if (retval == -1) { @@ -61,9 +61,9 @@ _DEFUN (wcrtomb, (s, wc, ps), #endif if (s == NULL) - retval = __wctomb (_REENT, buf, L'\0', __locale_charset (), ps); + retval = __wctomb (_REENT, buf, L'\0', __charset_index, ps); else - retval = __wctomb (_REENT, s, wc, __locale_charset (), ps); + retval = __wctomb (_REENT, s, wc, __charset_index, ps); if (retval == -1) { Index: libc/stdlib/wcsnrtombs.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/wcsnrtombs.c,v retrieving revision 1.2 diff -u -p -r1.2 wcsnrtombs.c --- libc/stdlib/wcsnrtombs.c 18 Nov 2009 09:49:57 -0000 1.2 +++ libc/stdlib/wcsnrtombs.c 29 Mar 2010 18:10:17 -0000 @@ -135,7 +135,7 @@ _DEFUN (_wcsnrtombs_r, (r, dst, src, nwc { int count = ps->__count; wint_t wch = ps->__value.__wch; - int bytes = __wctomb (r, buff, *pwcs, __locale_charset (), ps); + int bytes = __wctomb (r, buff, *pwcs, __charset_index, ps); if (bytes == -1) { r->_errno = EILSEQ; Index: libc/stdlib/wcstombs_r.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/wcstombs_r.c,v retrieving revision 1.5 diff -u -p -r1.5 wcstombs_r.c --- libc/stdlib/wcstombs_r.c 19 Jan 2010 21:14:53 -0000 1.5 +++ libc/stdlib/wcstombs_r.c 29 Mar 2010 18:10:17 -0000 @@ -20,7 +20,7 @@ _DEFUN (_wcstombs_r, (reent, s, pwcs, n, size_t num_bytes = 0; while (*pwcs != 0) { - bytes = __wctomb (r, buff, *pwcs++, __locale_charset (), state); + bytes = __wctomb (r, buff, *pwcs++, __charset_index, state); if (bytes == -1) return -1; num_bytes += bytes; @@ -31,7 +31,7 @@ _DEFUN (_wcstombs_r, (reent, s, pwcs, n, { while (n > 0) { - bytes = __wctomb (r, buff, *pwcs, __locale_charset (), state); + bytes = __wctomb (r, buff, *pwcs, __charset_index, state); if (bytes == -1) return -1; num_to_copy = (n > bytes ? bytes : (int)n); Index: libc/stdlib/wctob.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/wctob.c,v retrieving revision 1.4 diff -u -p -r1.4 wctob.c --- libc/stdlib/wctob.c 18 Nov 2009 09:49:57 -0000 1.4 +++ libc/stdlib/wctob.c 29 Mar 2010 18:10:17 -0000 @@ -17,7 +17,7 @@ wctob (wint_t c) _REENT_CHECK_MISC(_REENT); - retval = __wctomb (_REENT, &pwc, c, __locale_charset (), &mbs); + retval = __wctomb (_REENT, &pwc, c, __charset_index, &mbs); if (c == EOF || retval != 1) return WEOF; Index: libc/stdlib/wctomb.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/wctomb.c,v retrieving revision 1.5 diff -u -p -r1.5 wctomb.c --- libc/stdlib/wctomb.c 18 Nov 2009 09:49:57 -0000 1.5 +++ libc/stdlib/wctomb.c 29 Mar 2010 18:10:17 -0000 @@ -59,7 +59,7 @@ _DEFUN (wctomb, (s, wchar), #ifdef _MB_CAPABLE _REENT_CHECK_MISC(_REENT); - return __wctomb (_REENT, s, wchar, __locale_charset (), + return __wctomb (_REENT, s, wchar, __charset_index, &(_REENT_WCTOMB_STATE(_REENT))); #else /* not _MB_CAPABLE */ if (s == NULL) Index: libc/stdlib/wctomb_r.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/wctomb_r.c,v retrieving revision 1.18 diff -u -p -r1.18 wctomb_r.c --- libc/stdlib/wctomb_r.c 17 Jan 2010 09:39:06 -0000 1.18 +++ libc/stdlib/wctomb_r.c 29 Mar 2010 18:10:17 -0000 @@ -6,8 +6,7 @@ #include "mbctype.h" #include "local.h" -int (*__wctomb) (struct _reent *, char *, wchar_t, const char *charset, - mbstate_t *) +int (*__wctomb) (struct _reent *, char *, wchar_t, int cs_idx, mbstate_t *) #ifdef __CYGWIN__ /* Cygwin starts up in UTF-8 mode. */ = __utf8_wctomb; @@ -22,15 +21,15 @@ _DEFUN (_wctomb_r, (r, s, wchar, state), wchar_t _wchar _AND mbstate_t *state) { - return __wctomb (r, s, _wchar, __locale_charset (), state); + return __wctomb (r, s, _wchar, __charset_index, state); } int -_DEFUN (__ascii_wctomb, (r, s, wchar, charset, state), +_DEFUN (__ascii_wctomb, (r, s, wchar, idx, state), struct _reent *r _AND char *s _AND wchar_t _wchar _AND - const char *charset _AND + int idx _AND mbstate_t *state) { /* Avoids compiler warnings about comparisons that are always false @@ -60,11 +59,11 @@ _DEFUN (__ascii_wctomb, (r, s, wchar, ch #define __state __count int -_DEFUN (__utf8_wctomb, (r, s, wchar, charset, state), +_DEFUN (__utf8_wctomb, (r, s, wchar, idx, state), struct _reent *r _AND char *s _AND wchar_t _wchar _AND - const char *charset _AND + int idx _AND mbstate_t *state) { wint_t wchar = _wchar; @@ -155,11 +154,11 @@ _DEFUN (__utf8_wctomb, (r, s, wchar, cha because the underlying OS requires wchar_t == UTF-16. */ #ifndef __CYGWIN__ int -_DEFUN (__sjis_wctomb, (r, s, wchar, charset, state), +_DEFUN (__sjis_wctomb, (r, s, wchar, idx, state), struct _reent *r _AND char *s _AND wchar_t _wchar _AND - const char *charset _AND + int idx _AND mbstate_t *state) { wint_t wchar = _wchar; @@ -190,11 +189,11 @@ _DEFUN (__sjis_wctomb, (r, s, wchar, cha } int -_DEFUN (__eucjp_wctomb, (r, s, wchar, charset, state), +_DEFUN (__eucjp_wctomb, (r, s, wchar, idx, state), struct _reent *r _AND char *s _AND wchar_t _wchar _AND - const char *charset _AND + int idx _AND mbstate_t *state) { wint_t wchar = _wchar; @@ -231,11 +230,11 @@ _DEFUN (__eucjp_wctomb, (r, s, wchar, ch } int -_DEFUN (__jis_wctomb, (r, s, wchar, charset, state), +_DEFUN (__jis_wctomb, (r, s, wchar, idx, state), struct _reent *r _AND char *s _AND wchar_t _wchar _AND - const char *charset _AND + int idx _AND mbstate_t *state) { wint_t wchar = _wchar; @@ -283,11 +282,11 @@ _DEFUN (__jis_wctomb, (r, s, wchar, char #ifdef _MB_EXTENDED_CHARSETS_ISO int -_DEFUN (__iso_wctomb, (r, s, wchar, charset, state), +_DEFUN (__iso_wctomb, (r, s, wchar, iso_idx, state), struct _reent *r _AND char *s _AND wchar_t _wchar _AND - const char *charset _AND + int iso_idx _AND mbstate_t *state) { wint_t wchar = _wchar; @@ -298,7 +297,6 @@ _DEFUN (__iso_wctomb, (r, s, wchar, char /* wchars <= 0x9f translate to all ISO charsets directly. */ if (wchar >= 0xa0) { - int iso_idx = __iso_8859_index (charset + 9); if (iso_idx >= 0) { unsigned char mb; @@ -330,11 +328,11 @@ _DEFUN (__iso_wctomb, (r, s, wchar, char #ifdef _MB_EXTENDED_CHARSETS_WINDOWS int -_DEFUN (__cp_wctomb, (r, s, wchar, charset, state), +_DEFUN (__cp_wctomb, (r, s, wchar, cp_idx, state), struct _reent *r _AND char *s _AND wchar_t _wchar _AND - const char *charset _AND + int cp_idx _AND mbstate_t *state) { wint_t wchar = _wchar; @@ -344,7 +342,6 @@ _DEFUN (__cp_wctomb, (r, s, wchar, chars if (wchar >= 0x80) { - int cp_idx = __cp_index (charset + 2); if (cp_idx >= 0) { unsigned char mb;