* libc/locale/locale.c (loadlocale): Throughout check charset string
case insensitive and store internal charset string uppercased. Allow "UTF8" additionally to "UTF-8". Add this change to documentation.
This commit is contained in:
parent
3584ff9cb2
commit
24149e4aa9
|
@ -1,3 +1,9 @@
|
||||||
|
2009-08-21 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* libc/locale/locale.c (loadlocale): Throughout check charset string
|
||||||
|
case insensitive and store internal charset string uppercased. Allow
|
||||||
|
"UTF8" additionally to "UTF-8". Add this change to documentation.
|
||||||
|
|
||||||
2009-08-21 Eric Blake <ebb9@byu.net>
|
2009-08-21 Eric Blake <ebb9@byu.net>
|
||||||
|
|
||||||
* libc/include/iconv.h (iconv): Match POSIX prototype.
|
* libc/include/iconv.h (iconv): Match POSIX prototype.
|
||||||
|
|
|
@ -65,7 +65,10 @@ Even when using POSIX locale strings, the only charsets allowed are
|
||||||
<<"UTF-8">>, <<"JIS">>, <<"EUCJP">>/<<"eucJP">>, <<"SJIS">>, <<"ISO-8859-x">>
|
<<"UTF-8">>, <<"JIS">>, <<"EUCJP">>/<<"eucJP">>, <<"SJIS">>, <<"ISO-8859-x">>
|
||||||
with 1 <= x <= 15, or <<"CPxxx">> with xxx in [437, 720, 737, 775, 850,
|
with 1 <= x <= 15, or <<"CPxxx">> with xxx in [437, 720, 737, 775, 850,
|
||||||
852, 855, 857, 858, 862, 866, 874, 1125, 1250, 1251, 1252, 1253, 1254,
|
852, 855, 857, 858, 862, 866, 874, 1125, 1250, 1251, 1252, 1253, 1254,
|
||||||
1255, 1256, 1257, 1258].
|
1255, 1256, 1257, 1258]. Charsets are case insensitive. For instance,
|
||||||
|
<<"UTF-8">> and <<"utf-8">> are equivalent. <<"UTF-8">> can also be
|
||||||
|
written without dash, as in <<"UTF8">> or <<"utf8">>.
|
||||||
|
|
||||||
(<<"">> is also accepted; if given, the settings are read from the
|
(<<"">> is also accepted; if given, the settings are read from the
|
||||||
corresponding LC_* environment variables and $LANG according to POSIX rules.
|
corresponding LC_* environment variables and $LANG according to POSIX rules.
|
||||||
|
|
||||||
|
@ -487,8 +490,10 @@ loadlocale(struct _reent *p, int category)
|
||||||
switch (charset[0])
|
switch (charset[0])
|
||||||
{
|
{
|
||||||
case 'U':
|
case 'U':
|
||||||
if (strcmp (charset, "UTF-8"))
|
case 'u':
|
||||||
|
if (strcasecmp (charset, "UTF-8") && strcasecmp (charset, "UTF8"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
strcpy (charset, "UTF-8");
|
||||||
mbc_max = 6;
|
mbc_max = 6;
|
||||||
#ifdef _MB_CAPABLE
|
#ifdef _MB_CAPABLE
|
||||||
l_wctomb = __utf8_wctomb;
|
l_wctomb = __utf8_wctomb;
|
||||||
|
@ -496,8 +501,10 @@ loadlocale(struct _reent *p, int category)
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 'J':
|
case 'J':
|
||||||
if (strcmp (charset, "JIS"))
|
case 'j':
|
||||||
|
if (strcasecmp (charset, "JIS"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
strcpy (charset, "JIS");
|
||||||
mbc_max = 8;
|
mbc_max = 8;
|
||||||
#ifdef _MB_CAPABLE
|
#ifdef _MB_CAPABLE
|
||||||
l_wctomb = __jis_wctomb;
|
l_wctomb = __jis_wctomb;
|
||||||
|
@ -506,7 +513,7 @@ loadlocale(struct _reent *p, int category)
|
||||||
break;
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
case 'e':
|
case 'e':
|
||||||
if (!strcmp (charset, "EUCJP") || !strcmp (charset, "eucJP"))
|
if (!strcasecmp (charset, "EUCJP"))
|
||||||
{
|
{
|
||||||
strcpy (charset, "EUCJP");
|
strcpy (charset, "EUCJP");
|
||||||
mbc_max = 3;
|
mbc_max = 3;
|
||||||
|
@ -516,7 +523,7 @@ loadlocale(struct _reent *p, int category)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
else if (!strcmp (charset, "EUCKR") || !strcmp (charset, "eucKR"))
|
else if (!strcasecmp (charset, "EUCKR"))
|
||||||
{
|
{
|
||||||
strcpy (charset, "EUCKR");
|
strcpy (charset, "EUCKR");
|
||||||
mbc_max = 2;
|
mbc_max = 2;
|
||||||
|
@ -530,8 +537,10 @@ loadlocale(struct _reent *p, int category)
|
||||||
return NULL;
|
return NULL;
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
if (strcmp (charset, "SJIS"))
|
case 's':
|
||||||
|
if (strcasecmp (charset, "SJIS"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
strcpy (charset, "SJIS");
|
||||||
mbc_max = 2;
|
mbc_max = 2;
|
||||||
#ifdef _MB_CAPABLE
|
#ifdef _MB_CAPABLE
|
||||||
l_wctomb = __sjis_wctomb;
|
l_wctomb = __sjis_wctomb;
|
||||||
|
@ -539,10 +548,12 @@ loadlocale(struct _reent *p, int category)
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
|
case 'i':
|
||||||
/* Must be exactly one of ISO-8859-1, [...] ISO-8859-16, except for
|
/* Must be exactly one of ISO-8859-1, [...] ISO-8859-16, except for
|
||||||
ISO-8859-12. */
|
ISO-8859-12. */
|
||||||
if (strncmp (charset, "ISO-8859-", 9))
|
if (strncasecmp (charset, "ISO-8859-", 9))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
strncpy (charset, "ISO", 3);
|
||||||
val = _strtol_r (p, charset + 9, &end, 10);
|
val = _strtol_r (p, charset + 9, &end, 10);
|
||||||
if (val < 1 || val > 16 || val == 12 || *end)
|
if (val < 1 || val > 16 || val == 12 || *end)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -558,8 +569,10 @@ loadlocale(struct _reent *p, int category)
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
if (charset[1] != 'P')
|
case 'c':
|
||||||
|
if (charset[1] != 'P' && charset[1] != 'p')
|
||||||
return NULL;
|
return NULL;
|
||||||
|
strncpy (charset, "CP", 2);
|
||||||
val = _strtol_r (p, charset + 2, &end, 10);
|
val = _strtol_r (p, charset + 2, &end, 10);
|
||||||
if (*end)
|
if (*end)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -603,8 +616,10 @@ loadlocale(struct _reent *p, int category)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'A':
|
case 'A':
|
||||||
if (strcmp (charset, "ASCII"))
|
case 'a':
|
||||||
|
if (strcasecmp (charset, "ASCII"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
strcpy (charset, "ASCII");
|
||||||
mbc_max = 1;
|
mbc_max = 1;
|
||||||
#ifdef _MB_CAPABLE
|
#ifdef _MB_CAPABLE
|
||||||
l_wctomb = __ascii_wctomb;
|
l_wctomb = __ascii_wctomb;
|
||||||
|
@ -613,8 +628,10 @@ loadlocale(struct _reent *p, int category)
|
||||||
break;
|
break;
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
case 'G':
|
case 'G':
|
||||||
if (strcmp (charset, "GBK"))
|
case 'g':
|
||||||
|
if (strcasecmp (charset, "GBK"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
strcpy (charset, "GBK");
|
||||||
mbc_max = 2;
|
mbc_max = 2;
|
||||||
#ifdef _MB_CAPABLE
|
#ifdef _MB_CAPABLE
|
||||||
l_wctomb = __gbk_wctomb;
|
l_wctomb = __gbk_wctomb;
|
||||||
|
@ -622,7 +639,8 @@ loadlocale(struct _reent *p, int category)
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
if (strcmp (charset, "BIG5") && strcmp (charset, "Big5"))
|
case 'b':
|
||||||
|
if (strcasecmp (charset, "BIG5"))
|
||||||
return NULL;
|
return NULL;
|
||||||
strcpy (charset, "BIG5");
|
strcpy (charset, "BIG5");
|
||||||
mbc_max = 2;
|
mbc_max = 2;
|
||||||
|
|
Loading…
Reference in New Issue