From 3bbf88c92ba5380ce1771682f6f48c17236257bf Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Wed, 31 Jul 2013 21:57:27 +0100 Subject: [PATCH] Fixed issue #33. --- src/api/api.cpp | 24 ++++++++++++++++++------ src/backend/legacy-parser.h | 5 +---- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/api/api.cpp b/src/api/api.cpp index 618fdc26..b042ff02 100644 --- a/src/api/api.cpp +++ b/src/api/api.cpp @@ -130,6 +130,21 @@ char * ToNewCString(std::string str) { return strcpy(p, str.c_str()); } +bool IsDirtyMessage(std::string message) { + const std::string local[3] = { + "Contains dirty edits: ", + "Contiene ediciones sucia: ", + "\"Грязные\" правки: " + }; + + for (int i=0; i < 3; ++i) { + if (boost::icontains(message, local[i])) + return true; + } + + return false; +} + ////////////////////////////// // Error Handling Functions ////////////////////////////// @@ -605,10 +620,10 @@ BOSS_API unsigned int boss_get_dirty_message (boss_db db, const char * const plu pluginMessages.insert(pluginMessages.end(), temp.begin(), temp.end()); } - //Now discard any that aren't warnings about dirty edits. + //Now discard any that aren't about dirty edits. std::list::iterator it=pluginMessages.begin(); while (it != pluginMessages.end()) { - if (it->ChooseContent(boss::g_lang_any).Str().find("dirty edits") == std::string::npos) + if (IsDirtyMessage(it->ChooseContent(boss::g_lang_any).Str())) it = pluginMessages.erase(it); } @@ -654,10 +669,7 @@ BOSS_API unsigned int boss_write_minimal_list (boss_db db, const char * const ou std::list messages = it->Messages(), newMessages; for (std::list::iterator messageIter = messages.begin(); messageIter != messages.end(); ++messageIter) { if (messageIter->Type() == boss_message_warn) { - const std::string content = messageIter->ChooseContent(boss::g_lang_any).Str(); - if (boost::contains(content, "Do not clean")) - newMessages.push_back(*messageIter); - else if (boost::contains(content, "Contains dirty edits")) + if (IsDirtyMessage(messageIter->ChooseContent(boss::g_lang_any).Str())) newMessages.push_back(*messageIter); } } diff --git a/src/backend/legacy-parser.h b/src/backend/legacy-parser.h index 47619dec..469266d7 100644 --- a/src/backend/legacy-parser.h +++ b/src/backend/legacy-parser.h @@ -649,10 +649,7 @@ namespace boss { opener = "\"Грязные\" правки: "; } - const boost::iterator_range ir1(content.begin(), content.end()); - const boost::iterator_range ir2(search.begin(), search.end()); - - if (boost::ifind_first(ir1, ir2)) + if (boost::icontains(content, search)) type = g_message_say; else type = g_message_warn;