Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-07-30 18:22:40


Author: eric_niebler
Date: 2008-07-30 18:22:40 EDT (Wed, 30 Jul 2008)
New Revision: 47899
URL: http://svn.boost.org/trac/boost/changeset/47899

Log:
fixed buggy eol matching behavior (fixes #2157)
Text files modified:
   trunk/boost/xpressive/detail/core/matcher/assert_bol_matcher.hpp | 2 +-
   trunk/boost/xpressive/detail/core/matcher/assert_eol_matcher.hpp | 3 ++-
   trunk/boost/xpressive/detail/core/matcher/assert_line_base.hpp | 8 ++++----
   trunk/libs/xpressive/test/Jamfile.v2 | 4 ++--
   trunk/libs/xpressive/test/regress.txt | 27 +++++++++++++++++++++++++++
   5 files changed, 36 insertions(+), 8 deletions(-)

Modified: trunk/boost/xpressive/detail/core/matcher/assert_bol_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/assert_bol_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/assert_bol_matcher.hpp 2008-07-30 18:22:40 EDT (Wed, 30 Jul 2008)
@@ -43,7 +43,7 @@
                     return false;
                 }
             }
- else if(!this->is_line_break(state))
+ else if(!this->is_line_break(state, state.cur_))
             {
                 return false;
             }

Modified: trunk/boost/xpressive/detail/core/matcher/assert_eol_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/assert_eol_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/assert_eol_matcher.hpp 2008-07-30 18:22:40 EDT (Wed, 30 Jul 2008)
@@ -13,6 +13,7 @@
 # pragma once
 #endif
 
+#include <boost/next_prior.hpp>
 #include <boost/xpressive/detail/detail_fwd.hpp>
 #include <boost/xpressive/detail/core/quant_style.hpp>
 #include <boost/xpressive/detail/core/state.hpp>
@@ -43,7 +44,7 @@
                     return false;
                 }
             }
- else if((state.bos() && !state.flags_.match_prev_avail_) || !this->is_line_break(state))
+ else if((state.bos() && !state.flags_.match_prev_avail_) || !this->is_line_break(state, boost::next(state.cur_)))
             {
                 return false;
             }

Modified: trunk/boost/xpressive/detail/core/matcher/assert_line_base.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/assert_line_base.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/assert_line_base.hpp 2008-07-30 18:22:40 EDT (Wed, 30 Jul 2008)
@@ -39,16 +39,16 @@
         }
 
         template<typename BidiIter>
- bool is_line_break(match_state<BidiIter> &state) const
+ bool is_line_break(match_state<BidiIter> &state, BidiIter where) const
         {
- BOOST_ASSERT(!state.bos() || state.flags_.match_prev_avail_);
- BidiIter tmp = state.cur_;
+ BOOST_ASSERT(where != state.begin_ || state.flags_.match_prev_avail_);
+ BidiIter tmp = where;
             char_type ch = *--tmp;
 
             if(traits_cast<Traits>(state).isctype(ch, this->newline_))
             {
                 // there is no line-break between \r and \n
- if(this->cr_ != ch || state.eos() || this->nl_ != *state.cur_)
+ if(this->cr_ != ch || where == state.end_ || this->nl_ != *where)
                 {
                     return true;
                 }

Modified: trunk/libs/xpressive/test/Jamfile.v2
==============================================================================
--- trunk/libs/xpressive/test/Jamfile.v2 (original)
+++ trunk/libs/xpressive/test/Jamfile.v2 2008-07-30 18:22:40 EDT (Wed, 30 Jul 2008)
@@ -23,8 +23,8 @@
     ;
 
 test-suite "xpressive"
- : [ run regress.cpp ]
- [ run c_traits.cpp ]
+ : [ run regress.cpp : : : <dependency>regress.txt ]
+ [ run c_traits.cpp : : : <dependency>regress.txt ]
          [ run test1.cpp ]
          [ run test2.cpp ]
          [ run test3.cpp ]

Modified: trunk/libs/xpressive/test/regress.txt
==============================================================================
--- trunk/libs/xpressive/test/regress.txt (original)
+++ trunk/libs/xpressive/test/regress.txt 2008-07-30 18:22:40 EDT (Wed, 30 Jul 2008)
@@ -3697,3 +3697,30 @@
 br10=
 br11=b
 [end]
+
+[track2157.1]
+str=abc\ndef\nghi
+pat=^.+$
+flg=m
+br0=abc
+[end]
+
+[track2157.2]
+str=abc\ndef\nghi
+pat=.$
+flg=m
+br0=c
+[end]
+
+[track2157.3]
+str=abc\ndef\nghi
+pat=^.+$
+flg=
+[end]
+
+[track2157.4]
+str=abc\ndef\nghi
+pat=.$
+flg=
+br0=i
+[end]


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