|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r49234 - in trunk: boost/spirit/home/classic/iterator libs/spirit/classic/test
From: daniel_james_at_[hidden]
Date: 2008-10-09 18:16:26
Author: danieljames
Date: 2008-10-09 18:16:26 EDT (Thu, 09 Oct 2008)
New Revision: 49234
URL: http://svn.boost.org/trac/boost/changeset/49234
Log:
Change position_iterator so that it doesn't count '\n\r' as a single
newline and doesn't change the sequence at all (which was conflicting
with spirit's newline handling).
Text files modified:
trunk/boost/spirit/home/classic/iterator/position_iterator.hpp | 18 +++++++++---------
trunk/libs/spirit/classic/test/position_iterator_tests.cpp | 24 +++++++++++++++---------
2 files changed, 24 insertions(+), 18 deletions(-)
Modified: trunk/boost/spirit/home/classic/iterator/position_iterator.hpp
==============================================================================
--- trunk/boost/spirit/home/classic/iterator/position_iterator.hpp (original)
+++ trunk/boost/spirit/home/classic/iterator/position_iterator.hpp 2008-10-09 18:16:26 EDT (Thu, 09 Oct 2008)
@@ -252,19 +252,19 @@
void increment()
{
typename base_t::reference val = *(this->base());
- if (val == '\n' || val == '\r') {
+ if (val == '\n') {
++this->base_reference();
- if (this->base_reference() != _end) {
- typename base_t::reference val2 = *(this->base());
- if ((val == '\n' && val2 == '\r')
- || (val == '\r' && val2 == '\n'))
- {
- ++this->base_reference();
- }
- }
this->next_line(_pos);
static_cast<main_iter_t &>(*this).newline();
}
+ else if ( val == '\r') {
+ ++this->base_reference();
+ if (this->base_reference() == _end || *(this->base()) != '\n')
+ {
+ this->next_line(_pos);
+ static_cast<main_iter_t &>(*this).newline();
+ }
+ }
else if (val == '\t') {
this->tabulation(_pos);
++this->base_reference();
Modified: trunk/libs/spirit/classic/test/position_iterator_tests.cpp
==============================================================================
--- trunk/libs/spirit/classic/test/position_iterator_tests.cpp (original)
+++ trunk/libs/spirit/classic/test/position_iterator_tests.cpp 2008-10-09 18:16:26 EDT (Thu, 09 Oct 2008)
@@ -141,32 +141,38 @@
{
IterT end;
- BOOST_TEST(*iter == '\n' || *iter == '\r');
+ BOOST_TEST(*iter == '\n');
BOOST_TEST(iter.get_position().line == 1);
++iter; // 0
BOOST_TEST(iter.get_position().line == 2);
++iter; // 1
++iter; // 2
++iter; // 3
- ++iter; // newline
- BOOST_TEST(*iter == '\n' || *iter == '\r');
+ ++iter; // \r
+ BOOST_TEST(*iter == '\r');
+ BOOST_TEST(iter.get_position().line == 2);
+ ++iter; // \n
+ BOOST_TEST(*iter == '\n');
BOOST_TEST(iter.get_position().line == 2);
++iter; // 4
BOOST_TEST(iter.get_position().line == 3);
++iter; // 5
++iter; // 6
++iter; // 7
- ++iter; // newline
- BOOST_TEST(*iter == '\n' || *iter == '\r');
+ ++iter; // \n
+ BOOST_TEST(*iter == '\n');
BOOST_TEST(iter.get_position().line == 3);
++iter; // 8
BOOST_TEST(iter.get_position().line == 4);
++iter; // 9
- ++iter; // newline
+ ++iter; // \n
BOOST_TEST(iter.get_position().line == 4);
- BOOST_TEST(*iter == '\n' || *iter == '\r');
- ++iter; // end
+ BOOST_TEST(*iter == '\n');
+ ++iter; // \r
BOOST_TEST(iter.get_position().line == 5);
+ BOOST_TEST(*iter == '\r');
+ ++iter; // end
+ BOOST_TEST(iter.get_position().line == 6);
BOOST_TEST(iter == end);
}
@@ -463,4 +469,4 @@
test_impl::CheckDistance(position_iterator2<iter_t>(b, b+15, ""));
test_impl::CheckDistance(position_iterator<iter_t, file_position_without_column>(b, b+15, ""));
test_impl::CheckDistance(position_iterator2<iter_t, file_position_without_column>(b, b+15, ""));
-}
\ No newline at end of file
+}
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