fnmatch() errors encountered with charset conversion errors on file names were treated as matches

This commit is contained in:
Jean-Francois Dockes
2013-03-27 15:44:24 +01:00
parent e88db6a7c8
commit dd0e89e694
4 changed files with 39 additions and 12 deletions
+12 -2
View File
@@ -26,12 +26,22 @@
using std::string;
#include "cstr.h"
#include "debuglog.h"
#include "strmatcher.h"
bool StrWildMatcher::match(const string& val) const
{
return fnmatch(m_sexp.c_str(), val.c_str(), 0) != FNM_NOMATCH;
LOGDEB2(("StrWildMatcher::match: [%s] against [%s]\n",
m_sexp.c_str(), val.c_str()));
int ret = fnmatch(m_sexp.c_str(), val.c_str(), FNM_NOESCAPE);
switch (ret) {
case 0: return true;
case FNM_NOMATCH: return false;
default:
LOGDEB0(("StrWildMatcher::match error: [%s] against [%s]\n",
m_sexp.c_str(), val.c_str()));
return false;
}
}
string::size_type StrWildMatcher::baseprefixlen() const