Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49231 - trunk/tools/quickbook/detail
From: daniel_james_at_[hidden]
Date: 2008-10-09 18:14:14


Author: danieljames
Date: 2008-10-09 18:14:14 EDT (Thu, 09 Oct 2008)
New Revision: 49231
URL: http://svn.boost.org/trac/boost/changeset/49231

Log:
Work around the problems with window newlines in position_iterator. (I'm
about to fix them, but this will get quickbook working immediately).

Fixes #2155
Text files modified:
   trunk/tools/quickbook/detail/utils.cpp | 21 ++++++++++++++++++++-
   1 files changed, 20 insertions(+), 1 deletions(-)

Modified: trunk/tools/quickbook/detail/utils.cpp
==============================================================================
--- trunk/tools/quickbook/detail/utils.cpp (original)
+++ trunk/tools/quickbook/detail/utils.cpp 2008-10-09 18:14:14 EDT (Thu, 09 Oct 2008)
@@ -181,6 +181,25 @@
         }
     }
 
+ // Copy a string, converting mac and windows style newlines to unix
+ // newlines.
+
+ template <class InputIterator, class OutputIterator>
+ void normalize_newlines(InputIterator begin, InputIterator end,
+ OutputIterator out)
+ {
+ while(begin != end) {
+ if(*begin == '\r') {
+ *out++ = '\n';
+ ++begin;
+ if(begin != end && *begin == '\n') ++begin;
+ }
+ else {
+ *out++ = *begin++;
+ }
+ }
+ }
+
     int load(std::string const& filename, std::string& storage)
     {
         using std::cerr;
@@ -200,7 +219,7 @@
         // Turn off white space skipping on the stream
         in.unsetf(ios::skipws);
 
- std::copy(
+ normalize_newlines(
             istream_iterator<char>(in),
             istream_iterator<char>(),
             std::back_inserter(storage));


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