From 51f082dcde8c6f1b5036f81ae7b504bcc291bced Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 4 Oct 2007 08:04:18 +0000 Subject: Patch #1805208: move matchString to Common::Util svn-id: r29154 --- common/util.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'common/util.cpp') diff --git a/common/util.cpp b/common/util.cpp index 8bf704456a..eaef9ce0b5 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -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 // -- cgit v1.2.3