Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82673 - in trunk: boost/regex/v4 libs/regex/test/regress
From: john_at_[hidden]
Date: 2013-02-06 20:23:46


Author: johnmaddock
Date: 2013-01-31 13:31:25 EST (Thu, 31 Jan 2013)
New Revision: 82673
URL: http://svn.boost.org/trac/boost/changeset/82673

Log:
Fix bug in partial matches and POSIX or literal expressions.
Text files modified:
   trunk/boost/regex/v4/perl_matcher_common.hpp | 6 ++++++
   trunk/libs/regex/test/regress/basic_tests.cpp | 11 +++++++++++
   2 files changed, 17 insertions(+), 0 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 2013-01-31 13:31:25 EST (Thu, 31 Jan 2013)
@@ -65,6 +65,8 @@
          m_match_flags |= match_perl;
       else if((re_f & (regbase::main_option_type|regbase::emacs_ex)) == (regbase::basic_syntax_group|regbase::emacs_ex))
          m_match_flags |= match_perl;
+ else if((re_f & (regbase::main_option_type|regbase::literal)) == (regbase::literal))
+ m_match_flags |= match_perl;
       else
          m_match_flags |= match_posix;
    }
@@ -326,6 +328,10 @@
       m_has_found_match = true;
       m_presult->set_second(last, 0, false);
       position = last;
+ if((m_match_flags & match_posix) == match_posix)
+ {
+ m_result.maybe_assign(*m_presult);
+ }
    }
 #ifdef BOOST_REGEX_MATCH_EXTRA
    if(m_has_found_match && (match_extra & m_match_flags))

Modified: trunk/libs/regex/test/regress/basic_tests.cpp
==============================================================================
--- trunk/libs/regex/test/regress/basic_tests.cpp (original)
+++ trunk/libs/regex/test/regress/basic_tests.cpp 2013-01-31 13:31:25 EST (Thu, 31 Jan 2013)
@@ -134,6 +134,17 @@
    TEST_REGEX_SEARCH("a*?<tag>", perl, "aaa", match_default|match_partial, make_array(0, 3, -2, -2));
    TEST_REGEX_SEARCH("\\w*?<tag>", perl, "aaa", match_default|match_partial, make_array(0, 3, -2, -2));
    TEST_REGEX_SEARCH("(\\w)*?<tag>", perl, "aaa", match_default|match_partial, make_array(0, 3, -2, -2));
+
+ TEST_REGEX_SEARCH("(xyz)(.*)abc", extended, "xyzaaab", match_default|match_partial, make_array(0, 7, -2, -2));
+ TEST_REGEX_SEARCH("(xyz)(.*)abc", extended, "xyz", match_default|match_partial, make_array(0, 3, -2, -2));
+ TEST_REGEX_SEARCH("(xyz)(.*)abc", extended, "xy", match_default|match_partial, make_array(0, 2, -2, -2));
+ TEST_REGEX_SEARCH("(xyz)(.*)abc", extended, "x", match_default|match_partial, make_array(0, 1, -2, -2));
+ TEST_REGEX_SEARCH("(xyz)(.*)abc", extended, "", match_default|match_partial, make_array(-2, -2));
+ TEST_REGEX_SEARCH("(xyz)(.*)abc", extended, "aaaa", match_default|match_partial, make_array(-2, -2));
+ TEST_REGEX_SEARCH(".abc", extended, "aaab", match_default|match_partial, make_array(1, 4, -2, -2));
+ TEST_REGEX_SEARCH("a[_]", extended, "xxa", match_default|match_partial, make_array(2, 3, -2, -2));
+ TEST_REGEX_SEARCH(".{4,}", extended, "xxa", match_default|match_partial, make_array(0, 3, -2, -2));
+ TEST_REGEX_SEARCH(".{4,}", extended, "xxa", match_default|match_partial|match_not_dot_null, make_array(0, 3, -2, -2));
 }
 
 void test_nosubs()


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