comment to BSPF::matches() added

some compiler warnings fixed
This commit is contained in:
thrust26 2017-10-10 15:29:14 +02:00
parent d702829ed3
commit 20ff2163ca
2 changed files with 8 additions and 6 deletions

View File

@ -190,15 +190,17 @@ namespace BSPF
return findIgnoreCase(s1, s2) != string::npos;
}
inline bool matches(const string& command, const string& in)
// Test whether the first string matches the second one (case insensitive)
// - the first character must match
// - the following characters must appear in the order of the first string
inline bool matches(const string& s1, const string& s2)
{
if(BSPF::startsWithIgnoreCase(command, in.substr(0, 1)))
if(BSPF::startsWithIgnoreCase(s1, s2.substr(0, 1)))
{
size_t pos = 1;
for(int j = 1; j < in.size(); j++)
for(uInt32 j = 1; j < s2.size(); j++)
{
int found = BSPF::findIgnoreCase(command, in.substr(j, 1), pos);
size_t found = BSPF::findIgnoreCase(s1, s2.substr(j, 1), pos);
if(found == string::npos)
return false;
pos += found + 1;

View File

@ -914,7 +914,7 @@ bool PromptWidget::saveBuffer(const FilesystemNode& file)
string PromptWidget::getCompletionPrefix(const StringList& completions)
{
// Find the largest match at the beginning of the completions provided
for(int len = 1;; len++)
for(uInt32 len = 1;; len++)
{
for(const auto& s1 : completions)
{