$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r63099 - in branches/filesystem3: boost/io libs/filesystem/v3/test libs/io/doc
From: bdawes_at_[hidden]
Date: 2010-06-19 09:25:55
Author: bemandawes
Date: 2010-06-19 09:25:55 EDT (Sat, 19 Jun 2010)
New Revision: 63099
URL: http://svn.boost.org/trac/boost/changeset/63099
Log:
Cope with I/O errors or premature eof
Text files modified: 
   branches/filesystem3/boost/io/quoted_manip.hpp                     |    10 +++++++++-                              
   branches/filesystem3/libs/filesystem/v3/test/quote_string_test.cpp |     9 +++++----                               
   branches/filesystem3/libs/io/doc/quoted_manip.html                 |    20 +++++++++++++-------                    
   3 files changed, 27 insertions(+), 12 deletions(-)
Modified: branches/filesystem3/boost/io/quoted_manip.hpp
==============================================================================
--- branches/filesystem3/boost/io/quoted_manip.hpp	(original)
+++ branches/filesystem3/boost/io/quoted_manip.hpp	2010-06-19 09:25:55 EDT (Sat, 19 Jun 2010)
@@ -13,7 +13,9 @@
 #define BOOST_IO_QUOTED_MANIP
 
 #include <iosfwd>
+#include <ios>
 #include <string>
+#include <iterator>
 #include <boost/io/ios_state.hpp>
 
 namespace boost
@@ -130,11 +132,17 @@
         {
           boost::io::ios_flags_saver ifs(is);
           is >> std::noskipws;
-          for (;;)
+          for (;;)  
           {
             is >> c;
+            if (!is.good())  // cope with I/O errors or end-of-file
+              break;
             if (c == proxy.escape)
+            {
               is >> c;
+              if (!is.good())  // cope with I/O errors or end-of-file
+                break;
+            }
             else if (c == proxy.delim)
               break;
             proxy.string += c;
Modified: branches/filesystem3/libs/filesystem/v3/test/quote_string_test.cpp
==============================================================================
--- branches/filesystem3/libs/filesystem/v3/test/quote_string_test.cpp	(original)
+++ branches/filesystem3/libs/filesystem/v3/test/quote_string_test.cpp	2010-06-19 09:25:55 EDT (Sat, 19 Jun 2010)
@@ -9,10 +9,7 @@
 {
 
   std::cout << quoted(std::string("foo\\bar, \" *")) << std::endl;
-  std::cout << quoted("foo\\bar, \" *") << std::endl;
-  std::cout << quoted("foo & bar, \" *", '&') << std::endl;
-  std::cout << quoted("foo & bar, * ", '&', '*') << std::endl;
-
+  std::cout << quoted("'Jack & Jill'", '&', '\'') << '\n';  // outputs: '&'Jack && Jill&''
   std::wcout << "Wide: " << quoted(L"foo$bar, \" *", L'$') << std::endl;
 
   std::string non_const_string("non-const string");
@@ -32,6 +29,10 @@
 
   assert(expected == actual);
 
+  ss << "\"abc"; // note missing end delimiter
+  ss >> quoted(actual);
+  std::cout << '*' << actual << "*\n";
+
   // these should fail to compile because the arguments are non-const:
   //   ss >> quoted(expected);
   //   ss >> quoted("foo");
Modified: branches/filesystem3/libs/io/doc/quoted_manip.html
==============================================================================
--- branches/filesystem3/libs/io/doc/quoted_manip.html	(original)
+++ branches/filesystem3/libs/io/doc/quoted_manip.html	2010-06-19 09:25:55 EDT (Sat, 19 Jun 2010)
@@ -4,7 +4,7 @@
 <html>
 <head>
   <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
-  <title>Boost quoted string manipulator</title>
+  <title>Boost "quoted" I/O manipulator</title>
   <meta name="generator" content="Microsoft FrontPage 5.0" />
   <link rel="stylesheet" type="text/css" href="../../../doc/html/minimal.css" />
 </head>
@@ -19,9 +19,9 @@
         src="../../../boost.png" alt="boost.png (6897 bytes)" align="middle"
         width="300" height="86" border="0" /></a></td>
       <td>
-      <h1 align="center">Quoted String<br>
-      Stream
-      I/O Manipulator</h1>
+      <h1 align="center">"Quoted"
+      I/O Manipulator<br>
+      for Strings</h1>
       </td>
     </tr>
   </tbody>
@@ -43,7 +43,7 @@
 
 assert(original == round_trip); // assert will fire</pre>
 </blockquote>
-<p>The Boost quoted string stream I/O manipulator places delimiters, defaulted 
+<p>The Boost <code>quoted</code> stream I/O manipulator places delimiters, defaulted 
 to the double-quote (<code>"</code>), around strings on output, and strips off 
 the delimiters on input. This ensures strings with embedded spaces round-trip as 
 desired. For example,</p>
@@ -60,6 +60,11 @@
 
 assert(original == round_trip); // assert will not fire</pre>
 </blockquote>
+<p>If the string contains the delimiter character, on output that character will 
+be preceded by an escape character, as will the escape character itself:</p>
+<blockquote>
+  <pre>std::cout << quoted("'Jack & Jill'", '&', '\'');  // outputs: '&'Jack && Jill&''</pre>
+</blockquote>
 <h2>Header <boost/io/quoted_manip.hpp> synopsis</h2>
 <pre>namespace boost
 {
@@ -113,7 +118,8 @@
     <code>operator==</code>, then:<ul>
       <li>Turn off the <code>skipws</code> flag.</li>
       <li><code>string.clear()</code></li>
-      <li>Until an unescaped <code>delim</code> character is reached, extract 
+      <li>Until an unescaped <code>delim</code> character is reached or <code>
+      is.not_good()</code>, extract 
       characters from <code>os</code> and append them to <code>string</code>, 
       except that if an <code>escape</code> is reached, ignore it and append the 
       next character to <code>string</code>.</li>
@@ -139,7 +145,7 @@
 <p>Distributed under the Boost Software License, Version 1.0. See
 <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
 <p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->18 June 2010<!--webbot bot="Timestamp" endspan i-checksum="17559" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->19 June 2010<!--webbot bot="Timestamp" endspan i-checksum="17561" --></p>
 
 </body>
 </html>
\ No newline at end of file