Cleanup guess_buffer_cp() a bit, remove tmp variable, break the loop on success.

Requested by ulion.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24880 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
iive 2007-10-28 15:53:08 +00:00
parent b43c16f8b6
commit b69670151c
1 changed files with 6 additions and 7 deletions

View File

@ -1287,17 +1287,14 @@ const char* guess_buffer_cp(unsigned char* buffer, int buflen, char *preferred_
mp_msg(MSGT_SUBREADER, MSGL_V, "\n");
for (i = 0; i < langcnt; i++) {
const char *tmp;
if (strcasecmp(languages[i], preferred_language) != 0) continue;
analyser = enca_analyser_alloc(languages[i]);
encoding = enca_analyse_const(analyser, buffer, buflen);
tmp = enca_charset_name(encoding.charset, ENCA_NAME_STYLE_ICONV);
if (tmp && encoding.charset != ENCA_CS_UNKNOWN) {
detected_sub_cp = tmp;
mp_msg(MSGT_SUBREADER, MSGL_INFO, "ENCA detected charset: %s\n", tmp);
}
enca_analyser_free(analyser);
if (encoding.charset != ENCA_CS_UNKNOWN) {
detected_sub_cp = enca_charset_name(encoding.charset, ENCA_NAME_STYLE_ICONV);
break;
}
}
free(languages);
@ -1305,6 +1302,8 @@ const char* guess_buffer_cp(unsigned char* buffer, int buflen, char *preferred_
if (!detected_sub_cp) {
detected_sub_cp = fallback;
mp_msg(MSGT_SUBREADER, MSGL_INFO, "ENCA detection failed: fallback to %s\n", fallback);
}else{
mp_msg(MSGT_SUBREADER, MSGL_INFO, "ENCA detected charset: %s\n", detected_sub_cp);
}
return detected_sub_cp;