parent
9e8167b10c
commit
51f082dcde
3 changed files with 57 additions and 45 deletions
|
@ -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
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue