Quickbook: Avoid expanding macros that are now invalid.

The macro syntax has been tightened up in 1.6, so that fewer characters
are available for macro identifiers. But macros can still be defined
using the older quickbook versions When such macros are defined, prevent
them from expanding in a quickbook 1.6 document.

[SVN r75630]
This commit is contained in:
Daniel James
2011-11-22 23:50:17 +00:00
parent 16fe2e20e0
commit e779bb6f08
5 changed files with 67 additions and 6 deletions

View File

@@ -461,10 +461,14 @@ namespace quickbook
;
local.macro =
// must not be followed by alpha or underscore
cl::eps_p(actions.macro
>> (cl::eps_p - (cl::alpha_p | '_')))
>> actions.macro [actions.do_macro]
cl::eps_p
( ( actions.macro
>> ~cl::eps_p(cl::alpha_p | '_')
// must not be followed by alpha or underscore
)
& macro_identifier // must be a valid macro for the current version
)
>> actions.macro [actions.do_macro]
;
local.template_ =
@@ -585,7 +589,7 @@ namespace quickbook
[
actions.to_value()
[
cl::eps_p(actions.macro >> local.simple_markup_end)
cl::eps_p((actions.macro & macro_identifier) >> local.simple_markup_end)
>> actions.macro [actions.do_macro]
| ~cl::eps_p(cl::f_ch_p(local.simple_markup.mark))
>> +( ~cl::eps_p
@@ -717,7 +721,6 @@ namespace quickbook
'[' >> *(local.line_dummy_block | (cl::anychar_p - (cl::eol_p | ']'))) >> ']'
;
// TODO: Prevent an old macro from being used in a 1.6 file.
macro_identifier =
qbk_since(106u)
>> +(cl::anychar_p - (cl::space_p | '[' | '\\' | ']'))

View File

@@ -15,4 +15,5 @@ import quickbook-testing : quickbook-test quickbook-error-test ;
test-suite quickbook.test :
[ quickbook-test versions-1_6 ]
[ quickbook-test invalid_macro-1_6 ]
;

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
<article id="invalid_macro_test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Invalid macro test</title>
<para>
Import:
</para>
<itemizedlist>
<listitem>
<simpara>
okay
</simpara>
</listitem>
<listitem>
<simpara>
__invalid\macro__
</simpara>
</listitem>
</itemizedlist>
<para>
Include:
</para>
<itemizedlist>
<listitem>
<simpara>
okay
</simpara>
</listitem>
<listitem>
<simpara>
bad
</simpara>
</listitem>
</itemizedlist>
</article>

View File

@@ -0,0 +1,14 @@
[article Invalid macro test
[quickbook 1.6]
]
Import:
[import invalid_macro-inc-1_1.qbk]
* __valid__
* __invalid\macro__
Include:
[include invalid_macro-inc-1_1.qbk]

View File

@@ -0,0 +1,7 @@
[quickbook 1.1]
[def __valid__ okay]
[def __invalid\macro__ bad]
* __valid__
* __invalid\macro__