Boost logo

Boost-Commit :

From: john_at_[hidden]
Date: 2008-05-14 07:19:59


Author: johnmaddock
Date: 2008-05-14 07:19:58 EDT (Wed, 14 May 2008)
New Revision: 45354
URL: http://svn.boost.org/trac/boost/changeset/45354

Log:
Changed behaviour of \B so that it succeeds when the neither adjacent character is a word character.
Text files modified:
   trunk/boost/regex/v4/perl_matcher_common.hpp | 4 ++--
   trunk/libs/regex/test/regress/test_escapes.cpp | 3 +++
   2 files changed, 5 insertions(+), 2 deletions(-)

Modified: trunk/boost/regex/v4/perl_matcher_common.hpp
==============================================================================
--- trunk/boost/regex/v4/perl_matcher_common.hpp (original)
+++ trunk/boost/regex/v4/perl_matcher_common.hpp 2008-05-14 07:19:58 EDT (Wed, 14 May 2008)
@@ -535,7 +535,7 @@
    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 @@
          b = traits_inst.isctype(*position, m_word_mask);
          ++position;
       }
- if(b)
+ if(b == prev)
       {
          pstate = pstate->next.p;
          return true;

Modified: trunk/libs/regex/test/regress/test_escapes.cpp
==============================================================================
--- trunk/libs/regex/test/regress/test_escapes.cpp (original)
+++ trunk/libs/regex/test/regress/test_escapes.cpp 2008-05-14 07:19:58 EDT (Wed, 14 May 2008)
@@ -109,6 +109,9 @@
    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));


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk