Patch #1805208: move matchString to Common::Util

svn-id: r29154
This commit is contained in:
Max Horn 2007-10-04 08:04:18 +00:00
parent 9e8167b10c
commit 51f082dcde
3 changed files with 57 additions and 45 deletions

View file

@ -61,6 +61,39 @@ extern bool isSmartphone(void);
namespace Common {
bool matchString(const char *str, const char *pat) {
const char *p = 0;
const char *q = 0;
for (;;) {
switch (*pat) {
case '*':
p = ++pat;
q = str;
break;
default:
if (*pat != *str) {
if (p) {
pat = p;
str = ++q;
if (!*str)
return !*pat;
break;
}
else
return false;
}
// fallthrough
case '?':
if (!*str)
return !*pat;
pat++;
str++;
}
}
}
//
// Print hexdump of the data passed in
//