From eaaf00a92491cf5dc321aa87ade0e9edee96af52 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sun, 6 Jun 2010 12:38:26 +0000 Subject: [PATCH] Fix bug in branch reset code. [SVN r62478] --- include/boost/regex/v4/basic_regex_parser.hpp | 3 +++ test/regress/test_perl_ex.cpp | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/include/boost/regex/v4/basic_regex_parser.hpp b/include/boost/regex/v4/basic_regex_parser.hpp index 3ea4d645..172b53a0 100644 --- a/include/boost/regex/v4/basic_regex_parser.hpp +++ b/include/boost/regex/v4/basic_regex_parser.hpp @@ -1906,7 +1906,9 @@ bool basic_regex_parser::parse_perl_extension() m_has_case_change = false; charT name_delim; int mark_reset = m_mark_reset; + int max_mark = m_max_mark; m_mark_reset = -1; + m_max_mark = m_mark_count; int v; // // select the actual extension used: @@ -2536,6 +2538,7 @@ option_group_jump: m_mark_count = m_max_mark; } m_mark_reset = mark_reset; + m_max_mark = max_mark; if(markid > 0) diff --git a/test/regress/test_perl_ex.cpp b/test/regress/test_perl_ex.cpp index d58da2a7..27d5cee4 100644 --- a/test/regress/test_perl_ex.cpp +++ b/test/regress/test_perl_ex.cpp @@ -674,6 +674,15 @@ void test_mark_resets() TEST_REGEX_SEARCH("^X(?7)(a)(?|(b)|(q)(r)(s))(c)(d)(Y)", perl, "XYabcdY", match_default, make_array(0, 7, 2, 3, 3, 4, -1, -1, -1, -1, 4, 5, 5, 6, 6, 7, -2, -2)); TEST_REGEX_SEARCH("^X(?7)(a)(?|(b|(r)(s))|(q))(c)(d)(Y)", perl, "XYabcdY", match_default, make_array(0, 7, 2, 3, 3, 4, -1, -1, -1, -1, 4, 5, 5, 6, 6, 7, -2, -2)); TEST_REGEX_SEARCH("^X(?7)(a)(?|(b|(?|(r)|(t))(s))|(q))(c)(d)(Y)", perl, "XYabcdY", match_default, make_array(0, 7, 2, 3, 3, 4, -1, -1, -1, -1, 4, 5, 5, 6, 6, 7, -2, -2)); + TEST_REGEX_SEARCH("(?|(abc)|(?:((?:xyz)))|(123))", perl, "abc", match_default, make_array(0, 3, 0, 3, -2, -2)); + TEST_REGEX_SEARCH("(?|(abc)|(?:)((?:)xyz)|(123))", perl, "xyz", match_default, make_array(0, 3, 0, 3, -2, -2)); + TEST_REGEX_SEARCH("(?|(abc)|((?:(x)|(y)|(z)))|(123))", perl, "y", match_default, make_array(0, 1, 0, 1, -1, -1, 0, 1, -1, -1, -2, -2)); + TEST_REGEX_SEARCH("(?|(abc)|((?|(x)|(y)|(z)))|(123))", perl, "y", match_default, make_array(0, 1, 0, 1, 0, 1, -2, -2)); + TEST_REGEX_SEARCH("(?|(abc)|((?|(x)|(y)|(z)))|(123))", perl, "abc", match_default, make_array(0, 3, 0, 3, -1, -1, -2, -2)); + TEST_REGEX_SEARCH("(?|(abc)|((?|(x)|(y)|(z)))|(123))", perl, "123", match_default, make_array(0, 3, 0, 3, -1, -1, -2, -2)); + TEST_REGEX_SEARCH("(?|(abc)|((x)|(y)|(z))|(123))", perl, "z", match_default, make_array(0, 1, 0, 1, -1, -1, -1, -1, 0, 1, -2, -2)); + TEST_REGEX_SEARCH("(?|(abc)|((x)|(y)|(z))|(123))", perl, "abc", match_default, make_array(0, 3, 0, 3, -1, -1, -1, -1, -1, -1, -2, -2)); + TEST_REGEX_SEARCH("(?|(abc)|((x)|(y)|(z))|(123))", perl, "123", match_default, make_array(0, 3, 0, 3, -1, -1, -1, -1, -1, -1, -2, -2)); } void test_recursion()