aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeddy <[email protected]>2013-08-07 12:09:02 +0800
committerTeddy <[email protected]>2013-08-07 12:09:02 +0800
commit8a92faf9f1e9f77e05db7dc8a1399317ba530f93 (patch)
tree48b01f408537521e763214b64f5e4f593189895c
parentac19e9752dee0b9a78709e41f6a6c2d52c611908 (diff)
proper case-insensitive
-rw-r--r--parser.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/parser.cpp b/parser.cpp
index f667933..194443e 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -43,6 +43,13 @@ void Tokenizor::set_stream(FILE *_stream) {
} while (0)
#define TOP (*(buff_ptr - 1))
+void str_to_lower(string &str) {
+ size_t len = str.length();
+ for (int i = 0; i < len; i++)
+ if ('A' <= str[i] && str[i] <= 'Z')
+ str[i] -= 'A' - 'a';
+}
+
bool Tokenizor::get_token(string &ret) {
char ch;
bool flag = false;
@@ -105,7 +112,11 @@ bool Tokenizor::get_token(string &ret) {
else
*buff_ptr++ = ch;
}
- if (flag) return true;
+ if (flag)
+ {
+ str_to_lower(ret);
+ return true;
+ }
}
}
if (buff_ptr != buff) POP;