Boost logo

Boost-Commit :

From: john_at_[hidden]
Date: 2007-11-22 05:38:49


Author: johnmaddock
Date: 2007-11-22 05:38:48 EST (Thu, 22 Nov 2007)
New Revision: 41302
URL: http://svn.boost.org/trac/boost/changeset/41302

Log:
Fixes #501 #1334.
Text files modified:
   trunk/boost/token_functions.hpp | 10 ++++++++--
   trunk/boost/token_iterator.hpp | 2 +-
   trunk/libs/tokenizer/examples.cpp | 10 +++++++++-
   3 files changed, 18 insertions(+), 4 deletions(-)

Modified: trunk/boost/token_functions.hpp
==============================================================================
--- trunk/boost/token_functions.hpp (original)
+++ trunk/boost/token_functions.hpp 2007-11-22 05:38:48 EST (Thu, 22 Nov 2007)
@@ -336,10 +336,12 @@
         return false;
 
       if (current_offset_ == offsets_.size())
+ {
         if (wrap_offsets_)
           current_offset_=0;
         else
           return false;
+ }
       
       int c = offsets_[current_offset_];
       int i = 0;
@@ -449,12 +451,16 @@
         
         // Handle empty token at the end
         if (next == end)
- if (m_output_done == false) {
+ {
+ if (m_output_done == false)
+ {
             m_output_done = true;
             assigner::assign(start,next,tok);
             return true;
- } else
+ }
+ else
             return false;
+ }
         
         if (is_kept(*next)) {
           if (m_output_done == false)

Modified: trunk/boost/token_iterator.hpp
==============================================================================
--- trunk/boost/token_iterator.hpp (original)
+++ trunk/boost/token_iterator.hpp 2007-11-22 05:38:48 EST (Thu, 22 Nov 2007)
@@ -94,7 +94,7 @@
 
       Type current_token()const{return tok_;}
 
- bool at_end()const{return valid_;}
+ bool at_end()const{return !valid_;}
 
 
 

Modified: trunk/libs/tokenizer/examples.cpp
==============================================================================
--- trunk/libs/tokenizer/examples.cpp (original)
+++ trunk/libs/tokenizer/examples.cpp 2007-11-22 05:38:48 EST (Thu, 22 Nov 2007)
@@ -16,7 +16,7 @@
 
 #include <boost/test/minimal.hpp>
 
-int test_main( int argc, char* argv[] )
+int test_main( int /*argc*/, char* /*argv*/[] )
 {
   using namespace std;
   using namespace boost;
@@ -95,9 +95,17 @@
     typedef token_iterator_generator<escaped_list_separator<char> >::type Iter;
     Iter begin = make_token_iterator<string>(test_string.begin(),
       test_string.end(),escaped_list_separator<char>());
+ Iter begin_c(begin);
     Iter end;
     BOOST_REQUIRE(equal(begin,end,answer));
 
+ while(begin_c != end)
+ {
+ BOOST_REQUIRE(begin_c.at_end() == 0);
+ ++begin_c;
+ }
+ BOOST_REQUIRE(begin_c.at_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