mirror of
https://github.com/boostorg/quickbook.git
synced 2026-01-19 04:22:16 +00:00
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:
@@ -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 | '[' | '\\' | ']'))
|
||||
|
||||
@@ -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 ]
|
||||
;
|
||||
|
||||
36
test/versions/invalid_macro-1_6.gold
Normal file
36
test/versions/invalid_macro-1_6.gold
Normal 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>
|
||||
14
test/versions/invalid_macro-1_6.quickbook
Normal file
14
test/versions/invalid_macro-1_6.quickbook
Normal 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]
|
||||
7
test/versions/invalid_macro-inc-1_1.qbk
Normal file
7
test/versions/invalid_macro-inc-1_1.qbk
Normal file
@@ -0,0 +1,7 @@
|
||||
[quickbook 1.1]
|
||||
|
||||
[def __valid__ okay]
|
||||
[def __invalid\macro__ bad]
|
||||
|
||||
* __valid__
|
||||
* __invalid\macro__
|
||||
Reference in New Issue
Block a user