diff options
-rw-r--r-- | common/str.cpp | 99 | ||||
-rw-r--r-- | common/str.h | 17 | ||||
-rw-r--r-- | common/util.cpp | 29 | ||||
-rw-r--r-- | common/util.h | 7 |
4 files changed, 0 insertions, 152 deletions
diff --git a/common/str.cpp b/common/str.cpp index e849cb042d..ad48ef6087 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -283,105 +283,6 @@ void String::toUppercase() { _str[i] = toupper(_str[i]); } -bool String::regexMatch(const char *regex, bool skipSpaces) { - int pos = 0; - - if (regex[0] == '^') - return regexMatchPos(1, regex, 1, skipSpaces); - - do { - if (regexMatchPos(pos, regex, 0, skipSpaces)) - return true; - } while (_str[pos++]); - - return false; -} - -bool String::regexMatchCharacter(RegexMatchType type, char regexChar, char strChar) { - switch (type) { - case kRegexMatchAny: - return true; - - case kRegexMatchDigit: - return isdigit(strChar) != 0; - - case kRegexMatchSpace: - return isspace(strChar) != 0; - - case kRegexMatchAlphanum: - return isalnum(strChar) != 0; - - case kRegexMatchAlpha: - return isalpha(strChar) != 0; - - case kRegexMatchWord: - return isalnum(strChar) != 0 || strChar == '_'; - - case kRegexMatchCharacter: - return regexChar == strChar; - - default: - return false; - } -} - -bool String::regexMatchStar(RegexMatchType type, char regexChar, const char *regex, int regexPos, int strPos, bool skipSpaces) { - - do { - if (regexMatchPos(strPos, regex, regexPos, skipSpaces)) - return true; - } while (_str[strPos] && regexMatchCharacter(type, regexChar, _str[strPos++])); - - return false; -} - -bool String::regexMatchPos(int strPos, const char *regex, int regexPos, bool skipSpaces) { - RegexMatchType matchT = kRegexMatchCharacter; - - if (skipSpaces) { - while (isspace(_str[strPos])) - strPos++; - - while (isspace(regex[regexPos])) - regexPos++; - } - - if (regex[regexPos] == '\0') - return true; - - if (regex[regexPos] == '.') - matchT = kRegexMatchAny; - else if (regex[regexPos] == '[') { - String group; - while (regex[regexPos - 1] != ']') - group += regex[regexPos++]; - - regexPos--; - - if (group == "[digit]" || group == "[d]") - matchT = kRegexMatchDigit; - else if (group == "[space]" || group == "[s]") - matchT = kRegexMatchSpace; - else if (group == "[alnum]") - matchT = kRegexMatchAlphanum; - else if (group == "[alpha]") - matchT = kRegexMatchAlpha; - else if (group == "[word]") - matchT = kRegexMatchWord; - } - - if (regex[regexPos + 1] == '*') - return regexMatchStar(matchT, regex[regexPos], regex, regexPos + 2, strPos, skipSpaces); - - if (regex[regexPos] == '$' && regex[regexPos + 1] == 0) - return _str[strPos] == 0; - - if (_str[strPos] && regexMatchCharacter(matchT, regex[regexPos], _str[strPos])) - return regexMatchPos(strPos + 1, regex, regexPos + 1, skipSpaces); - - return false; -} - /** * Ensure that enough storage is available to store at least new_len * characters plus a null byte. In addition, if we currently share diff --git a/common/str.h b/common/str.h index 2ea151ba96..a92ec34fff 100644 --- a/common/str.h +++ b/common/str.h @@ -165,9 +165,6 @@ public: uint hash() const; - // Tanoku: Regular expression support for the String class - bool regexMatch(const char *regex, bool skipSpaces = false); - public: typedef char * iterator; typedef const char * const_iterator; @@ -192,20 +189,6 @@ protected: void ensureCapacity(uint32 new_len, bool keep_old); void incRefCount() const; void decRefCount(int *oldRefCount); - - enum RegexMatchType { - kRegexMatchAny, - kRegexMatchDigit, - kRegexMatchSpace, - kRegexMatchAlphanum, - kRegexMatchAlpha, - kRegexMatchWord, - kRegexMatchCharacter - }; - - bool regexMatchStar(RegexMatchType type, char regexChar, const char *regex, int regexPos, int strPos, bool skipSpaces); - bool regexMatchCharacter(RegexMatchType type, char regexChar, char strChar); - bool regexMatchPos(int strPos, const char *regex, int regexPos, bool skipSpaces); }; // Append two strings to form a new (temp) string diff --git a/common/util.cpp b/common/util.cpp index 51bd8bcad6..6f0fdcb233 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -481,34 +481,6 @@ uint32 getEnabledSpecialDebugLevels() { return gDebugLevelsEnabled; } -const char *getHostPlatformString() { - -#if defined(__SYMBIAN32__) - return "symbian"; -#elif defined(_WIN32_WCE) || defined(_MSC_VER) || defined(__MINGW32__) || defined(UNIX) - return "pc"; -#elif defined(__PALMOS_TRAPS__) || defined (__PALMOS_ARMLET__) - return "palmos"; -#elif defined(__DC__) - return "dc"; -#elif defined(__GP32__) - return "gp32"; -#elif defined(__PLAYSTATION2__) - return "ps2"; -#elif defined(__PSP__) - return "psp"; -#elif defined(__amigaos4__) - return "amigaos"; -#elif defined (__DS__) //NeilM - return "nds"; -#elif defined(__WII__) - return "wii"; -#else - return ""; -#endif - -} - } // End of namespace Common @@ -722,4 +694,3 @@ Common::String tag2string(uint32 tag) { str[4] = '\0'; return Common::String(str); } - diff --git a/common/util.h b/common/util.h index c4cbf35212..c23513596c 100644 --- a/common/util.h +++ b/common/util.h @@ -323,13 +323,6 @@ const DebugLevelContainer &listSpecialDebugLevels(); uint32 getEnabledSpecialDebugLevels(); -/** - * Return a string containing the name of the currently running host. - * E.g. returns "wii" if ScummVM is being run in a Wii, and so on. - */ -const char *getHostPlatformString(); - - } // End of namespace Common |