RE: [boost] regex lib: bug with sets and back ref

Sorry if I wasn't clear enough. All tests use regex_grep. In the last example, however, regex_grep _doesn't_ find "bcbc", even though it should. I would assume it's an issue with regex_compile, as the only difference between (2) and (3) is the way the set is defined. Ralph

Got it, yes it's a bug: the backreference was interacting badly with the heuristics regex uses to optimise some searches, there's a patch going into cvs now (see below). Rather than applying the patch though, I would suggest that you get hold of a copy of the RC_1_31_0 cvs branch, as that contains all the accumulated regex bug-fixes since the last release. John. $ cvs diff -u boost/regex/v4 johnmaddock@cvs.boost.sourceforge.net's password: cvs diff: Diffing boost/regex/v4 Index: boost/regex/v4/regex_compile.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/v4/regex_compile.hpp,v retrieving revision 1.11 diff -u -r1.11 regex_compile.hpp --- boost/regex/v4/regex_compile.hpp 19 Nov 2003 12:57:17 -0000 1.11 +++ boost/regex/v4/regex_compile.hpp 25 Apr 2004 10:25:41 -0000 @@ -1350,6 +1350,7 @@ data.clear(); _flags = f; fail(REG_NOERROR); // clear any error + _leading_len = 0; // set this to non-zero if there are any backrefs, we'll r efer to it later... if(arg_first >= arg_last) { @@ -1600,6 +1601,7 @@ dat = add_simple(dat, re_detail::syntax_element_backref, sizeof( re_detail::re_brace)); static_cast<re_detail::re_brace*>(dat)->index = i; ++ptr; + _leading_len = 1; continue; } break; @@ -2141,7 +2143,7 @@ case re_detail::syntax_element_char_rep: case re_detail::syntax_element_short_set_rep: case re_detail::syntax_element_long_set_rep: - if((len == 0) && (1 == fixup_leading_rep(dat->next.p, static_cast<re_d etail::re_repeat*>(dat)->alt.p) )) + if((len == 0) && (_leading_len == 0) && (1 == fixup_leading_rep(dat->n ext.p, static_cast<re_detail::re_repeat*>(dat)->alt.p) )) { static_cast<re_detail::re_repeat*>(dat)->leading = leading_lit; return len;
participants (2)
-
Benzinger, Ralph
-
John Maddock