Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55909 - in trunk/tools/quickbook: detail test
From: daniel_james_at_[hidden]
Date: 2009-08-31 07:37:05


Author: danieljames
Date: 2009-08-31 07:37:04 EDT (Mon, 31 Aug 2009)
New Revision: 55909
URL: http://svn.boost.org/trac/boost/changeset/55909

Log:
In quickbook 1.5 don't mix '..' and whitespace seperators for template arguments. Refs #1174
Added:
   trunk/tools/quickbook/test/fail-template-arguments3.quickbook (contents, props changed)
Text files modified:
   trunk/tools/quickbook/detail/actions.cpp | 34 +++++++++++++++++++++-------------
   trunk/tools/quickbook/test/Jamfile.v2 | 1 +
   trunk/tools/quickbook/test/templates_1_4.gold | 9 +++++++++
   trunk/tools/quickbook/test/templates_1_4.quickbook | 22 ++++++++++++++++++++++
   trunk/tools/quickbook/test/templates_1_5.gold | 6 ++++++
   trunk/tools/quickbook/test/templates_1_5.quickbook | 15 +++++++++++++++
   6 files changed, 74 insertions(+), 13 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:37:04 EDT (Mon, 31 Aug 2009)
@@ -524,9 +524,17 @@
           , boost::spirit::classic::file_position const& pos
         )
         {
- if (template_.size()-1 != template_info.size())
+ // Quickbook 1.4-: If there aren't enough parameters seperated by
+ // '..' then seperate the last parameter using
+ // whitespace.
+ // Quickbook 1.5+: If '..' isn't used to seperate the parameters
+ // then use whitespace to separate them
+ // (2 = template name + argument).
+
+ if (qbk_version_n < 105 || template_info.size() == 2)
             {
- while (template_.size()-1 > template_info.size())
+ // template_.size() - 1 because template_ also includes the body.
+ while (template_info.size() < template_.size()-1 )
                 {
                     // Try to break the last argument at the first space found
                     // and push it into the back of template_info. Do this
@@ -545,18 +553,18 @@
                     str = first;
                     template_info.push_back(second);
                 }
+ }
 
- if (template_.size()-1 != template_info.size())
- {
- detail::outerr(pos.file, pos.line)
- << "Invalid number of arguments passed. Expecting: "
- << template_.size()-2
- << " argument(s), got: "
- << template_info.size()-1
- << " argument(s) instead."
- << std::endl;
- return false;
- }
+ if (template_info.size() != template_.size()-1)
+ {
+ detail::outerr(pos.file, pos.line)
+ << "Invalid number of arguments passed. Expecting: "
+ << template_.size()-2
+ << " argument(s), got: "
+ << template_info.size()-1
+ << " argument(s) instead."
+ << std::endl;
+ return false;
             }
             return true;
         }

Modified: trunk/tools/quickbook/test/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/test/Jamfile.v2 (original)
+++ trunk/tools/quickbook/test/Jamfile.v2 2009-08-31 07:37:04 EDT (Mon, 31 Aug 2009)
@@ -29,6 +29,7 @@
     [ quickbook-fail-test fail-import ]
     [ quickbook-fail-test fail-template-arguments1 ]
     [ quickbook-fail-test fail-template-arguments2 ]
+ [ quickbook-fail-test fail-template-arguments3 ]
     [ quickbook-fail-test fail-cpp-mismatched-escape ]
     [ quickbook-fail-test fail-python-mismatched-escape ]
     [ quickbook-fail-test fail-post-process ]

Added: trunk/tools/quickbook/test/fail-template-arguments3.quickbook
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/fail-template-arguments3.quickbook 2009-08-31 07:37:04 EDT (Mon, 31 Aug 2009)
@@ -0,0 +1,6 @@
+[article Expect template to fail because there are not enough arguments on 1.5.
+ [quickbook 1.5]
+]
+
+[template ternary[x y z] {[x]-[y]-[z]}]
+[ternary 1..2 3 4]
\ No newline at end of file

Modified: trunk/tools/quickbook/test/templates_1_4.gold
==============================================================================
--- trunk/tools/quickbook/test/templates_1_4.gold (original)
+++ trunk/tools/quickbook/test/templates_1_4.gold 2009-08-31 07:37:04 EDT (Mon, 31 Aug 2009)
@@ -11,4 +11,13 @@
   <para>
     old
   </para>
+ <para>
+ {1-2} {1-2} {1-2 3 4} {1 2-3 4} {1 2 3-4} {[1-2} {1..2-3} {1..2-3}
+ </para>
+ <para>
+ {[binary 1 2- {1 2-y}} 4]
+ </para>
+ <para>
+ {1-2-3} {1-2-3} {1-2-3 4} {1 2-3-4} {[1-2-3}
+ </para>
 </article>

Modified: trunk/tools/quickbook/test/templates_1_4.quickbook
==============================================================================
--- trunk/tools/quickbook/test/templates_1_4.quickbook (original)
+++ trunk/tools/quickbook/test/templates_1_4.quickbook 2009-08-31 07:37:04 EDT (Mon, 31 Aug 2009)
@@ -14,3 +14,25 @@
 [template y new]
 [template foo3[a y] [a]]
 [foo3 [y] old]
+
+[/ 1.4 template arguments]
+
+[template binary[x y] {[x]-[y]}]
+[binary 1..2] [/ {1-2} ]
+[binary 1 2] [/ {1-2} ]
+[binary 1..2 3 4] [/ {1-2 3 4} ]
+[binary 1 2..3 4] [/ {1 2-3 4} ]
+[binary 1 2 3..4] [/ {1 2 3-4} ]
+[binary [1..2] [/ {(1-2} but with a square bracket ]
+[binary 1.\.2..3] [/ {1..2-3} ]
+[binary 1.\.2 3] [/ {1..2-3} ]
+
+[binary [binary 1 2..3] 4] [/ {[binary 1 2- {1 2-y}} 4] ]
+[/ This is obviously wrong, but I don't feel up to fixing it at the moment.]
+
+[template ternary[x y z] {[x]-[y]-[z]}]
+[ternary 1..2..3] [/ {1-2-3} ]
+[ternary 1 2 3] [/ {1-2-3} ]
+[ternary 1..2 3 4] [/ {1-2-3 4} ]
+[ternary 1 2..3 4] [/ {1 2-3-4} ]
+[ternary [1..2..3] [/ {(1-2-3} (but with a square bracket) ]
\ No newline at end of file

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:37:04 EDT (Mon, 31 Aug 2009)
@@ -14,4 +14,10 @@
   <para>
     foo foo
   </para>
+ <para>
+ {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} {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:37:04 EDT (Mon, 31 Aug 2009)
@@ -21,3 +21,18 @@
 [template echo[a b] [a] [b]]
 [template echo_twice[x] [echo [same [x]]..[same [x]]]]
 [echo_twice foo]
+
+[/ 1.5 template arguments]
+
+[template binary[x y] {[x]-[y]}]
+[binary 1..2] [/ {1-2} ]
+[binary 1 2] [/ {1-2} ]
+[binary 1..2 3 4] [/ {1-2 3 4} ]
+[binary 1 2..3 4] [/ {1 2-3 4} ]
+[binary 1 2 3..4] [/ {1 2 3-4} ]
+[binary 1.\.2..3] [/ {1..2-3} ]
+[binary 1.\.2 3] [/ {1..2-3} ]
+
+[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