From: John L. <mov...@us...> - 2003-09-14 23:57:39
|
Update of /cvsroot/oprofile/oprofile/libregex In directory sc8-pr-cvs1:/tmp/cvs-serv29157/libregex Modified Files: Tag: BRANCH_CALLGRAPH op_regex.cpp Log Message: merge from HEAD Index: op_regex.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/libregex/op_regex.cpp,v retrieving revision 1.7.2.3 retrieving revision 1.7.2.4 diff -u -p -d -r1.7.2.3 -r1.7.2.4 --- op_regex.cpp 23 Aug 2003 16:47:10 -0000 1.7.2.3 +++ op_regex.cpp 14 Sep 2003 23:57:04 -0000 1.7.2.4 @@ -212,6 +212,8 @@ regmatch_t const & regular_expression_replace::get_match(regmatch_t const * match, char idx) const { size_t sub_expr = subexpr_index(idx); + if (sub_expr == size_t(-1)) + throw bad_regex("expect group index: " + idx); if (sub_expr >= max_match) throw bad_regex("illegal group index :" + idx); return match[sub_expr]; @@ -231,7 +233,7 @@ void regular_expression_replace::do_repl ++i; if (replace[i] == '\\') { inserted += '\\'; - } else if (subexpr_index(replace[i]) != size_t(-1)) { + } else { regmatch_t const & matched = get_match(match, replace[i]); if (matched.rm_so == -1 && @@ -245,9 +247,6 @@ void regular_expression_replace::do_repl inserted += str.substr(matched.rm_so, matched.rm_eo - matched.rm_so); } - } else { - throw bad_regex("expect group index: " + - replace); } } else { inserted += replace[i]; |