From 76176b302b653e82218e7e8f40f7e7a0b240e055 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sun, 25 Apr 2004 10:32:09 +0000 Subject: [PATCH] Don't optimise leading repeats when there are backreferences involved. [SVN r22705] --- include/boost/regex/v4/regex_compile.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/boost/regex/v4/regex_compile.hpp b/include/boost/regex/v4/regex_compile.hpp index 74b1784b..25fb41b8 100644 --- a/include/boost/regex/v4/regex_compile.hpp +++ b/include/boost/regex/v4/regex_compile.hpp @@ -1350,6 +1350,7 @@ unsigned int BOOST_REGEX_CALL reg_expression::set_expr 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 refer to it later... if(arg_first >= arg_last) { @@ -1600,6 +1601,7 @@ unsigned int BOOST_REGEX_CALL reg_expression::set_expr dat = add_simple(dat, re_detail::syntax_element_backref, sizeof(re_detail::re_brace)); static_cast(dat)->index = i; ++ptr; + _leading_len = 1; continue; } break; @@ -2141,7 +2143,7 @@ unsigned int BOOST_REGEX_CALL reg_expression::fixup_le 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(dat)->alt.p) )) + if((len == 0) && (_leading_len == 0) && (1 == fixup_leading_rep(dat->next.p, static_cast(dat)->alt.p) )) { static_cast(dat)->leading = leading_lit; return len;