Actually reverted stupid changes in Common::String and Util.cpp regarding Regex and the platform function.

svn-id: r32797
This commit is contained in:
Vicent Marti 2008-06-26 09:18:41 +00:00
parent 73d5715a79
commit 3ae28530ef
4 changed files with 0 additions and 152 deletions

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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