From: Mikko Rasa Date: Wed, 28 May 2008 23:56:45 +0000 (+0000) Subject: Remove the "optimization" of omitting MATCH_CHAR instruction for characters >LAST_INS... X-Git-Tag: strings-1.0~6 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=47df471884234130a2a27f0a5fc842df3f994a3e;p=libs%2Fcore.git Remove the "optimization" of omitting MATCH_CHAR instruction for characters >LAST_INSTRUCTION_ since it caused trouble with -O3 without a measurable benefit Fix commandline handling in grep --- diff --git a/grep.cpp b/grep.cpp index eaf1663..0774307 100644 --- a/grep.cpp +++ b/grep.cpp @@ -14,7 +14,7 @@ int main(int argc, char **argv) getopt.add_option('d', "debug", debug, GetOpt::NO_ARG); getopt(argc, argv); - const list &args=getopt.get_args(); + const vector &args=getopt.get_args(); if(args.empty()) { @@ -22,7 +22,7 @@ int main(int argc, char **argv) return 1; } - Regex regex(argv[1]); + Regex regex(args[0]); if(debug) cout<(*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 "<