From 3bfba1a7cf60a4ca302a8382c4397e95e057c8a5 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sat, 7 Jul 2012 18:08:01 +0000 Subject: [PATCH] Fix regex_iterator and regex_replace to do what grep/sed do for multiple repeats when matching in POSIX mode. Fixes #589. [SVN r79339] --- doc/history.qbk | 6 ++++++ include/boost/regex/v4/regex_iterator.hpp | 2 +- test/regress/test_replace.cpp | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/history.qbk b/doc/history.qbk index f83aef93..8c71192c 100644 --- a/doc/history.qbk +++ b/doc/history.qbk @@ -15,6 +15,12 @@ Currently open issues can be viewed [@https://svn.boost.org/trac/boost/query?sta All issues including closed ones can be viewed [@https://svn.boost.org/trac/boost/query?status=assigned&status=closed&status=new&status=reopened&component=regex&order=priority&col=id&col=summary&col=status&col=type&col=milestone&col=component here]. +[h4 Boost-1.51] + +Fixed issues: +[@https://svn.boost.org/trac/boost/ticket/589 #589], [@https://svn.boost.org/trac/boost/ticket/7084 #7084], +[@https://svn.boost.org/trac/boost/ticket/7032 #7032]. + [h4 Boost-1.50] Fixed issue with `(?!)` not being a valid expression, and updated docs on what constitutes a valid conditional expression. diff --git a/include/boost/regex/v4/regex_iterator.hpp b/include/boost/regex/v4/regex_iterator.hpp index c2f2c49f..09e75c69 100644 --- a/include/boost/regex/v4/regex_iterator.hpp +++ b/include/boost/regex/v4/regex_iterator.hpp @@ -68,7 +68,7 @@ public: // flags |= match_prev_avail; BidirectionalIterator next_start = what[0].second; match_flag_type f(flags); - if(!what.length()) + if(!what.length() || (f & regex_constants::match_posix)) f |= regex_constants::match_not_initial_null; //if(base != next_start) // f |= regex_constants::match_not_bob; diff --git a/test/regress/test_replace.cpp b/test/regress/test_replace.cpp index 2d8724eb..be518268 100644 --- a/test/regress/test_replace.cpp +++ b/test/regress/test_replace.cpp @@ -190,5 +190,9 @@ void test_replace() TEST_REGEX_REPLACE("(?:(?a)|(?b))", perl, " ...b,,", match_default, "$1.$2.$+{one}", " ....b.b,,"); TEST_REGEX_REPLACE("(?:(?a)(?b))", perl, " ...ab,,", match_default, "$1.$2.$+{one}", " ...a.b.a,,"); + // See https://svn.boost.org/trac/boost/ticket/589 + TEST_REGEX_REPLACE("(a*)", perl, "aabb", match_default, "{$1}", "{aa}{}b{}b{}"); + TEST_REGEX_REPLACE("(a*)", extended, "aabb", match_default, "{$1}", "{aa}{}b{}b{}"); + TEST_REGEX_REPLACE("(a*)", extended, "aabb", match_default|match_posix, "{$1}", "{aa}b{}b{}"); }