|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55915 - in trunk/tools/quickbook: . detail test
From: daniel_james_at_[hidden]
Date: 2009-08-31 07:38:21
Author: danieljames
Date: 2009-08-31 07:38:20 EDT (Mon, 31 Aug 2009)
New Revision: 55915
URL: http://svn.boost.org/trac/boost/changeset/55915
Log:
Don't use seperators that are in brackets, or are escaped. Refs #2036.
Text files modified:
trunk/tools/quickbook/detail/actions.cpp | 52 +++++++++++++++++++++++++++++++++++++++
trunk/tools/quickbook/phrase.hpp | 30 +++++++++++++++++++++-
trunk/tools/quickbook/test/templates_1_5.gold | 6 ++++
trunk/tools/quickbook/test/templates_1_5.quickbook | 8 ++++++
4 files changed, 93 insertions(+), 3 deletions(-)
Modified: trunk/tools/quickbook/detail/actions.cpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.cpp (original)
+++ trunk/tools/quickbook/detail/actions.cpp 2009-08-31 07:38:20 EDT (Mon, 31 Aug 2009)
@@ -519,6 +519,56 @@
namespace
{
+ std::string::size_type find_bracket_end(std::string const& str, std::string::size_type pos)
+ {
+ unsigned int depth = 1;
+
+ while(depth > 0) {
+ pos = str.find_first_of("[]\\", pos);
+ if(pos == std::string::npos) return pos;
+
+ if(str[pos] == '\\')
+ {
+ pos += 2;
+ }
+ else
+ {
+ depth += (str[pos] == '[') ? 1 : -1;
+ ++pos;
+ }
+ }
+
+ return pos;
+ }
+
+ std::string::size_type find_first_seperator(std::string const& str)
+ {
+ if(qbk_version_n < 105) {
+ return str.find_first_of(" \t\r\n");
+ }
+ else {
+ std::string::size_type pos = 0;
+
+ while(true)
+ {
+ pos = str.find_first_of(" \t\r\n\\[", pos);
+ if(pos == std::string::npos) return pos;
+
+ switch(str[pos])
+ {
+ case '[':
+ pos = find_bracket_end(str, pos + 1);
+ break;
+ case '\\':
+ pos += 2;
+ break;
+ default:
+ return pos;
+ }
+ }
+ }
+ }
+
bool break_arguments(
std::vector<std::string>& template_info
, std::vector<std::string> const& template_
@@ -543,7 +593,7 @@
// arguments, or if there are no more spaces left.
std::string& str = template_info.back();
- std::string::size_type l_pos = str.find_first_of(" \t\r\n");
+ std::string::size_type l_pos = find_first_seperator(str);
if (l_pos == std::string::npos)
break;
std::string first(str.begin(), str.begin()+l_pos);
Modified: trunk/tools/quickbook/phrase.hpp
==============================================================================
--- trunk/tools/quickbook/phrase.hpp (original)
+++ trunk/tools/quickbook/phrase.hpp 2009-08-31 07:38:20 EDT (Mon, 31 Aug 2009)
@@ -10,6 +10,7 @@
#if !defined(BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP)
#define BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP
+#include "./detail/quickbook.hpp"
#include "detail/utils.hpp"
#include <boost/spirit/include/classic_core.hpp>
#include <boost/spirit/include/classic_confix.hpp>
@@ -142,7 +143,11 @@
;
template_args =
- template_args_1_4
+ if_p(qbk_since(105u)) [
+ template_args_1_5
+ ].else_p [
+ template_args_1_4
+ ]
;
template_args_1_4 =
@@ -160,6 +165,25 @@
'[' >> +template_arg_1_4 >> ']'
;
+ template_args_1_5 =
+ template_arg_1_5 [push_back_a(actions.template_info)]
+ >> *(
+ ".." >> template_arg_1_5 [push_back_a(actions.template_info)]
+ )
+ ;
+
+ template_arg_1_5 =
+ +(brackets_1_5 | ('\\' >> anychar_p) | (anychar_p - (str_p("..") | '[' | ']')))
+ ;
+
+ template_inner_arg_1_5 =
+ +(brackets_1_5 | ('\\' >> anychar_p) | (anychar_p - (str_p('[') | ']')))
+ ;
+
+ brackets_1_5 =
+ '[' >> +template_inner_arg_1_5 >> ']'
+ ;
+
inline_code =
'`' >>
(
@@ -427,7 +451,9 @@
simple_teletype, source_mode, template_,
quote, code_block, footnote, replaceable, macro,
dummy_block, cond_phrase, macro_identifier, template_args,
- template_args_1_4, template_arg_1_4, brackets_1_4
+ template_args_1_4, template_arg_1_4, brackets_1_4,
+ template_args_1_5, template_arg_1_5,
+ template_inner_arg_1_5, brackets_1_5,
;
rule<Scanner> const&
Modified: trunk/tools/quickbook/test/templates_1_5.gold
==============================================================================
--- trunk/tools/quickbook/test/templates_1_5.gold (original)
+++ trunk/tools/quickbook/test/templates_1_5.gold 2009-08-31 07:38:20 EDT (Mon, 31 Aug 2009)
@@ -18,6 +18,12 @@
{1-2} {1-2} {1-2 3 4} {1 2-3 4} {1 2 3-4} {1..2-3} {1..2-3}
</para>
<para>
+ { {1 2-3}-4} { {1 2-3}-4} { {1-2 3}-4}
+ </para>
+ <para>
+ {[1-2] 3} {[1-2] 3} {[1-2}
+ </para>
+ <para>
{1-2-3} {1-2-3}
</para>
</article>
Modified: trunk/tools/quickbook/test/templates_1_5.quickbook
==============================================================================
--- trunk/tools/quickbook/test/templates_1_5.quickbook (original)
+++ trunk/tools/quickbook/test/templates_1_5.quickbook 2009-08-31 07:38:20 EDT (Mon, 31 Aug 2009)
@@ -33,6 +33,14 @@
[binary 1.\.2..3] [/ {1..2-3} ]
[binary 1.\.2 3] [/ {1..2-3} ]
+[binary [binary 1 2..3]..4] [/ { {1 2-3}-4} ]
+[binary [binary 1 2..3] 4] [/ { {1 2-3}-4} ]
+[binary [binary 1 2 3]..4] [/ { {1-2 3}-4} ]
+
+[binary \[1 2\] 3] [/ {[1-2] 3} ]
+[binary \[1..2\] 3] [/ {[1-2] 3} ]
+[binary \[1 2] [/ {(1-2} ]
+
[template ternary[x y z] {[x]-[y]-[z]}]
[ternary 1..2..3] [/ {1-2-3} ]
[ternary 1 2 3] [/ {1-2-3} ]
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