$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r84151 - in trunk/tools/quickbook: doc src test
From: dnljms_at_[hidden]
Date: 2013-05-05 09:46:39
Author: danieljames
Date: 2013-05-05 09:46:38 EDT (Sun, 05 May 2013)
New Revision: 84151
URL: http://svn.boost.org/trac/boost/changeset/84151
Log:
Only recognise preprocessor statements at the start of the line. Refs #8511.
Text files modified: 
   trunk/tools/quickbook/doc/change_log.qbk          |     7 +++++--                                 
   trunk/tools/quickbook/src/syntax_highlight.cpp    |    26 +++++++++++++++++---------              
   trunk/tools/quickbook/test/code_cpp-1_5.gold      |     1 +                                       
   trunk/tools/quickbook/test/code_cpp-1_5.quickbook |     1 +                                       
   4 files changed, 24 insertions(+), 11 deletions(-)
Modified: trunk/tools/quickbook/doc/change_log.qbk
==============================================================================
--- trunk/tools/quickbook/doc/change_log.qbk	(original)
+++ trunk/tools/quickbook/doc/change_log.qbk	2013-05-05 09:46:38 EDT (Sun, 05 May 2013)
@@ -279,8 +279,11 @@
 
 * When code blocks are indented using a mixture of tabs and spaces,
   convert indentation to spaces.
-* Support the token pasting operator (`##`) in C++ code blocks
-  ([@https://svn.boost.org/trac/boost/ticket/8510 #8510]).
+* In the C++ systax highlighter, fix syntax highlighting for `#`, so that it's
+  used for preprocessor statements at the start of a line, and as a 'special'
+  character elsewhere
+  ([@https://svn.boost.org/trac/boost/ticket/8510 #8510],
+  [@https://svn.boost.org/trac/boost/ticket/8511 #8511]).
 * Hidden options for formatting of `--output-deps`. Not really for public use
 * yet.
 * 1.6 changes:
Modified: trunk/tools/quickbook/src/syntax_highlight.cpp
==============================================================================
--- trunk/tools/quickbook/src/syntax_highlight.cpp	(original)
+++ trunk/tools/quickbook/src/syntax_highlight.cpp	2013-05-05 09:46:38 EDT (Sun, 05 May 2013)
@@ -270,12 +270,21 @@
                     do_macro(self.actions, &syntax_highlight_actions::do_macro);
                 error_action error(self.actions.state);
 
-                program
-                    =
-                    *(  (+cl::space_p)                  [plain_char]
+                program =
+                    *(  (*cl::space_p)                  [plain_char]
+                    >>  (line_start | rest_of_line)
+                    >>  *rest_of_line
+                    )
+                    ;
+
+                line_start =
+                        preprocessor                    [span("preprocessor")]
+                    ;
+                
+                rest_of_line = 
+                        (+cl::blank_p)                  [plain_char]
                     |   macro
                     |   escape
-                    |   preprocessor                    [span("preprocessor")]
                     |   cl::eps_p(ph::var(self.actions.support_callouts))
                     >>  (   line_callout                [callout]
                         |   inline_callout              [callout]
@@ -287,8 +296,8 @@
                     |   string_                         [span("string")]
                     |   char_                           [span("char")]
                     |   number                          [span("number")]
-                    |   u8_codepoint_p                  [unexpected_char]
-                    )
+                    |   ~cl::eps_p(cl::eol_p)
+                    >>  u8_codepoint_p                  [unexpected_char]
                     ;
 
                 macro =
@@ -359,8 +368,7 @@
                     ;   // make sure we recognize whole words only
 
                 special
-                    =   +cl::chset_p("~!%^&*()+={[}]:;,<.>?/|\\-") |
-                        "##"
+                    =   +cl::chset_p("~!%^&*()+={[}]:;,<.>?/|\\#-")
                     ;
 
                 string_char = ('\\' >> u8_codepoint_p) | (cl::anychar_p - '\\');
@@ -388,7 +396,7 @@
             }
 
             cl::rule<Scanner>
-                            program, macro, preprocessor,
+                            program, line_start, rest_of_line, macro, preprocessor,
                             inline_callout, line_callout, comment,
                             special, string_, 
                             char_, number, identifier, keyword, escape,
Modified: trunk/tools/quickbook/test/code_cpp-1_5.gold
==============================================================================
--- trunk/tools/quickbook/test/code_cpp-1_5.gold	(original)
+++ trunk/tools/quickbook/test/code_cpp-1_5.gold	2013-05-05 09:46:38 EDT (Sun, 05 May 2013)
@@ -6,6 +6,7 @@
 <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">some_header</phrase><phrase role="special">></phrase>
     <phrase role="preprocessor">#include</phrase> <phrase role="string">"another_header.hpp"</phrase>
 <phrase role="preprocessor">#   define</phrase> <phrase role="identifier">A_MACRO</phrase> <phrase role="identifier">value</phrase>
+<phrase role="preprocessor">#define</phrase> <phrase role="identifier">stringize</phrase><phrase role="special">(</phrase><phrase role="identifier">hello</phrase><phrase role="special">)</phrase> <phrase role="special">#</phrase><phrase role="identifier">hello</phrase>
 <phrase role="comment">// No escape</phrase>
 <phrase role="comment">/* No escape */</phrase>
 <phrase role="comment">/* No escape
Modified: trunk/tools/quickbook/test/code_cpp-1_5.quickbook
==============================================================================
--- trunk/tools/quickbook/test/code_cpp-1_5.quickbook	(original)
+++ trunk/tools/quickbook/test/code_cpp-1_5.quickbook	2013-05-05 09:46:38 EDT (Sun, 05 May 2013)
@@ -5,6 +5,7 @@
     #include <some_header>
         #include "another_header.hpp"
     #   define A_MACRO value
+    #define stringize(hello) #hello
     // No escape
     /* No escape */
     /* No escape