X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fregex.cpp;h=9ba089d09008c7fd1c23a9d700051984eab11362;hp=c2590f2c8f8d9109606d06499da24b6b51c87e80;hb=cc69674bf670178a8076f2ce9740c2e60c4644c9;hpb=5c8c0d5e52bbba8dc3f9c7c71b6e4c973216c600 diff --git a/source/regex.cpp b/source/regex.cpp index c2590f2..9ba089d 100644 --- a/source/regex.cpp +++ b/source/regex.cpp @@ -116,11 +116,11 @@ Regex::Code Regex::compile(const string &expr, string::const_iterator &iter, uns } --level; } - else if(*end=='|') + else if(*end=='|' && level==0) { if(branch) break; - else if(level==0) + else has_branches=true; } else if(*end=='[') @@ -324,7 +324,7 @@ Regex::Code Regex::parse_brackets(const string &str, string::const_iterator &ite if(end==str.end()) throw InvalidParameterValue("Unmatched '['"); - uint8_t mask[32]={0}; + unsigned char mask[32]={0}; unsigned type=0; bool range=false; unsigned char first=0, last=0; @@ -468,11 +468,13 @@ bool Regex::run(const string &str, const string::const_iterator &begin, RegMatch } else if(instr==MATCH_MASK) { - uint8_t mask[32]; - for(unsigned k=0; k<32; ++k) - mask[k]=*j->citer++; - match_result=mask[c>>3]&(1<<(c&7)); - input_consumed=true; + if(c>=0 && c<=0xFF) + { + unsigned char m=*(j->citer+(c>>3)); + match_result=m&(1<<(c&7)); + input_consumed=true; + j->citer+=32; + } } else if(instr==MATCH_ANY) {