From 9ca82f02f8fcbf01327b55843ce0f8ad9b0d5ca8 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Thu, 13 Jul 2017 14:50:27 +0200 Subject: [PATCH] Decomposition (inverse-translation) fixed --- ZRCola/zrcolacomppnl.cpp | 4 ++-- lib/libZRCola/src/translate.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ZRCola/zrcolacomppnl.cpp b/ZRCola/zrcolacomppnl.cpp index d8db033..e856bf1 100644 --- a/ZRCola/zrcolacomppnl.cpp +++ b/ZRCola/zrcolacomppnl.cpp @@ -141,8 +141,8 @@ void wxZRColaComposerPanel::SynchronizePanels() GetTranslationSeq(sets_begin, sets_end); m_mapping.clear(); - for (auto s = sets_end; s != sets_begin; s--) { - if (*s) { + for (auto s = sets_end; (s--) != sets_begin;) { + if (*s == 0) { // ZRCola Decomposed => ZRCola Composed app->m_t_db.TranslateInv(*s, dst.data(), dst.size(), &app->m_lc_db, app->m_mainWnd->m_settings->m_lang, dst2, &map); } else { diff --git a/lib/libZRCola/src/translate.cpp b/lib/libZRCola/src/translate.cpp index a37636c..4dcf5df 100644 --- a/lib/libZRCola/src/translate.cpp +++ b/lib/libZRCola/src/translate.cpp @@ -125,7 +125,7 @@ void ZRCola::translation_db::TranslateInv(_In_ transetid_t set, _In_z_count_(inp for (size_t i = 0; i < inputMax;) { // Find the longest matching inverse translation at i-th character. size_t l_match = (size_t)-1; - for (size_t l = 0, r = r_set, ii = i, j = 0; ii < inputMax && l < r; ii++, j++) { + for (size_t l = l_set, r = r_set, ii = i, j = 0; ii < inputMax && l < r; ii++, j++) { wchar_t c = input[ii]; while (l < r) { // Test the inverse translation in the middle of the search area.