Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82078 - in trunk: boost/spirit/home/qi/stream libs/spirit/test libs/spirit/test/qi
From: hartmut.kaiser_at_[hidden]
Date: 2012-12-18 08:51:22


Author: hkaiser
Date: 2012-12-18 08:51:21 EST (Tue, 18 Dec 2012)
New Revision: 82078
URL: http://svn.boost.org/trac/boost/changeset/82078

Log:
Spirit: applying patch fixing qi::stream EOF behavior
Added:
   trunk/libs/spirit/test/qi/regression_stream_eof.cpp (contents, props changed)
Text files modified:
   trunk/boost/spirit/home/qi/stream/stream.hpp | 9 +++++----
   trunk/libs/spirit/test/Jamfile | 1 +
   2 files changed, 6 insertions(+), 4 deletions(-)

Modified: trunk/boost/spirit/home/qi/stream/stream.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/stream/stream.hpp (original)
+++ trunk/boost/spirit/home/qi/stream/stream.hpp 2012-12-18 08:51:21 EST (Tue, 18 Dec 2012)
@@ -65,16 +65,17 @@
 
             qi::skip_over(first, last, skipper);
 
- instream in(first, last); // copies 'first'
- in >> attr_; // use existing operator>>()
+ instream in(first, last); // copies 'first'
+ in >> attr_; // use existing operator>>()
 
             // advance the iterator if everything is ok
- if (in.good()) {
+ if (in) {
                 std::streamsize pos = in.tellg();
                 std::advance(first, pos);
+ return true;
             }
 
- return in.good() || in.eof();
+ return false;
         }
 
         template <typename Context>

Modified: trunk/libs/spirit/test/Jamfile
==============================================================================
--- trunk/libs/spirit/test/Jamfile (original)
+++ trunk/libs/spirit/test/Jamfile 2012-12-18 08:51:21 EST (Tue, 18 Dec 2012)
@@ -161,6 +161,7 @@
      [ run qi/regression_repeat.cpp : : : : qi_regression_repeat ]
      [ run qi/regression_transform_assignment.cpp : : : : qi_regression_transform_assignment ]
      [ run qi/regression_binary_action.cpp : : : : qi_regression_binary_action ]
+ [ run qi/regression_stream_eof.cpp : : : : qi_regression_stream_eof ]
     ;
 
     ###########################################################################

Added: trunk/libs/spirit/test/qi/regression_stream_eof.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/regression_stream_eof.cpp 2012-12-18 08:51:21 EST (Tue, 18 Dec 2012)
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 Louis Dionne
+// Copyright (c) 2001-2012 Hartmut Kaiser
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/qi.hpp>
+
+#include <iostream>
+#include <string>
+
+struct MyInt
+{
+ int i_;
+
+ template <typename Istream>
+ friend Istream operator>>(Istream& is, MyInt& self)
+ {
+ is >> self.i_;
+ return is;
+ }
+};
+
+int main()
+{
+ using namespace boost::spirit::qi;
+ typedef std::string::const_iterator Iterator;
+
+ std::string input = "1";
+ Iterator first(input.begin()), last(input.end());
+ rule<Iterator, int()> my_int = stream_parser<char, MyInt>();
+ BOOST_TEST(parse(first, last, my_int));
+ BOOST_TEST(first == last);
+
+ return boost::report_errors();
+}
+


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