From 4c105a90a1491fdd0a13840e33a3ba36bf0a2020 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Wed, 14 May 2008 11:19:58 +0000 Subject: [PATCH] Changed behaviour of \B so that it succeeds when the neither adjacent character is a word character. [SVN r45354] --- include/boost/regex/v4/perl_matcher_common.hpp | 4 ++-- test/regress/test_escapes.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/boost/regex/v4/perl_matcher_common.hpp b/include/boost/regex/v4/perl_matcher_common.hpp index 72e43d00..399caa3b 100644 --- a/include/boost/regex/v4/perl_matcher_common.hpp +++ b/include/boost/regex/v4/perl_matcher_common.hpp @@ -535,7 +535,7 @@ bool perl_matcher::match_within_word() if(position == last) return false; // both prev and this character must be m_word_mask: - if(traits_inst.isctype(*position, m_word_mask)) + bool prev = traits_inst.isctype(*position, m_word_mask); { bool b; if((position == backstop) && ((m_match_flags & match_prev_avail) == 0)) @@ -546,7 +546,7 @@ bool perl_matcher::match_within_word() b = traits_inst.isctype(*position, m_word_mask); ++position; } - if(b) + if(b == prev) { pstate = pstate->next.p; return true; diff --git a/test/regress/test_escapes.cpp b/test/regress/test_escapes.cpp index aa842130..ba78c454 100644 --- a/test/regress/test_escapes.cpp +++ b/test/regress/test_escapes.cpp @@ -109,6 +109,9 @@ void test_assertion_escapes() TEST_REGEX_SEARCH("a\\B", perl, "ab", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("a\\B", perl, "a", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("a\\B", perl, "a ", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("\\By\\b", perl, "xy", match_default, make_array(1, 2, -2, -2)); + TEST_REGEX_SEARCH("\\by\\B", perl, "yz", match_default, make_array(0, 1, -2, -2)); + TEST_REGEX_SEARCH("\\B\\*\\B", perl, " * ", match_default, make_array(1, 2, -2, -2)); // buffer operators: TEST_REGEX_SEARCH("\\`abc", perl, "abc", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("\\`abc", perl, "\nabc", match_default, make_array(-2, -2));