* libc/locale/locale.c (loadlocale): Only change __wctomb and __mbtowc

pointers if category is LC_CTYPE.
This commit is contained in:
Corinna Vinschen 2009-03-25 13:52:08 +00:00
parent 5354e13fe6
commit 6396c8889f
2 changed files with 36 additions and 24 deletions

View File

@ -1,3 +1,8 @@
2009-03-25 Corinna Vinschen <corinna@vinschen.de>
* libc/locale/locale.c (loadlocale): Only change __wctomb and __mbtowc
pointers if category is LC_CTYPE.
2009-03-25 Corinna Vinschen <corinna@vinschen.de> 2009-03-25 Corinna Vinschen <corinna@vinschen.de>
* libc/locale/locale.c (loadlocale): Rename charset "GBK" to * libc/locale/locale.c (loadlocale): Rename charset "GBK" to

View File

@ -396,6 +396,9 @@ loadlocale(struct _reent *p, int category)
unsigned long val; unsigned long val;
char *end; char *end;
int mbc_max; int mbc_max;
int (*l_wctomb) (struct _reent *, char *, wchar_t, const char *, mbstate_t *);
int (*l_mbtowc) (struct _reent *, wchar_t *, const char *, size_t,
const char *, mbstate_t *);
/* "POSIX" is translated to "C", as on Linux. */ /* "POSIX" is translated to "C", as on Linux. */
if (!strcmp (locale, "POSIX")) if (!strcmp (locale, "POSIX"))
@ -450,8 +453,8 @@ loadlocale(struct _reent *p, int category)
return NULL; return NULL;
mbc_max = 6; mbc_max = 6;
#ifdef _MB_CAPABLE #ifdef _MB_CAPABLE
__wctomb = __utf8_wctomb; l_wctomb = __utf8_wctomb;
__mbtowc = __utf8_mbtowc; l_mbtowc = __utf8_mbtowc;
#endif #endif
break; break;
case 'J': case 'J':
@ -459,8 +462,8 @@ loadlocale(struct _reent *p, int category)
return NULL; return NULL;
mbc_max = 8; mbc_max = 8;
#ifdef _MB_CAPABLE #ifdef _MB_CAPABLE
__wctomb = __jis_wctomb; l_wctomb = __jis_wctomb;
__mbtowc = __jis_mbtowc; l_mbtowc = __jis_mbtowc;
#endif #endif
break; break;
case 'E': case 'E':
@ -470,8 +473,8 @@ loadlocale(struct _reent *p, int category)
strcpy (charset, "EUCJP"); strcpy (charset, "EUCJP");
mbc_max = 2; mbc_max = 2;
#ifdef _MB_CAPABLE #ifdef _MB_CAPABLE
__wctomb = __eucjp_wctomb; l_wctomb = __eucjp_wctomb;
__mbtowc = __eucjp_mbtowc; l_mbtowc = __eucjp_mbtowc;
#endif #endif
} }
#ifdef __CYGWIN__ #ifdef __CYGWIN__
@ -480,8 +483,8 @@ loadlocale(struct _reent *p, int category)
strcpy (charset, "EUCKR"); strcpy (charset, "EUCKR");
mbc_max = 2; mbc_max = 2;
#ifdef _MB_CAPABLE #ifdef _MB_CAPABLE
__wctomb = __kr_wctomb; l_wctomb = __kr_wctomb;
__mbtowc = __kr_mbtowc; l_mbtowc = __kr_mbtowc;
#endif #endif
} }
#endif #endif
@ -493,8 +496,8 @@ loadlocale(struct _reent *p, int category)
return NULL; return NULL;
mbc_max = 2; mbc_max = 2;
#ifdef _MB_CAPABLE #ifdef _MB_CAPABLE
__wctomb = __sjis_wctomb; l_wctomb = __sjis_wctomb;
__mbtowc = __sjis_mbtowc; l_mbtowc = __sjis_mbtowc;
#endif #endif
break; break;
case 'I': case 'I':
@ -508,11 +511,11 @@ loadlocale(struct _reent *p, int category)
mbc_max = 1; mbc_max = 1;
#ifdef _MB_CAPABLE #ifdef _MB_CAPABLE
#ifdef _MB_EXTENDED_CHARSETS_ISO #ifdef _MB_EXTENDED_CHARSETS_ISO
__wctomb = __iso_wctomb; l_wctomb = __iso_wctomb;
__mbtowc = __iso_mbtowc; l_mbtowc = __iso_mbtowc;
#else /* !_MB_EXTENDED_CHARSETS_ISO */ #else /* !_MB_EXTENDED_CHARSETS_ISO */
__wctomb = __ascii_wctomb; l_wctomb = __ascii_wctomb;
__mbtowc = __ascii_mbtowc; l_mbtowc = __ascii_mbtowc;
#endif /* _MB_EXTENDED_CHARSETS_ISO */ #endif /* _MB_EXTENDED_CHARSETS_ISO */
#endif #endif
break; break;
@ -549,11 +552,11 @@ loadlocale(struct _reent *p, int category)
mbc_max = 1; mbc_max = 1;
#ifdef _MB_CAPABLE #ifdef _MB_CAPABLE
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS #ifdef _MB_EXTENDED_CHARSETS_WINDOWS
__wctomb = __cp_wctomb; l_wctomb = __cp_wctomb;
__mbtowc = __cp_mbtowc; l_mbtowc = __cp_mbtowc;
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ #else /* !_MB_EXTENDED_CHARSETS_WINDOWS */
__wctomb = __ascii_wctomb; l_wctomb = __ascii_wctomb;
__mbtowc = __ascii_mbtowc; l_mbtowc = __ascii_mbtowc;
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ #endif /* _MB_EXTENDED_CHARSETS_WINDOWS */
#endif #endif
break; break;
@ -566,8 +569,8 @@ loadlocale(struct _reent *p, int category)
return NULL; return NULL;
mbc_max = 1; mbc_max = 1;
#ifdef _MB_CAPABLE #ifdef _MB_CAPABLE
__wctomb = __ascii_wctomb; l_wctomb = __ascii_wctomb;
__mbtowc = __ascii_mbtowc; l_mbtowc = __ascii_mbtowc;
#endif #endif
break; break;
#ifdef __CYGWIN__ #ifdef __CYGWIN__
@ -576,8 +579,8 @@ loadlocale(struct _reent *p, int category)
return NULL; return NULL;
mbc_max = 2; mbc_max = 2;
#ifdef _MB_CAPABLE #ifdef _MB_CAPABLE
__wctomb = __gbk_wctomb; l_wctomb = __gbk_wctomb;
__mbtowc = __gbk_mbtowc; l_mbtowc = __gbk_mbtowc;
#endif #endif
break; break;
case 'B': case 'B':
@ -586,8 +589,8 @@ loadlocale(struct _reent *p, int category)
strcpy (charset, "BIG5"); strcpy (charset, "BIG5");
mbc_max = 2; mbc_max = 2;
#ifdef _MB_CAPABLE #ifdef _MB_CAPABLE
__wctomb = __big5_wctomb; l_wctomb = __big5_wctomb;
__mbtowc = __big5_mbtowc; l_mbtowc = __big5_mbtowc;
#endif #endif
break; break;
#endif /* __CYGWIN__ */ #endif /* __CYGWIN__ */
@ -598,8 +601,12 @@ loadlocale(struct _reent *p, int category)
{ {
strcpy (lc_ctype_charset, charset); strcpy (lc_ctype_charset, charset);
__mb_cur_max = mbc_max; __mb_cur_max = mbc_max;
#ifdef _MB_CAPABLE
__wctomb = l_wctomb;
__mbtowc = l_mbtowc;
#ifdef __CYGWIN__ #ifdef __CYGWIN__
__set_ctype (charset); __set_ctype (charset);
#endif
#endif #endif
} }
else if (category == LC_MESSAGES) else if (category == LC_MESSAGES)