Commit f96942ab authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Fix many warnings

parent b6d0e5a0
...@@ -124,7 +124,7 @@ static const char* vlc_charset_aliases( const char *psz_name ) ...@@ -124,7 +124,7 @@ static const char* vlc_charset_aliases( const char *psz_name )
{ "CP28605", "ISO-8859-15" }, { "CP28605", "ISO-8859-15" },
{ NULL, NULL } { NULL, NULL }
}; };
#elif SYS_AIX #elif defined (SYS_AIX)
VLCCharsetAlias aliases[] = VLCCharsetAlias aliases[] =
{ {
{ "IBM-850", "CP850" }, { "IBM-850", "CP850" },
...@@ -143,7 +143,7 @@ static const char* vlc_charset_aliases( const char *psz_name ) ...@@ -143,7 +143,7 @@ static const char* vlc_charset_aliases( const char *psz_name )
{ "IBM-EUCTW", "EUC-TW" }, { "IBM-EUCTW", "EUC-TW" },
{ NULL, NULL } { NULL, NULL }
}; };
#elif SYS_HPUX #elif defined (SYS_HPUX)
VLCCharsetAlias aliases[] = VLCCharsetAlias aliases[] =
{ {
{ "ROMAN8", "HP-ROMAN8" }, { "ROMAN8", "HP-ROMAN8" },
...@@ -155,13 +155,13 @@ static const char* vlc_charset_aliases( const char *psz_name ) ...@@ -155,13 +155,13 @@ static const char* vlc_charset_aliases( const char *psz_name )
{ "HP15CN", "GB2312" }, { "HP15CN", "GB2312" },
{ NULL, NULL } { NULL, NULL }
}; };
#elif SYS_IRIX #elif defined (SYS_IRIX)
VLCCharsetAlias aliases[] = VLCCharsetAlias aliases[] =
{ {
{ "EUCCN", "GB2312" }, { "EUCCN", "GB2312" },
{ NULL, NULL } { NULL, NULL }
}; };
#elif SYS_OSF #elif defined (SYS_OSF)
VLCCharsetAlias aliases[] = VLCCharsetAlias aliases[] =
{ {
{ "KSC5601", "CP949" }, { "KSC5601", "CP949" },
...@@ -169,7 +169,7 @@ static const char* vlc_charset_aliases( const char *psz_name ) ...@@ -169,7 +169,7 @@ static const char* vlc_charset_aliases( const char *psz_name )
{ "TACTIS", "TIS-620" }, { "TACTIS", "TIS-620" },
{ NULL, NULL } { NULL, NULL }
}; };
#elif SYS_SOLARIS #elif defined (SYS_SOLARIS)
VLCCharsetAlias aliases[] = VLCCharsetAlias aliases[] =
{ {
{ "646", "ASCII" }, { "646", "ASCII" },
...@@ -180,7 +180,7 @@ static const char* vlc_charset_aliases( const char *psz_name ) ...@@ -180,7 +180,7 @@ static const char* vlc_charset_aliases( const char *psz_name )
{ "2533", "TIS-620" }, { "2533", "TIS-620" },
{ NULL, NULL } { NULL, NULL }
}; };
#elif SYS_BSD #elif defined (SYS_BSD)
VLCCharsetAlias aliases[] = VLCCharsetAlias aliases[] =
{ {
{ "646", " ASCII" }, { "646", " ASCII" },
...@@ -375,176 +375,136 @@ char *__vlc_fix_readdir_charset( vlc_object_t *p_this, const char *psz_string ) ...@@ -375,176 +375,136 @@ char *__vlc_fix_readdir_charset( vlc_object_t *p_this, const char *psz_string )
return strdup( psz_string ); return strdup( psz_string );
} }
static inline int locale_match (const char *tab, const char *locale)
{
for (;*tab; tab += 2)
if (memcmp (tab, locale, 2) == 0)
return 0;
return 1;
}
/** /**
* @return a fallback characters encoding to be used, given a locale. * @return a fallback characters encoding to be used, given a locale.
*/ */
const char *FindFallbackEncoding( const char *locale ) static const char *FindFallbackEncoding (const char *locale)
{ {
if( ( locale == NULL ) || ( strlen( locale ) < 2 ) ) if ((locale == NULL) || (strlen (locale) < 2))
return "ASCII"; return "ASCII";
switch( U16_AT( locale ) )
{
/*** The ISO-8859 series (anything but Asia) ***/ /*** The ISO-8859 series (anything but Asia) ***/
/* Latin-1 Western-European languages (ISO-8859-1) */ // Latin-1 Western-European languages (ISO-8859-1)
case 'aa': static const char western[] =
case 'af': "aa" "af" "an" "br" "ca" "da" "de" "en" "es" "et" "eu" "fi" "fo" "fr"
case 'an': "ga" "gd" "gl" "gv" "id" "is" "it" "kl" "kw" "mg" "ms" "nb" "nl" "nn"
case 'br': "no" "oc" "om" "pt" "so" "sq" "st" "sv" "tl" "uz" "wa" "xh" "zu"
case 'ca': "eo" "mt" "cy";
case 'da': if (!locale_match (western, locale))
case 'de': return "CP1252"; // Compatible Microsoft superset
case 'en':
case 'es': // Latin-2 Slavic languages (ISO-8859-2)
case 'et': static const char slavic[] = "bs" "cs" "hr" "hu" "pl" "ro" "sk" "sl";
case 'eu': if (!locale_match (slavic, locale))
case 'fi': return "CP1250"; // CP1250 is more common, but incompatible
case 'fo':
case 'fr': // Latin-3 Southern European languages (ISO-8859-3)
case 'ga': // "eo" and "mt" -> Latin-1 instead, I presume(?).
case 'gd': // "tr" -> ISO-8859-9 instead
case 'gl':
case 'gv': // Latin-4 North-European languages (ISO-8859-4)
case 'id': // -> Latin-1 instead
case 'is':
case 'it':
case 'kl':
case 'kw':
case 'mg':
case 'ms':
case 'nb':
case 'nl':
case 'nn':
case 'no':
case 'oc':
case 'om':
case 'pt':
case 'so':
case 'sq':
case 'st':
case 'sv':
case 'tl':
case 'uz':
case 'wa':
case 'xh':
case 'zu':
/* Compatible Microsoft superset */
return "CP1252";
/* Latin-2 Slavic languages (ISO-8859-2) */
case 'bs':
case 'cs':
case 'hr':
case 'hu':
case 'pl':
case 'ro':
case 'sk':
case 'sl':
/* CP1250 is more common, but incompatible */
return "CP1250";
/* Latin-3 Southern European languages (ISO-8859-3) */
case 'eo':
case 'mt':
/*case 'tr': Turkish uses ISO-8859-9 instead */
return "ISO-8859-3";
/* Latin-4 North-European languages (ISO-8859-4) */
/* All use Latin-1 or Latin-6 instead */
/* Cyrillic alphabet languages (ISO-8859-5) */ /* Cyrillic alphabet languages (ISO-8859-5) */
case 'be': static const char cyrillic[] = "be" "bg" "mk" "ru" "sr";
case 'bg': if (!locale_match (cyrillic, locale))
case 'mk': return "CP1251"; // KOI8, ISO-8859-5 and CP1251 are incompatible(?)
case 'ru':
case 'sr':
/* KOI8, ISO-8859-5 and CP1251 are supposedly incompatible */
return "CP1251";
/* Arabic (ISO-8859-6) */ /* Arabic (ISO-8859-6) */
case 'ar': if (!locale_match ("ar", locale))
/* FIXME: someone check if we should return CP1256 // FIXME: someone check if we should return CP1256 or ISO-8859-6
* or ISO-8859-6 */ return "CP1256"; // CP1256 is(?) more common, but incompatible(?)
/* CP1256 is(?) more common, but incompatible(?) */
return "CP1256";
/* Greek (ISO-8859-7) */ /* Greek (ISO-8859-7) */
case 'el': if (!locale_match ("el", locale))
/* FIXME: someone check if we should return CP1253 // FIXME: someone check if we should return CP1253 or ISO-8859-7
* or ISO-8859-7 */ return "CP1253"; // CP1253 is(?) more common and less incompatible
/* CP1253 is(?) more common and partially compatible */
return "CP1253";
/* Hebrew (ISO-8859-8) */ /* Hebrew (ISO-8859-8) */
case 'he': if (!locale_match ("he" "iw" "yi", locale))
case 'iw': return "CP1255"; // Compatible Microsoft superset
case 'yi':
/* Compatible Microsoft superset */
return "CP1255";
/* Latin-5 Turkish (ISO-8859-9) */ /* Latin-5 Turkish (ISO-8859-9) */
case 'tr': if (!locale_match ("tr" "ku", locale))
case 'ku': return "CP1254"; // Compatible Microsoft superset
/* Compatible Microsoft superset */
return "CP1254";
/* Latin-6 “North-European” languages (ISO-8859-10) */ /* Latin-6 “North-European” languages (ISO-8859-10) */
/* It is so much north European that glibc only uses that for Luganda /* It is so much north European that glibc only uses that for Luganda
* which is spoken in Uganda... unless someone complains, I'm not * which is spoken in Uganda... unless someone complains, I'm not
* using this one; let's fallback to CP1252 here. */ * using this one; let's fallback to CP1252 here. */
/* ISO-8859-11 does arguably not exist. Thai is handled below. */
/* ISO-8859-12 really doesn't exist. */ // ISO-8859-11 does arguably not exist. Thai is handled below.
/* Latin-7 Baltic languages (ISO-8859-13) */ // ISO-8859-12 really doesn't exist.
case 'lt':
case 'lv': // Latin-7 Baltic languages (ISO-8859-13)
case 'mi': /* FIXME: ??? that's in New Zealand, doesn't sound baltic */ if (!locale_match ("lt" "lv" "mi", locale))
/* Compatible Microsoft superset */ // FIXME: mi = New Zealand, doesn't sound baltic!
return "CP1257"; return "CP1257"; // Compatible Microsoft superset
/* Latin-8 Celtic languages (ISO-8859-14) */ // Latin-8 Celtic languages (ISO-8859-14)
case 'cy': // "cy" -> use Latin-1 instead (most likely English or French)
return "ISO-8859-14";
// Latin-9 (ISO-8859-15) -> see Latin-1
/* Latin-9 (ISO-8859-15) -> see Latin-1 */
/* Latin-10 (ISO-8859-16) does not seem to be used */ // Latin-10 (ISO-8859-16) does not seem to be used
/* KOI series */ /*** KOI series ***/
/* For Russian, we use CP1251 */ // For Russian, we use CP1251
case 'uk': if (!locale_match ("uk", locale))
return "KOI8-U"; return "KOI8-U";
case 'tg':
if (!locale_match ("tg", locale))
return "KOI8-T"; return "KOI8-T";
/*** Asia ***/ /*** Asia ***/
case 'jp': /* Japanese */ // Japanese
/* Shift-JIS is way more common than EUC-JP */ if (!locale_match ("jp", locale))
return "SHIFT-JIS"; return "SHIFT-JIS"; // Shift-JIS is way more common than EUC-JP
case 'ko': /* Korean */
// Korean
if (!locale_match ("ko", locale))
return "EUC-KR"; return "EUC-KR";
case 'th': /* Thai */
// Thai
if (!locale_match ("th", locale))
return "TIS-620"; return "TIS-620";
case 'vt': /* Vietnamese FIXME: infos needed */
// Vietnamese (FIXME: more infos needed)
if (!locale_match ("vt", locale))
/* VISCII is probably a bad idea as it is not extended ASCII */ /* VISCII is probably a bad idea as it is not extended ASCII */
/* glibc has TCVN5712-1, but I could find no infos on this one */ /* glibc has TCVN5712-1 */
return "CP1258"; return "CP1258";
case 'kk': /* Kazakh FIXME: infos needed */ /* Kazakh (FIXME: more infos needed) */
if (!locale_match ("kk", locale))
return "PT154"; return "PT154";
case 'zh': /* Chinese, charset is country dependant */ // Chinese. The politically incompatible character sets.
if( ( strlen( locale ) >= 5 ) && ( locale[2] != '_' ) ) if (!locale_match ("zh", locale))
switch( U16_AT( locale + 3 ) )
{ {
case 'HK': /* Hong Kong */ if ((strlen (locale) >= 5) && (locale[2] != '_'))
/* FIXME: use something else? */ locale += 3;
return "BIG5-HKSCS";
// Hong Kong
if (!locale_match ("HK", locale))
return "BIG5-HKSCS"; /* FIXME: use something else? */
case 'TW': /* Taiwan */ // Taiwan island
if (!locale_match ("TW", locale))
return "BIG5"; return "BIG5";
}
/* People's Republic of China */ // People's Republic of China and Singapore
/* Singapore */
/* /*
* GB18030 can represent any Unicode code point * GB18030 can represent any Unicode code point
* (like UTF-8), while remaining compatible with GBK * (like UTF-8), while remaining compatible with GBK
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment