change sorting mnemonic words for print out into case-insensitive

This commit is contained in:
Dario 2020-07-21 11:16:21 +02:00
parent 5630a62513
commit a71a69a619

View File

@ -270,6 +270,19 @@ std::string Mnemonic::getCompleteWordList()
return result;
}
// comparison, not case sensitive.
bool compare_nocase(const std::string& first, const std::string& second)
{
unsigned int i = 0;
while ((i < first.length()) && (i < second.length()))
{
if (tolower(first[i]) < tolower(second[i])) return true;
else if (tolower(first[i]) > tolower(second[i])) return false;
++i;
}
return (first.length() < second.length());
}
std::string Mnemonic::getCompleteWordListSorted()
{
std::shared_lock<std::shared_mutex> _lock(mWorkingMutex);
@ -284,7 +297,7 @@ std::string Mnemonic::getCompleteWordListSorted()
printf("missing word on %d\n", i);
}
}
words.sort();
words.sort(compare_nocase);
//std::string toReplaced[] = { "auml", "ouml", "uuml", "Auml", "Ouml", "Uuml", "szlig" };
Poco::RegularExpression toReplaced[] = { "&auml;", "&ouml;", "&uuml;", "&Auml;", "&Ouml;", "&Uuml;", "&szlig;" };