1
0
mirror of https://github.com/biergaizi/codecrypt synced 2024-06-27 09:18:16 +00:00

str_match: keyspec matches are ignorecase

This commit is contained in:
Mirek Kratochvil 2014-02-02 17:04:49 +01:00
parent 40fc690b1d
commit e66e82b9a8

@ -18,7 +18,9 @@
#include "str_match.h"
#include <ctype.h> //for tolower()
#include <algorithm>
#include <cctype> //for tolower()
using namespace std;
bool algorithm_name_matches (const std::string& search,
const std::string&name)
@ -30,6 +32,13 @@ bool algorithm_name_matches (const std::string& search,
return true;
}
bool matches_icase (string name, string search)
{
for_each (name.begin(), name.end(), ::tolower);
for_each (search.begin(), search.end(), ::tolower);
return name.find (search) != name.npos;
}
bool keyspec_matches (const std::string&search,
const std::string&name,
const std::string&keyid)
@ -43,6 +52,5 @@ bool keyspec_matches (const std::string&search,
return true;
}
//TODO maybe get case-insensitive
return name.find (search) != name.npos;
return matches_icase (name, search);
}