# HG changeset patch # User iive # Date 1193586788 0 # Node ID 35902b7349518e2413f6c33ab4daea2574397ea6 # Parent e36efda34616586c6311f9a996fda2c3a9e1b898 Cleanup guess_buffer_cp() a bit, remove tmp variable, break the loop on success. Requested by ulion. diff -r e36efda34616 -r 35902b734951 subreader.c --- a/subreader.c Sun Oct 28 14:26:05 2007 +0000 +++ b/subreader.c Sun Oct 28 15:53:08 2007 +0000 @@ -1287,17 +1287,14 @@ 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; } - enca_analyser_free(analyser); } free(languages); @@ -1305,6 +1302,8 @@ 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;