X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fregex.cpp;h=48fe4a7c3422fb027c40481d1f7d39b8fc7010d3;hp=320705e8e33dc1cecbca03a26adab78e9d498805;hb=47df471884234130a2a27f0a5fc842df3f994a3e;hpb=df1a66180655104af15f9bb6067b4eaa1421f5ff diff --git a/source/regex.cpp b/source/regex.cpp index 320705e..48fe4a7 100644 --- a/source/regex.cpp +++ b/source/regex.cpp @@ -5,7 +5,7 @@ Copyright © 2007 Mikko Rasa Distributed under the LGPL */ #include -#include +#include #include "formatter.h" #include "regex.h" @@ -244,8 +244,7 @@ Regex::Code Regex::parse_atom(const string &expr, string::const_iterator &i, uns if(flag) { - if(static_cast(*i)<=LAST_INSTRUCTION_) - result+=MATCH_CHAR; + result+=MATCH_CHAR; result+=*i; } @@ -388,11 +387,7 @@ bool Regex::run(const string &str, const string::const_iterator &begin, RegMatch bool negate_match=false; for(; j->citer!=code.end();) { - Instruction instr=static_cast(*j->citer); - if(instr>LAST_INSTRUCTION_) - instr=MATCH_CHAR; - else - ++j->citer; + Instruction instr=static_cast(*j->citer++); if(instr==NEGATE) negate_match=true; @@ -517,11 +512,7 @@ bool Regex::group_compare(const RegMatch::Group &g1, const RegMatch::Group &g2) string Regex::disassemble_instruction(Code::const_iterator &i) const { - Instruction instr=static_cast(*i); - if(instr>=LAST_INSTRUCTION_) - instr=MATCH_CHAR; - else - ++i; + Instruction instr=static_cast(*i++); ostringstream result; switch(instr) @@ -575,8 +566,7 @@ string Regex::disassemble_instruction(Code::const_iterator &i) const case MATCH_ANY: result<<"MATCH_ANY"; break; - case FIRST_INSTRUCTION_: - case LAST_INSTRUCTION_: + default: result<<"UNKNOWN "<