From 8a92faf9f1e9f77e05db7dc8a1399317ba530f93 Mon Sep 17 00:00:00 2001 From: Teddy Date: Wed, 7 Aug 2013 12:09:02 +0800 Subject: proper case-insensitive --- parser.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3-70-g09d2