Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53504 - in branches/quickbook-1.5: detail test
From: daniel_james_at_[hidden]
Date: 2009-05-31 11:35:12


Author: danieljames
Date: 2009-05-31 11:35:11 EDT (Sun, 31 May 2009)
New Revision: 53504
URL: http://svn.boost.org/trac/boost/changeset/53504

Log:
In quickbook 1.5 don't mix '..' and whitespace seperators for template arguments. Refs #1174
Added:
   branches/quickbook-1.5/test/fail-template-arguments3.quickbook (contents, props changed)
Text files modified:
   branches/quickbook-1.5/detail/actions.cpp | 34 +++++++++++++++++++++-------------
   branches/quickbook-1.5/test/Jamfile.v2 | 1 +
   branches/quickbook-1.5/test/templates_1_4.gold | 9 +++++++++
   branches/quickbook-1.5/test/templates_1_4.quickbook | 22 ++++++++++++++++++++++
   branches/quickbook-1.5/test/templates_1_5.gold | 6 ++++++
   branches/quickbook-1.5/test/templates_1_5.quickbook | 15 +++++++++++++++
   6 files changed, 74 insertions(+), 13 deletions(-)

Modified: branches/quickbook-1.5/detail/actions.cpp
==============================================================================
--- branches/quickbook-1.5/detail/actions.cpp (original)
+++ branches/quickbook-1.5/detail/actions.cpp 2009-05-31 11:35:11 EDT (Sun, 31 May 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: branches/quickbook-1.5/test/Jamfile.v2
==============================================================================
--- branches/quickbook-1.5/test/Jamfile.v2 (original)
+++ branches/quickbook-1.5/test/Jamfile.v2 2009-05-31 11:35:11 EDT (Sun, 31 May 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: branches/quickbook-1.5/test/fail-template-arguments3.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5/test/fail-template-arguments3.quickbook 2009-05-31 11:35:11 EDT (Sun, 31 May 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: branches/quickbook-1.5/test/templates_1_4.gold
==============================================================================
--- branches/quickbook-1.5/test/templates_1_4.gold (original)
+++ branches/quickbook-1.5/test/templates_1_4.gold 2009-05-31 11:35:11 EDT (Sun, 31 May 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: branches/quickbook-1.5/test/templates_1_4.quickbook
==============================================================================
--- branches/quickbook-1.5/test/templates_1_4.quickbook (original)
+++ branches/quickbook-1.5/test/templates_1_4.quickbook 2009-05-31 11:35:11 EDT (Sun, 31 May 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: branches/quickbook-1.5/test/templates_1_5.gold
==============================================================================
--- branches/quickbook-1.5/test/templates_1_5.gold (original)
+++ branches/quickbook-1.5/test/templates_1_5.gold 2009-05-31 11:35:11 EDT (Sun, 31 May 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: branches/quickbook-1.5/test/templates_1_5.quickbook
==============================================================================
--- branches/quickbook-1.5/test/templates_1_5.quickbook (original)
+++ branches/quickbook-1.5/test/templates_1_5.quickbook 2009-05-31 11:35:11 EDT (Sun, 31 May 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