$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r50175 - in trunk/tools/quickbook: . detail test
From: daniel_james_at_[hidden]
Date: 2008-12-07 07:37:08
Author: danieljames
Date: 2008-12-07 07:37:07 EST (Sun, 07 Dec 2008)
New Revision: 50175
URL: http://svn.boost.org/trac/boost/changeset/50175
Log:
Fix processing of unmatched escape characters in code - and issue a warning for unexpected characters.
Added:
   trunk/tools/quickbook/test/code-block-bad-escape-cpp.gold   (contents, props changed)
   trunk/tools/quickbook/test/code-block-bad-escape-cpp.quickbook   (contents, props changed)
   trunk/tools/quickbook/test/code-block-bad-escape-python.gold   (contents, props changed)
   trunk/tools/quickbook/test/code-block-bad-escape-python.quickbook   (contents, props changed)
Text files modified: 
   trunk/tools/quickbook/detail/actions.cpp   |     9 ++++++++-                               
   trunk/tools/quickbook/detail/actions.hpp   |     2 +-                                      
   trunk/tools/quickbook/syntax_highlight.hpp |    15 +++++++++++----                         
   trunk/tools/quickbook/test/Jamfile.v2      |     2 ++                                      
   4 files changed, 22 insertions(+), 6 deletions(-)
Modified: trunk/tools/quickbook/detail/actions.cpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.cpp	(original)
+++ trunk/tools/quickbook/detail/actions.cpp	2008-12-07 07:37:07 EST (Sun, 07 Dec 2008)
@@ -242,8 +242,15 @@
         out << "</phrase>";
     }
 
-    void unexpected_char::operator()(char) const
+    void unexpected_char::operator()(iterator first, iterator last) const
     {
+        boost::spirit::classic::file_position const pos = first.get_position();
+
+        detail::outwarn(pos.file, pos.line)
+            << "in column:" << pos.column
+            << ", unexpected character: " << std::string(first, last)
+            << "\n";
+
         out << '#'; // print out an unexpected character
     }
 
Modified: trunk/tools/quickbook/detail/actions.hpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.hpp	(original)
+++ trunk/tools/quickbook/detail/actions.hpp	2008-12-07 07:37:07 EST (Sun, 07 Dec 2008)
@@ -271,7 +271,7 @@
         unexpected_char(collector& out)
         : out(out) {}
 
-        void operator()(char) const;
+        void operator()(iterator first, iterator last) const;
 
         collector& out;
     };
Modified: trunk/tools/quickbook/syntax_highlight.hpp
==============================================================================
--- trunk/tools/quickbook/syntax_highlight.hpp	(original)
+++ trunk/tools/quickbook/syntax_highlight.hpp	2008-12-07 07:37:07 EST (Sun, 07 Dec 2008)
@@ -15,6 +15,7 @@
 #include <boost/spirit/include/classic_chset.hpp>
 #include <boost/spirit/include/classic_symbols.hpp>
 #include <boost/spirit/include/classic_escape_char.hpp>
+#include <boost/spirit/include/classic_loops.hpp>
 #include "./phrase.hpp"
 
 namespace quickbook
@@ -58,7 +59,7 @@
                     |   string_         [Process("string", self.out)]
                     |   char_           [Process("char", self.out)]
                     |   number          [Process("number", self.out)]
-                    |   anychar_p       [Unexpected(self.out)]
+                    |   repeat_p(1)[anychar_p] [Unexpected(self.out)]
                     )
                     ;
 
@@ -75,7 +76,10 @@
                     ;
 
                 escape
-                    = str_p("``")           [PreEscape(self.escape_actions, save)]
+                    = (
+                        str_p("``")
+                        >> eps_p(+(anychar_p - "``") >> eps_p("``"))  
+                    )                       [PreEscape(self.escape_actions, save)]
                     >>  (
                             (+(anychar_p - "``") >> eps_p("``"))
                             & qbk_phrase
@@ -193,7 +197,7 @@
                     |   special         [Process("special", self.out)]
                     |   string_         [Process("string", self.out)]
                     |   number          [Process("number", self.out)]
-                    |   anychar_p       [Unexpected(self.out)]
+                    |   repeat_p(1)[anychar_p] [Unexpected(self.out)]
                     )
                     ;
 
@@ -210,7 +214,10 @@
                     ;
 
                 escape
-                    = str_p("``")           [PreEscape(self.escape_actions, save)]
+                    = (
+                        str_p("``")
+                        >> eps_p(+(anychar_p - "``") >> eps_p("``"))  
+                    )                       [PreEscape(self.escape_actions, save)]
                     >>  (
                             (+(anychar_p - "``") >> eps_p("``"))
                             & qbk_phrase
Modified: trunk/tools/quickbook/test/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/test/Jamfile.v2	(original)
+++ trunk/tools/quickbook/test/Jamfile.v2	2008-12-07 07:37:07 EST (Sun, 07 Dec 2008)
@@ -14,6 +14,8 @@
     [ quickbook-test quickbook-manual ]
     [ quickbook-test code-block-1 ]
     [ quickbook-test code-block-2 ]
+    [ quickbook-test code-block-bad-escape-cpp ]
+    [ quickbook-test code-block-bad-escape-python ]
     [ quickbook-test code-snippet ]
     [ quickbook-test preformatted ]
     [ quickbook-test link-side-by-side ]
Added: trunk/tools/quickbook/test/code-block-bad-escape-cpp.gold
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/code-block-bad-escape-cpp.gold	2008-12-07 07:37:07 EST (Sun, 07 Dec 2008)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<article id="odd_code_markup__" name="Odd code markup. " dirname="odd_code_markup__"
+last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+  <articleinfo>
+  </articleinfo>
+  <title>Odd code markup. </title>
+  <para>
+  </para>
+  
+<programlisting>## <phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{}</phrase>
+</programlisting>
+</article>
Added: trunk/tools/quickbook/test/code-block-bad-escape-cpp.quickbook
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/code-block-bad-escape-cpp.quickbook	2008-12-07 07:37:07 EST (Sun, 07 Dec 2008)
@@ -0,0 +1,5 @@
+[article Odd code markup. [quickbook 1.4] ]
+
+[c++]
+
+   `` int main() {}
Added: trunk/tools/quickbook/test/code-block-bad-escape-python.gold
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/code-block-bad-escape-python.gold	2008-12-07 07:37:07 EST (Sun, 07 Dec 2008)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<article id="odd_code_markup__" name="Odd code markup. " dirname="odd_code_markup__"
+last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+  <articleinfo>
+  </articleinfo>
+  <title>Odd code markup. </title>
+  <para>
+  </para>
+  
+<programlisting><phrase role="keyword">print</phrase> <phrase role="string">"Hello World."</phrase> ##
+</programlisting>
+</article>
Added: trunk/tools/quickbook/test/code-block-bad-escape-python.quickbook
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/code-block-bad-escape-python.quickbook	2008-12-07 07:37:07 EST (Sun, 07 Dec 2008)
@@ -0,0 +1,5 @@
+[article Odd code markup. [quickbook 1.4] ]
+
+[python]
+
+   print "Hello World." ``