diff options
author | Teddy <[email protected]> | 2013-08-07 12:09:02 +0800 |
---|---|---|
committer | Teddy <[email protected]> | 2013-08-07 12:09:02 +0800 |
commit | 8a92faf9f1e9f77e05db7dc8a1399317ba530f93 (patch) | |
tree | 48b01f408537521e763214b64f5e4f593189895c | |
parent | ac19e9752dee0b9a78709e41f6a6c2d52c611908 (diff) |
proper case-insensitive
-rw-r--r-- | parser.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -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; |