Revision: 5166 http://geany.svn.sourceforge.net/geany/?rev=5166&view=rev Author: ntrel Date: 2010-08-16 11:47:50 +0000 (Mon, 16 Aug 2010)
Log Message: ----------- r5163 | eht16 | 2010-08-15 14:33:32 +0100 (Sun, 15 Aug 2010) | 1 line
Rewrite the logic to auto detect encodings a bit to make it more readable and fix a slightly wrong detection on Windows (closes #3019573).
Modified Paths: -------------- branches/Geany-0_19_1/ChangeLog branches/Geany-0_19_1/NEWS branches/Geany-0_19_1/src/encodings.c
Modified: branches/Geany-0_19_1/ChangeLog =================================================================== --- branches/Geany-0_19_1/ChangeLog 2010-08-16 11:22:45 UTC (rev 5165) +++ branches/Geany-0_19_1/ChangeLog 2010-08-16 11:47:50 UTC (rev 5166) @@ -2,6 +2,10 @@
* wscript: Check for libsocket on OpenSolaris to fix build. + * src/encodings.c: + Rewrite the logic to auto detect encodings a bit to make it more + readable and fix a slightly wrong detection on Windows + (closes #3019573).
2010-08-13 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: branches/Geany-0_19_1/NEWS =================================================================== --- branches/Geany-0_19_1/NEWS 2010-08-16 11:22:45 UTC (rev 5165) +++ branches/Geany-0_19_1/NEWS 2010-08-16 11:47:50 UTC (rev 5166) @@ -6,6 +6,7 @@ and switching document tabs). * Fix using filetype extension patterns with upper case letters on Windows (#3028856). + * Fix a slightly wrong encoding detection on Windows (#3019573). * Re-enable comment folding. * Fix not loading plugins built against a newer API when Geany doesn't provide the required version given in PLUGIN_VERSION_CHECK().
Modified: branches/Geany-0_19_1/src/encodings.c =================================================================== --- branches/Geany-0_19_1/src/encodings.c 2010-08-16 11:22:45 UTC (rev 5165) +++ branches/Geany-0_19_1/src/encodings.c 2010-08-16 11:47:50 UTC (rev 5166) @@ -563,34 +563,38 @@ if (G_UNLIKELY(i == encodings[GEANY_ENCODING_NONE].idx)) continue;
- if (i == -1) + if (check_regex) { - if (preferred_charset != -1) - { - charset = encodings[preferred_charset].charset; - geany_debug("Using preferred charset: %s", charset); - } - else - continue; - } - else if (check_regex) - { check_regex = FALSE; charset = regex_charset; + i = -2; /* keep i below the start value to have it again at -1 on the next loop run */ } else if (check_locale) { check_locale = FALSE; charset = locale_charset; + i = -2; /* keep i below the start value to have it again at -1 on the next loop run */ } - else + else if (i == -1) + { + if (preferred_charset >= 0) + { + charset = encodings[preferred_charset].charset; + geany_debug("Using preferred charset: %s", charset); + } + else + continue; + } + else if (i >= 0) charset = encodings[i].charset; + else /* in this case we have i == -2, continue to increase i and go ahead */ + continue;
- if (G_UNLIKELY(charset == NULL)) continue;
- geany_debug("Trying to convert %" G_GSIZE_FORMAT " bytes of data from %s into UTF-8.", size, charset); + geany_debug("Trying to convert %" G_GSIZE_FORMAT " bytes of data from %s into UTF-8.", + size, charset); utf8_content = encodings_convert_to_utf8_from_charset(buffer, size, charset, FALSE);
if (G_LIKELY(utf8_content != NULL))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.