summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Hazel <ph10@hermes.cam.ac.uk>2008-02-07 10:34:23 +0000
committerNigel Metheringham <nigel@exim.org>2010-06-09 12:42:07 +0000
commit8c96bce3da514e576f4be2119eeb284c577f0f92 (patch)
tree4e2bd6779850415ce9c6d1484b4d37a3491b614e
parent254529d36aa7bc1877c028082ebc18dd112bc3dd (diff)
downloadexim4-8c96bce3da514e576f4be2119eeb284c577f0f92.tar.gz
Imported from /Users/nigel/Work/x/xfpt-0.06.tar.bz2.
-rw-r--r--README2
-rw-r--r--doc/xfpt.html254
-rw-r--r--doc/xfpt.pdfbin65447 -> 62566 bytes
-rw-r--r--doc/xfpt.xfpt142
-rw-r--r--src/dot.c24
-rw-r--r--src/error.c37
-rw-r--r--src/globals.c6
-rw-r--r--src/globals.h2
-rw-r--r--src/para.c4
-rw-r--r--src/read.c127
-rw-r--r--src/xfpt.c5
-rw-r--r--src/xfpt.h16
-rw-r--r--testing/infiles/0210
-rw-r--r--testing/infiles/02.inc3
-rw-r--r--testing/infiles/0314
-rw-r--r--testing/infiles/pic01.aspic.inc1
-rw-r--r--testing/infiles/pic01.eps.inc47
-rw-r--r--testing/outfiles/02.err12
-rw-r--r--testing/outfiles/0312
-rwxr-xr-xtesting/runtest7
20 files changed, 423 insertions, 302 deletions
diff --git a/README b/README
index f09bb1c75..688e1641c 100644
--- a/README
+++ b/README
@@ -26,5 +26,5 @@ to compile it on any system with a Standard C compiler and library.
Philip Hazel
January 2006
-Domain: cus.cam.ac.uk
+Domain: cam.ac.uk
Local part: ph10
diff --git a/doc/xfpt.html b/doc/xfpt.html
index b86fb4e4a..062c0803e 100644
--- a/doc/xfpt.html
+++ b/doc/xfpt.html
@@ -54,7 +54,7 @@ The xfpt plain text to XML processor</title>
<div>
<div>
<h1 class="title">
-<a id="id2488007">
+<a id="id2490183">
</a>
The xfpt plain text to XML processor</h1>
</div>
@@ -70,7 +70,7 @@ Hazel</span>
</div>
<div>
<p class="copyright">
-Copyright © 2007 University of Cambridge</p>
+Copyright © 2008 University of Cambridge</p>
</div>
<div>
<div class="revhistory">
@@ -83,9 +83,9 @@ Revision History</b>
</tr>
<tr>
<td align="left">
-Revision 0.03</td>
+Revision 0.06</td>
<td align="left">
-03 July 2007</td>
+06 February 2008</td>
<td align="left">
PH</td>
</tr>
@@ -103,7 +103,7 @@ Table of Contents</b>
<dl>
<dt>
<span xmlns="" class="chapter">
-<a id="toc0001" href="#id2527655">
+<a id="toc0001" href="#ID00">
1. Introduction</a>
</span>
</dt>
@@ -111,7 +111,7 @@ Table of Contents</b>
<dl>
<dt>
<span xmlns="" class="section">
-<a id="toc0002" href="#id2489811">
+<a id="toc0002" href="#ID01">
1.1. The <span xmlns="http://www.w3.org/1999/xhtml" class="emphasis">
<em>
xfpt</em>
@@ -121,7 +121,7 @@ command line</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0003" href="#id2491791">
+<a id="toc0003" href="#ID02">
1.2. A short <span xmlns="http://www.w3.org/1999/xhtml" class="emphasis">
<em>
xfpt</em>
@@ -137,7 +137,7 @@ example</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0005" href="#id2490210">
+<a id="toc0005" href="#ID04">
1.4. Format of directive lines</a>
</span>
</dt>
@@ -151,7 +151,7 @@ example</a>
</dd>
<dt>
<span xmlns="" class="chapter">
-<a id="toc0007" href="#id2490456">
+<a id="toc0007" href="#ID06">
2. Flag sequences</a>
</span>
</dt>
@@ -159,7 +159,7 @@ example</a>
<dl>
<dt>
<span xmlns="" class="section">
-<a id="toc0008" href="#id2490509">
+<a id="toc0008" href="#ID07">
2.1. Flag sequences for XML entities and <span xmlns="http://www.w3.org/1999/xhtml" class="emphasis">
<em>
xfpt</em>
@@ -169,25 +169,25 @@ variables</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0009" href="#id2537121">
+<a id="toc0009" href="#ID08">
2.2. Flag sequences for calling macros</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0010" href="#id2537142">
+<a id="toc0010" href="#ID09">
2.3. Other flag sequences</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0011" href="#id2537295">
+<a id="toc0011" href="#ID10">
2.4. Unrecognized flag sequences</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0012" href="#id2537308">
+<a id="toc0012" href="#ID11">
2.5. Standard flag sequences</a>
</span>
</dt>
@@ -195,7 +195,7 @@ variables</a>
</dd>
<dt>
<span xmlns="" class="chapter">
-<a id="toc0013" href="#id2537548">
+<a id="toc0013" href="#ID12">
3. Built-in directive processing</a>
</span>
</dt>
@@ -203,7 +203,7 @@ variables</a>
<dl>
<dt>
<span xmlns="" class="section">
-<a id="toc0014" href="#id2537570">
+<a id="toc0014" href="#ID13">
3.1. The <span xmlns="http://www.w3.org/1999/xhtml" class="bold">
<strong>
.arg</strong>
@@ -213,7 +213,7 @@ directive</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0015" href="#id2537638">
+<a id="toc0015" href="#ID14">
3.2. The <span xmlns="http://www.w3.org/1999/xhtml" class="bold">
<strong>
.eacharg</strong>
@@ -223,7 +223,7 @@ directive</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0016" href="#id2537808">
+<a id="toc0016" href="#ID15">
3.3. The <span xmlns="http://www.w3.org/1999/xhtml" class="bold">
<strong>
.echo</strong>
@@ -233,7 +233,7 @@ directive</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0017" href="#id2537828">
+<a id="toc0017" href="#ID16">
3.4. The <span xmlns="http://www.w3.org/1999/xhtml" class="bold">
<strong>
.endarg</strong>
@@ -243,7 +243,7 @@ directive</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0018" href="#id2537851">
+<a id="toc0018" href="#ID17">
3.5. The <span xmlns="http://www.w3.org/1999/xhtml" class="bold">
<strong>
.endeach</strong>
@@ -253,7 +253,7 @@ directive</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0019" href="#id2537873">
+<a id="toc0019" href="#ID18">
3.6. The <span xmlns="http://www.w3.org/1999/xhtml" class="bold">
<strong>
.endinliteral</strong>
@@ -263,7 +263,7 @@ directive</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0020" href="#id2537896">
+<a id="toc0020" href="#ID19">
3.7. The <span xmlns="http://www.w3.org/1999/xhtml" class="bold">
<strong>
.flag</strong>
@@ -273,7 +273,7 @@ directive</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0021" href="#id2537931">
+<a id="toc0021" href="#ID20">
3.8. The <span xmlns="http://www.w3.org/1999/xhtml" class="bold">
<strong>
.include</strong>
@@ -283,7 +283,7 @@ directive</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0022" href="#id2537956">
+<a id="toc0022" href="#ID21">
3.9. The <span xmlns="http://www.w3.org/1999/xhtml" class="bold">
<strong>
.inliteral</strong>
@@ -293,7 +293,7 @@ directive</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0023" href="#id2538001">
+<a id="toc0023" href="#ID22">
3.10. The <span xmlns="http://www.w3.org/1999/xhtml" class="bold">
<strong>
.literal</strong>
@@ -313,7 +313,7 @@ directive</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0025" href="#id2538217">
+<a id="toc0025" href="#ID24">
3.12. The <span xmlns="http://www.w3.org/1999/xhtml" class="bold">
<strong>
.nest</strong>
@@ -323,7 +323,7 @@ directive</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0026" href="#id2538290">
+<a id="toc0026" href="#ID25">
3.13. The <span xmlns="http://www.w3.org/1999/xhtml" class="bold">
<strong>
.nonl</strong>
@@ -333,7 +333,7 @@ directive</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0027" href="#id2538316">
+<a id="toc0027" href="#ID26">
3.14. The <span xmlns="http://www.w3.org/1999/xhtml" class="bold">
<strong>
.pop</strong>
@@ -343,7 +343,7 @@ directive</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0028" href="#id2538377">
+<a id="toc0028" href="#ID27">
3.15. The <span xmlns="http://www.w3.org/1999/xhtml" class="bold">
<strong>
.push</strong>
@@ -363,7 +363,7 @@ directive</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0030" href="#id2538603">
+<a id="toc0030" href="#ID29">
3.17. The <span xmlns="http://www.w3.org/1999/xhtml" class="bold">
<strong>
.set</strong>
@@ -383,61 +383,61 @@ directive</a>
<dl>
<dt>
<span xmlns="" class="section">
-<a id="toc0032" href="#id2538706">
+<a id="toc0032" href="#ID31">
4.1. Overall setup</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0033" href="#id2538763">
+<a id="toc0033" href="#ID32">
4.2. Chapters, sections, and subsections</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0034" href="#id2538870">
+<a id="toc0034" href="#ID33">
4.3. Prefaces, appendixes, and colophons</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0035" href="#id2538917">
+<a id="toc0035" href="#ID34">
4.4. URL references</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0036" href="#id2538987">
+<a id="toc0036" href="#ID35">
4.5. Itemized lists</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0037" href="#id2539061">
+<a id="toc0037" href="#ID36">
4.6. Ordered lists</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0038" href="#id2539153">
+<a id="toc0038" href="#ID37">
4.7. Variable lists</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0039" href="#id2539208">
+<a id="toc0039" href="#ID38">
4.8. Nested lists</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0040" href="#id2539230">
+<a id="toc0040" href="#ID39">
4.9. Displayed text</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0041" href="#id2539342">
+<a id="toc0041" href="#ID40">
4.10. Block quotes</a>
</span>
</dt>
@@ -449,31 +449,31 @@ directive</a>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0043" href="#id2539589">
+<a id="toc0043" href="#ID42">
4.12. Informal tables</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0044" href="#id2539865">
+<a id="toc0044" href="#ID43">
4.13. Formal tables</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0045" href="#id2539922">
+<a id="toc0045" href="#ID44">
4.14. Figures and images</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0046" href="#id2540084">
+<a id="toc0046" href="#ID45">
4.15. Footnotes</a>
</span>
</dt>
<dt>
<span xmlns="" class="section">
-<a id="toc0047" href="#id2540145">
+<a id="toc0047" href="#ID46">
4.16. Indexes</a>
</span>
</dt>
@@ -481,7 +481,7 @@ directive</a>
</dd>
</dl>
</div>
-<div class="chapter" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a href="#" id="id2527655">1. Introduction</a></h2></div></div></div><p><span class="emphasis"><em>xfpt</em></span> is a program that reads a marked-up ASCII source file, and converts it into
+<div class="chapter" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a href="#" id="ID00">1. Introduction</a></h2></div></div></div><p><span class="emphasis"><em>xfpt</em></span> is a program that reads a marked-up ASCII source file, and converts it into
XML. It was written with DocBook XML in mind, but can also be used for other
forms of XML. Unlike <span class="emphasis"><em>AsciiDoc</em></span> (<span class="bold"><strong><a href="http://www.methods.co.nz/asciidoc/" target="_top">http://www.methods.co.nz/asciidoc/</a></strong></span>),
<span class="emphasis"><em>xfpt</em></span> does not try to produce XML from a document that is also usable as a
@@ -525,7 +525,7 @@ Notwithstanding the previous paragraph, <span class="emphasis"><em>xfpt</em></sp
and in all cases when a literal ampersand or angle bracket is required in the
output, the appropriate XML entity reference (<code class="literal">&amp;amp;</code>, <code class="literal">&amp;lt;</code>, or
<code class="literal">&amp;gt;</code>, respectively) is generated.
-</p><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2489811">1.1 The <span xmlns="http://www.w3.org/1999/xhtml" class="emphasis"><em>xfpt</em></span> command line</a></h3></div></div></div><p>The format of the <span class="emphasis"><em>xfpt</em></span> command line is:
+</p><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID01">1.1 The <span xmlns="http://www.w3.org/1999/xhtml" class="emphasis"><em>xfpt</em></span> command line</a></h3></div></div></div><p>The format of the <span class="emphasis"><em>xfpt</em></span> command line is:
</p><div class="literallayout">
 <code class="literal">xfpt [</code><span class="emphasis"><em>options</em></span><code class="literal">] [</code><span class="emphasis"><em>input source</em></span><code class="literal">]</code><br />
</div><p>
@@ -541,9 +541,9 @@ be given as an output destination to refer to the standard output.
</p></dd><dt><span class="term"><span><strong class="option">-S</strong></span> <span class="emphasis"><em>&lt;directory path&gt;</em></span></span></dt><dd><p>
This option overrides the path to <span class="emphasis"><em>xfpt</em></span>’s library directory that is built into
the program. This makes it possible to use or test alternate libraries.
-</p></dd><div xmlns="" class="changed"><dt xmlns="http://www.w3.org/1999/xhtml"><span class="term"><span><strong class="option">-v</strong></span></span></dt><dd xmlns="http://www.w3.org/1999/xhtml"><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">
+</p></dd><dt><span class="term"><span><strong class="option">-v</strong></span></span></dt><dd><p>
This option causes <span class="emphasis"><em>xfpt</em></span> to output its version number and exit.
-</p></div></dd></div></dl></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2491791">1.2 A short <span xmlns="http://www.w3.org/1999/xhtml" class="emphasis"><em>xfpt</em></span> example</a></h3></div></div></div><p>Here is a very short example of a complete <span class="emphasis"><em>xfpt</em></span> input file that uses some of the
+</p></dd></dl></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID02">1.2 A short <span xmlns="http://www.w3.org/1999/xhtml" class="emphasis"><em>xfpt</em></span> example</a></h3></div></div></div><p>Here is a very short example of a complete <span class="emphasis"><em>xfpt</em></span> input file that uses some of the
standard macros and flags:
</p><pre class="literallayout">
.include stdflags
@@ -570,7 +570,7 @@ standard macros and flags:
“<span class="quote">modes</span>”):
</p><div class="itemizedlist"><ul type="disc"><li><p>
In the default mode, text is processed paragraph by paragraph.
-<sup>[<a id="id2490979" href="#ftn.id2490979">1</a>]</sup>
+<sup>[<a id="id2490955" href="#ftn.id2490955">1</a>]</sup>
The end of a paragraph is indicated by the end of the input, a blank line, or
by an occurrence of the <span class="bold"><strong>.literal</strong></span> directive. Other directives (for example,
<span class="bold"><strong>.include</strong></span>) do not of themselves terminate a paragraph. Most of the standard
@@ -625,7 +625,7 @@ to use literal layout mode if you require such output. Another solution, which
is used in the source for this document (where many examples show directive
lines), is to indent every displayed line by one space, and thereby avoid the
problem altogether.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2490210">1.4 Format of directive lines</a></h3></div></div></div><p>If an input line starts with a dot followed by a space, it is ignored by <span class="emphasis"><em>xfpt</em></span>.
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID04">1.4 Format of directive lines</a></h3></div></div></div><p>If an input line starts with a dot followed by a space, it is ignored by <span class="emphasis"><em>xfpt</em></span>.
This provides a facility for including comments in the input. Otherwise, the
dot must be followed by a directive or macro name, and possibly one or more
arguments. Arguments that are strings are delimited by white space unless they
@@ -674,11 +674,11 @@ A macro that can be called inline can always be called as a directive, but the
opposite is not always true. Macros are usually designed to be called either
one way or the other. However, the <span class="bold"><strong>.new</strong></span> and <span class="bold"><strong>.index</strong></span> macros in the
standard library are examples of macros that are designed be called either way.
-</p></div><div class="footnotes"><br /><hr width="100" align="left" /><div class="footnote"><p><sup>[<a id="ftn.id2490979" href="#id2490979">1</a>] </sup>
+</p></div><div class="footnotes"><br /><hr width="100" align="left" /><div class="footnote"><p><sup>[<a id="ftn.id2490955" href="#id2490955">1</a>] </sup>
<span xmlns="" class="changed"><span xmlns="http://www.w3.org/1999/xhtml">There is, however, a special case when a paragraph contains one or more
footnotes. In that situation, each part of the outer paragraph is processed
independently.</span></span>
-</p></div></div></div><div class="chapter" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a href="#" id="id2490456">2. Flag sequences</a></h2></div></div></div><p>Only one flag sequence is built-into the code itself. If an input line ends
+</p></div></div></div><div class="chapter" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a href="#" id="ID06">2. Flag sequences</a></h2></div></div></div><p>Only one flag sequence is built-into the code itself. If an input line ends
with three ampersands (ignoring trailing white space), the ampersands are
removed, and the next input line, with any leading white space removed, is
joined to the original line. This happens before any other processing, and may
@@ -691,7 +691,7 @@ involve any number of lines. Thus:
produces exactly the same output as:
</p><pre class="literallayout">
The quick brown fox.
-</pre><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2490509">2.1 Flag sequences for XML entities and <span xmlns="http://www.w3.org/1999/xhtml" class="emphasis"><em>xfpt</em></span> variables</a></h3></div></div></div><p>If an ampersand is followed by a # character, a number, and a semicolon, it is
+</pre><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID07">2.1 Flag sequences for XML entities and <span xmlns="http://www.w3.org/1999/xhtml" class="emphasis"><em>xfpt</em></span> variables</a></h3></div></div></div><p>If an ampersand is followed by a # character, a number, and a semicolon, it is
understood as a numerical reference to an XML entity, and is passed through
unmodified. The number can be decimal, or hexadecimal preceded by <code class="literal">x</code>. For
example:
@@ -715,11 +715,11 @@ of the previous types. In this case, the input text is passed to the output
without modification. For example:
</p><pre class="literallayout">
This is an Ohm sign: &amp;Ohm;.
-</pre></li></ul></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2537121">2.2 Flag sequences for calling macros</a></h3></div></div></div><p>If an ampersand is followed by a sequence of alphanumeric characters starting
+</pre></li></ul></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID08">2.2 Flag sequences for calling macros</a></h3></div></div></div><p>If an ampersand is followed by a sequence of alphanumeric characters starting
with a letter, terminated by an opening parenthesis, the characters between the
ampersand and the parenthesis are interpreted as the name of a macro. See
section <a href="#SECTcallingmacro" title="1.5&#xA0;Calling macros">1.5</a> for more details.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2537142">2.3 Other flag sequences</a></h3></div></div></div><p>Any other flag sequences that are needed must be defined by means of the
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID09">2.3 Other flag sequences</a></h3></div></div></div><p>Any other flag sequences that are needed must be defined by means of the
<span class="bold"><strong>.flag</strong></span> directive. These are of two types, standalone and paired. Both cases
define replacement text. This is always literal; it is not itself scanned for
flag occurrences.
@@ -737,28 +737,28 @@ A standalone flag consists of an ampersand followed by any number of
non-alphanumeric characters. When it is encountered, it is replaced by its
replacement text. For example, in the standard flag definitions, <code class="literal">&amp;&amp;</code>
is defined as a standalone flag with with the replacement text <code class="literal">&amp;amp;</code>.
-</p><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">
+</p><p>
A paired flag is defined as two sequences. The first takes the same form as a
standalone flag. The second also consists of non-alphanumeric characters, but
need not start with an ampersand. It is often defined as the reverse of the
first sequence. For example, in the standard definitions, <code class="literal">&amp;'</code> and
<code class="literal">'&amp;</code> are defined as a flag pair for enclosing text in an <code class="literal">&lt;emphasis&gt;</code>
element.
-</p></div><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">
+</p><p>
When the first sequence of a paired flag is encountered, its partner is
expected to be found within the same text unit. In the default mode, the units
are a paragraphs, or part-paragraphs if footnotes intervene. In literal layout
mode, the text is processed line by line. Each member of the pair is replaced
by its replacement text.
-</p></div><p>
+</p><p>
Multiple occurrences of paired flags must be correctly nested. Note that,
though <span class="emphasis"><em>xfpt</em></span> diagnoses an error for badly nested flag pairs, it does not prevent
you from generating invalid XML. For example, DocBook does not allow
<code class="literal">&lt;emphasis&gt;</code> within <code class="literal">&lt;literal&gt;</code>, though it does allow <code class="literal">&lt;literal&gt;</code> within
<code class="literal">&lt;emphasis&gt;</code>.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2537295">2.4 Unrecognized flag sequences</a></h3></div></div></div><p>If an ampersand is not followed by a character sequence in one of the forms
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID10">2.4 Unrecognized flag sequences</a></h3></div></div></div><p>If an ampersand is not followed by a character sequence in one of the forms
described in the preceding sections, an error occurs.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2537308">2.5 Standard flag sequences</a></h3></div></div></div><p>These are the standalone flag sequences that are defined in the <em class="filename">stdflags</em>
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID11">2.5 Standard flag sequences</a></h3></div></div></div><p>These are the standalone flag sequences that are defined in the <em class="filename">stdflags</em>
file in the <span class="emphasis"><em>xfpt</em></span> library:
</p><div class="literallayout">
 <code class="literal">&amp;&amp;        </code> becomes <code class="literal"> &amp;amp;</code> (ampersand)<br />
@@ -784,10 +784,10 @@ For example, if you want to include a literal XML element in your output, you
can do it like this: <code class="literal">&amp;&lt;element&gt;&amp;</code>. If you want to include a longer
sequence of literal XML, changing to the literal XML mode may be more
convenient.
-</p></div></div><div class="chapter" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a href="#" id="id2537548">3. Built-in directive processing</a></h2></div></div></div><p>The directives that are built into the code of <span class="emphasis"><em>xfpt</em></span> are now described in
+</p></div></div><div class="chapter" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a href="#" id="ID12">3. Built-in directive processing</a></h2></div></div></div><p>The directives that are built into the code of <span class="emphasis"><em>xfpt</em></span> are now described in
alphabetical order. You can see more examples of their use in the descriptions
of the standard macros in chapter <a href="#CHAPstdmac" title="4.&#xA0;The standard macros for DocBook">4</a>.
-</p><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2537570">3.1 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.arg</strong></span> directive</a></h3></div></div></div><p>This directive may appear only within the body of a macro. It must be followed
+</p><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID13">3.1 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.arg</strong></span> directive</a></h3></div></div></div><p>This directive may appear only within the body of a macro. It must be followed
by a single number, optionally preceded by a minus sign. If the number is
positive (no minus sign), subsequent lines, up to a <span class="bold"><strong>.endarg</strong></span> directive, are
skipped unless the macro has been called with at least that number of
@@ -807,19 +807,18 @@ for the given argument. For example:
and the second one is not empty.
.endarg
.endmacro
-</pre><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">
+</pre><p>
Note that if a macro is defined with default values for its arguments, these
are not counted by the <span class="bold"><strong>.arg</strong></span> directive, which looks only at the actual
arguments in a particular macro call.
-</p></div><p>
+</p><p>
The <span class="bold"><strong>.arg</strong></span> directive may be nested.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2537638">3.2 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.eacharg</strong></span> directive</a></h3></div></div></div><p>This directive may appear only within the body of a macro. It may optionally be
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID14">3.2 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.eacharg</strong></span> directive</a></h3></div></div></div><p>This directive may appear only within the body of a macro. It may optionally be
followed by a single number; if omitted the value is taken to be 1. Subsequent
lines, up to a <span class="bold"><strong>.endeach</strong></span> directive, are processed multiple times, once for
-each remaining argument. Unlike <span class="bold"><strong>.arg</strong></span>, an argument that is an empty string
-is not treated specially. <span xmlns="" class="changed"><span xmlns="http://www.w3.org/1999/xhtml">However, like <span class="bold"><strong>.arg</strong></span>, only the actual
-arguments of a macro call are considered. Default argument values do not
-count.</span></span>
+each remaining argument. Unlike <span class="bold"><strong>.arg</strong></span>, an argument that is an empty string
+is not treated specially. However, like <span class="bold"><strong>.arg</strong></span>, only the actual arguments of
+a macro call are considered. Default argument values do not count.
</p><p>
The number given with <span class="bold"><strong>.eacharg</strong></span> defines which argument to start with. If the
macro is called with fewer arguments, the lines up to <span class="bold"><strong>.endeach</strong></span> are skipped,
@@ -850,14 +849,14 @@ fifth argument:
</pre><p>
The <span class="bold"><strong>.eacharg</strong></span> directive may in principle be nested, though this does not
seem useful in practice.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2537808">3.3 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.echo</strong></span> directive</a></h3></div></div></div><p>This directive takes a single string argument. It writes it to the standard
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID15">3.3 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.echo</strong></span> directive</a></h3></div></div></div><p>This directive takes a single string argument. It writes it to the standard
error stream. Within a macro, argument substitution takes place, but no other
processing is done on the string. This directive can be useful for debugging
macros or writing comments to the user.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2537828">3.4 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.endarg</strong></span> directive</a></h3></div></div></div><p>See the description of <span class="bold"><strong>.arg</strong></span> above.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2537851">3.5 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.endeach</strong></span> directive</a></h3></div></div></div><p>See the description of <span class="bold"><strong>.eacharg</strong></span> above.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2537873">3.6 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.endinliteral</strong></span> directive</a></h3></div></div></div><p>See the description of <span class="bold"><strong>.inliteral</strong></span> below.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2537896">3.7 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.flag</strong></span> directive</a></h3></div></div></div><p>This directive is used to define flag sequences. The directive must be followed
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID16">3.4 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.endarg</strong></span> directive</a></h3></div></div></div><p>See the description of <span class="bold"><strong>.arg</strong></span> above.
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID17">3.5 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.endeach</strong></span> directive</a></h3></div></div></div><p>See the description of <span class="bold"><strong>.eacharg</strong></span> above.
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID18">3.6 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.endinliteral</strong></span> directive</a></h3></div></div></div><p>See the description of <span class="bold"><strong>.inliteral</strong></span> below.
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID19">3.7 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.flag</strong></span> directive</a></h3></div></div></div><p>This directive is used to define flag sequences. The directive must be followed
either by a standalone flag sequence and one string in quotes, or by a flag
pair and two strings in quotes. White space separates these items. For example:
</p><pre class="literallayout">
@@ -867,16 +866,18 @@ pair and two strings in quotes. White space separates these items. For example:
There are more examples in the definitions of the standard flags. If you
redefine an existing flag, the new definition overrides the old. There is no
way to revert to the previous definition.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2537931">3.8 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.include</strong></span> directive</a></h3></div></div></div><p>This directive must be followed by a single string argument that is the path to
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID20">3.8 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.include</strong></span> directive</a></h3></div></div></div><p>This directive must be followed by a single string argument that is the path to
a file. The contents of the file are read and incorporated into the input at
this point. If the string does not contain any slashes, the path to the <span class="emphasis"><em>xfpt</em></span>
-library is prepended. Otherwise, the path is used unaltered.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2537956">3.9 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.inliteral</strong></span> directive</a></h3></div></div></div><p>This directive may appear only within the body of a macro. It must be followed
+library is prepended. Otherwise, the path is used unaltered. <span xmlns="" class="changed"><span xmlns="http://www.w3.org/1999/xhtml">If
+<span class="bold"><strong>.include</strong></span> is used inside a macro, it is evaluated each time the macro is
+called, and thus can be used to include a different file on each occasion.</span></span>
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID21">3.9 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.inliteral</strong></span> directive</a></h3></div></div></div><p>This directive may appear only within the body of a macro. It must be followed
by one of the words “<span class="quote">layout</span>”, “<span class="quote">text</span>”, “<span class="quote">off</span>”, or “<span class="quote">xml</span>”. If the current
literal mode does not correspond to the word, subsequent lines, up to a
<span class="bold"><strong>.endinliteral</strong></span> directive, are skipped. The <span class="bold"><strong>.inliteral</strong></span> directive may be
nested.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2538001">3.10 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.literal</strong></span> directive</a></h3></div></div></div><p>This must be followed by one of the words “<span class="quote">layout</span>”, “<span class="quote">text</span>”, “<span class="quote">off</span>”, or
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID22">3.10 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.literal</strong></span> directive</a></h3></div></div></div><p>This must be followed by one of the words “<span class="quote">layout</span>”, “<span class="quote">text</span>”, “<span class="quote">off</span>”, or
“<span class="quote">xml</span>”. It forces an end to a previous paragraph, if there is one, and then
switches between processing modes. The default mode is the “<span class="quote">off</span>” mode, in
which text is processed paragraph by paragraph, and flags are recognized.
@@ -934,26 +935,26 @@ call it, because <span class="emphasis"><em>xfpt</em></span> looks for built-in
It is possible to define a macro within a macro, though clearly care must be
taken with argument references to ensure that substitutions happen at the right
level.
-</p></div><div xmlns="" class="changed"><div xmlns="http://www.w3.org/1999/xhtml" class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2538217">3.12 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.nest</strong></span> directive</a></h3></div></div></div><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">This directive must be followed by one of the words “<span class="quote">begin</span>” or “<span class="quote">end</span>”. It is
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID24">3.12 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.nest</strong></span> directive</a></h3></div></div></div><p>This directive must be followed by one of the words “<span class="quote">begin</span>” or “<span class="quote">end</span>”. It is
used to delimit a nested sequence of independent text items that occurs inside
another, such as the contents of a footnote inside a paragraph. This directive
is usually used inside a macro. For example, a <span class="bold"><strong>footnote</strong></span> macro could be
defined like this:
-</p></div><div xmlns="" class="changed"><pre xmlns="http://www.w3.org/1999/xhtml" class="literallayout">
+</p><pre class="literallayout">
.macro footnote
&amp;&lt;footnote&gt;&amp;
.nest begin
.endmacro
-</pre></div><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">
+</pre><p>
At the start of a nested sequence, the current mode and paragraph state are
remembered and <span class="emphasis"><em>xfpt</em></span> then reverts to the default mode and “<span class="quote">not in a paragraph</span>”.
At the end of a nested sequence, if a paragraph has been started, it is
terminated, and then <span class="emphasis"><em>xfpt</em></span> reverts to the previous state.
-</p></div></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2538290">3.13 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.nonl</strong></span> directive</a></h3></div></div></div><p>This directive must be followed by a single string argument. It is processed
-as normal text, but without a newline at the end. This facility is useful in
-macros when constructing a single data line from several text fragments. See
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID25">3.13 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.nonl</strong></span> directive</a></h3></div></div></div><p>This directive must be followed by a single string argument. It is processed
+as <span xmlns="" class="changed"><span xmlns="http://www.w3.org/1999/xhtml">an input line</span></span> without a newline at the end. This facility is useful
+in macros when constructing a single data line from several text fragments. See
for example the <span class="bold"><strong>.new</strong></span> macro in the standard macros.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2538316">3.14 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.pop</strong></span> directive</a></h3></div></div></div><p><span class="emphasis"><em>xfpt</em></span> keeps a stack of text strings that are manipulated by the <span class="bold"><strong>.push</strong></span> and
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID26">3.14 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.pop</strong></span> directive</a></h3></div></div></div><p><span class="emphasis"><em>xfpt</em></span> keeps a stack of text strings that are manipulated by the <span class="bold"><strong>.push</strong></span> and
<span class="bold"><strong>.pop</strong></span> directives. When the end of the input is reached, any strings that
remain on the stack are popped off, processed for flags, and written to the
output.
@@ -966,7 +967,7 @@ to and including the one that matches.
</p><p>
If <span class="bold"><strong>.pop</strong></span> is given without a following letter, it pops one string off the
stack and writes it out. If there is nothing on the stack, an error occurs.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2538377">3.15 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.push</strong></span> directive</a></h3></div></div></div><p>This directive pushes a string onto the stack. If the rest of the command line
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID27">3.15 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.push</strong></span> directive</a></h3></div></div></div><p>This directive pushes a string onto the stack. If the rest of the command line
starts with an upper case letter followed by white space, that letter is
associated with the string that is pushed, which consists of the rest of the
line. For example, the <span class="bold"><strong>.chapter</strong></span> macro contains this line:
@@ -1009,7 +1010,7 @@ though it does still seem to process it correctly.
For handling the most common case (setting and unsetting “<span class="quote">changed</span>”), the
standard macros <span class="bold"><strong>.new</strong></span> and <span class="bold"><strong>.wen</strong></span> are provided (see section
<a href="#SECTrevmacs" title="4.11&#xA0;Revision markings">4.11</a>).
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2538603">3.17 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.set</strong></span> directive</a></h3></div></div></div><p>This directive must be followed by a name and a text string. It defines a user
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID29">3.17 The <span xmlns="http://www.w3.org/1999/xhtml" class="bold"><strong>.set</strong></span> directive</a></h3></div></div></div><p>This directive must be followed by a name and a text string. It defines a user
variable and gives it a name. A reference to the name in the style of an XML
entity causes the string to be substituted, without further processing. For
example:
@@ -1031,7 +1032,7 @@ is going to use these features should start with:
All the standard macros except <span class="bold"><strong>new</strong></span>, <span class="bold"><strong>index</strong></span>, and <span class="bold"><strong>url</strong></span> are intended to
be called as directive lines. Their names are therefore shown with a leading
dot in the discussion below.
-</p><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2538706">4.1 Overall setup</a></h3></div></div></div><p>There are two macros that should be used only once, at the start of the
+</p><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID31">4.1 Overall setup</a></h3></div></div></div><p>There are two macros that should be used only once, at the start of the
document. The <span class="bold"><strong>.docbook</strong></span> macro has no arguments. It inserts into the output
file the standard header material for a DocBook XML file, which is:
</p><pre class="literallayout">
@@ -1041,7 +1042,7 @@ file the standard header material for a DocBook XML file, which is:
</pre><p>
The <span class="bold"><strong>.book</strong></span> macro has no arguments. It generates <code class="literal">&lt;book&gt;</code> and pushes
<code class="literal">&lt;/book&gt;</code> onto the stack so that it will be output at the end.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2538763">4.2 Chapters, sections, and subsections</a></h3></div></div></div><p>Chapters, sections, and subsections are supported by three macros that all
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID32">4.2 Chapters, sections, and subsections</a></h3></div></div></div><p>Chapters, sections, and subsections are supported by three macros that all
operate in the same way. They are <span class="bold"><strong>.chapter</strong></span>, <span class="bold"><strong>.section</strong></span>, and
<span class="bold"><strong>.subsection</strong></span>. They take either one, two, or three arguments. The first
argument is the title. If a second argument is present, and is not an empty
@@ -1073,10 +1074,10 @@ controlled by the stylesheet when the XML is processed.
These three macros use the stack to ensure that each chapter, section, and
subsection is terminated at the correct point. For example, starting a new
section automatically terminates an open subsection and a previous section.
-</p></div><div xmlns="" class="changed"><div xmlns="http://www.w3.org/1999/xhtml" class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2538870">4.3 Prefaces, appendixes, and colophons</a></h3></div></div></div><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">The macros <span class="bold"><strong>.preface</strong></span>, <span class="bold"><strong>.appendix</strong></span>, and <span class="bold"><strong>.colophon</strong></span> operate in the same
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID33">4.3 Prefaces, appendixes, and colophons</a></h3></div></div></div><p>The macros <span class="bold"><strong>.preface</strong></span>, <span class="bold"><strong>.appendix</strong></span>, and <span class="bold"><strong>.colophon</strong></span> operate in the same
way as <span class="bold"><strong>.chapter</strong></span>, except that the first and the last have the default title
strings “<span class="quote">Preface</span>” and “<span class="quote">Colophon</span>”.
-</p></div></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2538917">4.4 URL references</a></h3></div></div></div><p>The <span class="bold"><strong>url</strong></span> macro generates URL references, and is intended to be called inline
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID34">4.4 URL references</a></h3></div></div></div><p>The <span class="bold"><strong>url</strong></span> macro generates URL references, and is intended to be called inline
within the text that is being processed. It generates a <code class="literal">&lt;ulink&gt;</code> element,
and has either one or two arguments. The first argument is the URL, and the
second is the text that describes it. For example:
@@ -1091,7 +1092,7 @@ If the second argument is absent, the contents of the first argument are used
instead. If <span class="bold"><strong>url</strong></span> is called as a directive, there will be a newline in the
output after <code class="literal">&lt;/ulink&gt;</code>, which in most cases (such as the example above), you
do not want.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2538987">4.5 Itemized lists</a></h3></div></div></div><p>The <span class="bold"><strong>.ilist</strong></span> macro marks the start of an itemized list, the items of which
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID35">4.5 Itemized lists</a></h3></div></div></div><p>The <span class="bold"><strong>.ilist</strong></span> macro marks the start of an itemized list, the items of which
are normally rendered with bullets or similar markings. The macro can
optionally be called with one argument, for which there is no default. If the
argument is present, it is used to add a <code class="literal">mark=</code> attribute to the
@@ -1110,7 +1111,7 @@ For example:
.endlist
</pre><p>
There may be more than one paragraph in an item.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2539061">4.6 Ordered lists</a></h3></div></div></div><p>The <span class="bold"><strong>.olist</strong></span> macro marks the start of an ordered list, the items of which are
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID36">4.6 Ordered lists</a></h3></div></div></div><p>The <span class="bold"><strong>.olist</strong></span> macro marks the start of an ordered list, the items of which are
numbered. If no argument is given, arabic numerals are used. One of the
following words can be given as the macro’s argument to specify the numeration:
</p><div class="literallayout">
@@ -1131,7 +1132,7 @@ For example:
.endlist
</pre><p>
There may be more than one paragraph in an item.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2539153">4.7 Variable lists</a></h3></div></div></div><p>A variable list is one in which each entry is composed of a set of one or more
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID37">4.7 Variable lists</a></h3></div></div></div><p>A variable list is one in which each entry is composed of a set of one or more
terms and an associated description. Typically, the terms are printed in a
style that makes them stand out, and the description is indented underneath.
The start of a variable list is indicated by the <span class="bold"><strong>.vlist</strong></span> macro, which has
@@ -1149,12 +1150,12 @@ This is followed by the body of the entry. The list is terminated by the
.endlist
</pre><p>
As for the other lists, there may be more than one paragraph in an item.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2539208">4.8 Nested lists</a></h3></div></div></div><p>Lists may be nested as required. Some DocBook processors automatically choose
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID38">4.8 Nested lists</a></h3></div></div></div><p>Lists may be nested as required. Some DocBook processors automatically choose
different bullets for nested itemized lists, but others do not. The
<span class="bold"><strong>.endlist</strong></span> macro has no useful arguments. Any text that follows it is
treated as a comment. This can provide an annotation facility that may make the
input easier to understand when lists are nested.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2539230">4.9 Displayed text</a></h3></div></div></div><p>In displayed text each non-directive input line generates one output line. The
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID39">4.9 Displayed text</a></h3></div></div></div><p>In displayed text each non-directive input line generates one output line. The
<code class="literal">&lt;literallayout&gt;</code> DocBook element is used to achieve this. Two kinds of
displayed text are supported by the standard macros. They differ in their
handling of the text itself.
@@ -1185,7 +1186,7 @@ monospaced font. For example:
</pre><p>
As the examples illustrate, both kinds of display are terminated by the
<span class="bold"><strong>.endd</strong></span> macro.
-</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2539342">4.10 Block quotes</a></h3></div></div></div><p>The macro pair <span class="bold"><strong>.blockquote</strong></span> and <span class="bold"><strong>.endblockquote</strong></span> are used to wrap the
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID40">4.10 Block quotes</a></h3></div></div></div><p>The macro pair <span class="bold"><strong>.blockquote</strong></span> and <span class="bold"><strong>.endblockquote</strong></span> are used to wrap the
lines between them in a <code class="literal">&lt;blockquote&gt;</code> element.
</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="SECTrevmacs">4.11 Revision markings</a></h3></div></div></div><p>Two macros are provided to simplify setting and unsetting the “<span class="quote">changed</span>”
revision marking (see section <a href="#SECTrevision" title="3.16&#xA0;The .revision directive">3.16</a>). When the revised text is
@@ -1234,11 +1235,11 @@ This usage works with both <span class="bold"><strong>.display</strong></span> a
section you can also call <span class="bold"><strong>.new</strong></span> with an argument, either as a directive or
inline. This does not work for <span class="bold"><strong>.code</strong></span> because its lines are processed in
literal text mode.
-</p><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">
+</p><p>
If you want to add revision indications to part of a table, you must use an
inline call of <span class="bold"><strong>new</strong></span> within an argument of the <span class="bold"><strong>.row</strong></span> macro (see below).
This is the only usage that works in this case.
-</p></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2539589">4.12 Informal tables</a></h3></div></div></div><p>The <span class="bold"><strong>.itable</strong></span> macro starts an informal (untitled) table with some basic
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID42">4.12 Informal tables</a></h3></div></div></div><p>The <span class="bold"><strong>.itable</strong></span> macro starts an informal (untitled) table with some basic
parameterization. If you are working on a large document that has many tables
with the same parameters, the best approach is to define your own table macros,
possibly calling the standard one with specific arguments.
@@ -1286,68 +1287,69 @@ The <span class="bold"><strong>.row</strong></span> macro does not set the <code
all current XML processors. However, you can use an inline call of the <span class="bold"><strong>new</strong></span>
macro within an entry to generate a <code class="literal">&lt;phrase&gt;</code> element with <code class="literal">revisionflag</code>
set.
-</p></div><div xmlns="" class="changed"><div xmlns="http://www.w3.org/1999/xhtml" class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2539865">4.13 Formal tables</a></h3></div></div></div><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">The <span class="bold"><strong>.table</strong></span> macro starts a formal table, that is, a table that has a title,
+</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID43">4.13 Formal tables</a></h3></div></div></div><p>The <span class="bold"><strong>.table</strong></span> macro starts a formal table, that is, a table that has a title,
and which can be cross referenced. The first argument of this macro is the
table’s title; the second is an identifier for cross-referencing. If you are
not going to reference the table, an empty string must be supplied. From the
third argument onwards, the arguments are identical to the <span class="bold"><strong>.itable</strong></span> macro.
For example:
-</p></div><div xmlns="" class="changed"><pre xmlns="http://www.w3.org/1999/xhtml" class="literallayout">
+</p><pre class="literallayout">
.table "A title for the table" "" all 1 1 2 1in left 2in center
.row "cell 11" "cell 12"
.row "cell 21" "cell 22"
.endtable
-</pre></div></div></div><div xmlns="" class="changed"><div xmlns="http://www.w3.org/1999/xhtml" class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2539922">4.14 Figures and images</a></h3></div></div></div><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">A figure is enclosed between <span class="bold"><strong>.figure</strong></span> and <span class="bold"><strong>.endfigure</strong></span> macros. The first
+</pre></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID44">4.14 Figures and images</a></h3></div></div></div><p>A figure is enclosed between <span class="bold"><strong>.figure</strong></span> and <span class="bold"><strong>.endfigure</strong></span> macros. The first
argument of <span class="bold"><strong>.figure</strong></span> provides a title for the figure. The second is
optional; if present, it is a tag for references to the figure.
-</p></div><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">
+</p><p>
A figure normally contains an image. The <span class="bold"><strong>.image</strong></span> macro can be used in simple
cases. It generates a <code class="literal">&lt;mediaobject&gt;</code> element containing an
-<code class="literal">&lt;imageobject&gt;</code>. The first argument is the name of the file containing the
-image. The remaining arguments are optional; if any one is not needed, an empty
-string must be supplied as a placeholder.
-</p></div><div xmlns="" class="changed"><div xmlns="http://www.w3.org/1999/xhtml" class="itemizedlist"><ul type="disc"><li><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">
+<code class="literal">&lt;imageobject&gt;</code>. The first argument is the name of the file containing the
+image. The remaining arguments are optional; <span xmlns="" class="changed"><span xmlns="http://www.w3.org/1999/xhtml">an empty string must be
+supplied as a placeholder when one that is not required is followed by one that
+is set.</span></span>
+</p><div class="itemizedlist"><ul type="disc"><li><p>
The second argument specifies a scaling factor for the image, as a percentage.
Thus, a value of 50 reduces the image to half size.
-</p></div></li><li><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">
+</p></li><li><p>
The third argument specifies an alignment for the image. It must be one of
-<code class="literal">left</code>, <code class="literal">right</code> or <code class="literal">center</code> (or even <code class="literal">centre</code> if the DocBook processor
-you are using can handle it).
-</p></div></li><li><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">
+<code class="literal">left</code> <span xmlns="" class="changed"><span xmlns="http://www.w3.org/1999/xhtml">(default)</span></span>, <code class="literal">right</code> or <code class="literal">center</code> (or even <code class="literal">centre</code> if the
+DocBook processor you are using can handle it).
+</p></li><li><p>
The fourth and fifth arguments specify the depth and width, respectively. How
these values are handled depends on the processing software.
-</p></div></li></ul></div></div><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">
+</p></li></ul></div><p>
Here is an example of the input for a figure, with all the image options
defaulted:
-</p></div><div xmlns="" class="changed"><pre xmlns="http://www.w3.org/1999/xhtml" class="literallayout">
+</p><pre class="literallayout">
.figure "My figure's title" "FIGfirst"
.image figure01.eps
.endfigure
-</pre></div><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">
+</pre><p>
Here is another example, where the figure is reduced to 80% and centred:
-</p></div><div xmlns="" class="changed"><pre xmlns="http://www.w3.org/1999/xhtml" class="literallayout">
+</p><pre class="literallayout">
.figure "A reduced figure"
.image figure02.eps 80 center
.endfigure
-</pre></div></div></div><div xmlns="" class="changed"><div xmlns="http://www.w3.org/1999/xhtml" class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2540084">4.15 Footnotes</a></h3></div></div></div><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">Footnotes can be specified between <span class="bold"><strong>.footnote</strong></span> and <span class="bold"><strong>.endnote</strong></span> macros.
+</pre></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID45">4.15 Footnotes</a></h3></div></div></div><p>Footnotes can be specified between <span class="bold"><strong>.footnote</strong></span> and <span class="bold"><strong>.endnote</strong></span> macros.
Within a footnote there can be any kind of text item, including displays and
tables. When a footnote occurs in the middle of a paragraph, paired flags
must not straddle the footnote. This example is wrong:
-</p></div><div xmlns="" class="changed"><pre xmlns="http://www.w3.org/1999/xhtml" class="literallayout">
+</p><pre class="literallayout">
The &amp;'quick
.footnote
That's really fast.
.endf
brown'&amp; fox.
-</pre></div><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">
+</pre><p>
The correct markup for this example is:
-</p></div><div xmlns="" class="changed"><pre xmlns="http://www.w3.org/1999/xhtml" class="literallayout">
+</p><pre class="literallayout">
The &amp;'quick'&amp;
.footnote
That's really fast.
.endf
&amp;'brown'&amp; fox.
-</pre></div></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="id2540145">4.16 Indexes</a></h3></div></div></div><p>The <span class="bold"><strong>.index</strong></span> macro generates <code class="literal">&lt;indexterm&gt;</code> elements (index entries) in the
+</pre></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 xmlns="" class="title"><a xmlns="http://www.w3.org/1999/xhtml" href="#" id="ID46">4.16 Indexes</a></h3></div></div></div><p>The <span class="bold"><strong>.index</strong></span> macro generates <code class="literal">&lt;indexterm&gt;</code> elements (index entries) in the
output. It takes one or two arguments. The first is the text for the primary
index term, and the second, if present, specifies a secondary index term. This
macro can be called either from a directive line, or inline. However, it is
@@ -1356,20 +1358,20 @@ example:
</p><pre class="literallayout">
.index goose "wild chase"
The chasing of wild geese...
-</pre><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">
+</pre><p>
You can generate “<span class="quote">see</span>” and “<span class="quote">see also</span>” index entries by using <span class="bold"><strong>.index-see</strong></span>
and <span class="bold"><strong>.index-seealso</strong></span> instead of <span class="bold"><strong>.index</strong></span>. The first argument of these
macros is the text for the “<span class="quote">see</span>”. For example:
-</p></div><div xmlns="" class="changed"><pre xmlns="http://www.w3.org/1999/xhtml" class="literallayout">
+</p><pre class="literallayout">
.index-see "chase" "wild goose"
-</pre></div><div xmlns="" class="changed"><p xmlns="http://www.w3.org/1999/xhtml">
+</pre><p>
This generates:
-</p></div><div xmlns="" class="changed"><pre xmlns="http://www.w3.org/1999/xhtml" class="literallayout">
+</p><pre class="literallayout">
&lt;indexterm&gt;
&lt;primary&gt;wild goose&lt;/primary&gt;
&lt;see&gt;chase&lt;/see&gt;
&lt;/indexterm&gt;
-</pre></div><p>
+</pre><p>
If you want to generate an index entry for a range of pages, you can use the
<span class="bold"><strong>.index-from</strong></span> and <span class="bold"><strong>.index-to</strong></span> macros. The first argument of each of them is
an ID that ties them together. The second and third arguments of
diff --git a/doc/xfpt.pdf b/doc/xfpt.pdf
index c585068d8..caa54eadf 100644
--- a/doc/xfpt.pdf
+++ b/doc/xfpt.pdf
Binary files differ
diff --git a/doc/xfpt.xfpt b/doc/xfpt.xfpt
index 71d54bceb..e23ac9d67 100644
--- a/doc/xfpt.xfpt
+++ b/doc/xfpt.xfpt
@@ -13,14 +13,14 @@
<bookinfo>
<title>The xfpt plain text to XML processor</title>
<titleabbrev>xfpt</titleabbrev>
-<date>03 July 2007</date>
+<date>06 February 2008</date>
<author>
<firstname>Philip</firstname>
<surname>Hazel</surname>
</author>
<authorinitials>PH</authorinitials>
-<revhistory><revision><revnumber>0.03</revnumber><date>03 July 2007</date><authorinitials>PH</authorinitials></revision></revhistory>
-<copyright><year>2007</year><holder>University of Cambridge</holder></copyright>
+<revhistory><revision><revnumber>0.06</revnumber><date>06 February 2008</date><authorinitials>PH</authorinitials></revision></revhistory>
+<copyright><year>2008</year><holder>University of Cambridge</holder></copyright>
</bookinfo>
.literal off
@@ -41,7 +41,7 @@
. ----------------------------------------------------------------------------
-.chapter "Introduction"
+.chapter "Introduction" ID00
&X; is a program that reads a marked-up ASCII source file, and converts it into
XML. It was written with DocBook XML in mind, but can also be used for other
forms of XML. Unlike &'AsciiDoc'& (&url(http://www.methods.co.nz/asciidoc/)),
@@ -90,7 +90,7 @@ output, the appropriate XML entity reference (&`&&amp;`&, &`&&lt;`&, or
&`&&gt;`&, respectively) is generated.
-.section "The &X; command line"
+.section "The &X; command line" ID01
The format of the &X; command line is:
.display
&`xfpt [`&&'options'&&`] [`&&'input source'&&`]`&
@@ -112,14 +112,12 @@ be given as an output destination to refer to the standard output.
This option overrides the path to &X;'s library directory that is built into
the program. This makes it possible to use or test alternate libraries.
-.new
.vitem &%-v%&
This option causes &X; to output its version number and exit.
-.wen
.endlist
-.section "A short &X; example"
+.section "A short &X; example" ID02
Here is a very short example of a complete &X; input file that uses some of the
standard macros and flags:
.code
@@ -147,7 +145,7 @@ standard macros and flags:
-.section "Literal and non-literal processing" "SECTliteralprocessing"
+.section "Literal and non-literal processing" "SECTliteralprocessing" ID03
&X; processes non-directive input lines in one of four ways (known as
&"modes"&):
@@ -219,7 +217,7 @@ lines), is to indent every displayed line by one space, and thereby avoid the
problem altogether.
-.section "Format of directive lines"
+.section "Format of directive lines" ID04
If an input line starts with a dot followed by a space, it is ignored by &X;.
This provides a facility for including comments in the input. Otherwise, the
dot must be followed by a directive or macro name, and possibly one or more
@@ -237,7 +235,7 @@ dot is treated as a data line.
-.section "Calling macros" "SECTcallingmacro"
+.section "Calling macros" "SECTcallingmacro" ID05
Macros are defined by the &*.macro*& directive, which is described in section
&<<SECTmacro>>&. There are two ways of calling a macro. It can be called in the
same way as a directive, or it can be called from within text that is being
@@ -280,7 +278,7 @@ standard library are examples of macros that are designed be called either way.
. ----------------------------------------------------------------------------
-.chapter "Flag sequences"
+.chapter "Flag sequences" ID06
Only one flag sequence is built-into the code itself. If an input line ends
with three ampersands (ignoring trailing white space), the ampersands are
removed, and the next input line, with any leading white space removed, is
@@ -300,7 +298,7 @@ produces exactly the same output as:
.endd
-.section "Flag sequences for XML entities and &X; variables"
+.section "Flag sequences for XML entities and &X; variables" ID07
If an ampersand is followed by a # character, a number, and a semicolon, it is
understood as a numerical reference to an XML entity, and is passed through
unmodified. The number can be decimal, or hexadecimal preceded by &`x`&. For
@@ -329,7 +327,7 @@ without modification. For example:
.endlist
-.section "Flag sequences for calling macros"
+.section "Flag sequences for calling macros" ID08
If an ampersand is followed by a sequence of alphanumeric characters starting
with a letter, terminated by an opening parenthesis, the characters between the
ampersand and the parenthesis are interpreted as the name of a macro. See
@@ -337,7 +335,7 @@ section &<<SECTcallingmacro>>& for more details.
-.section "Other flag sequences"
+.section "Other flag sequences" ID09
Any other flag sequences that are needed must be defined by means of the
&*.flag*& directive. These are of two types, standalone and paired. Both cases
define replacement text. This is always literal; it is not itself scanned for
@@ -357,7 +355,6 @@ non-alphanumeric characters. When it is encountered, it is replaced by its
replacement text. For example, in the standard flag definitions, &`&&&&`&
is defined as a standalone flag with with the replacement text &`&&amp;`&.
-.new
A paired flag is defined as two sequences. The first takes the same form as a
standalone flag. The second also consists of non-alphanumeric characters, but
need not start with an ampersand. It is often defined as the reverse of the
@@ -370,7 +367,6 @@ expected to be found within the same text unit. In the default mode, the units
are a paragraphs, or part-paragraphs if footnotes intervene. In literal layout
mode, the text is processed line by line. Each member of the pair is replaced
by its replacement text.
-.wen
Multiple occurrences of paired flags must be correctly nested. Note that,
though &X; diagnoses an error for badly nested flag pairs, it does not prevent
@@ -378,12 +374,12 @@ you from generating invalid XML. For example, DocBook does not allow
&`<emphasis>`& within &`<literal>`&, though it does allow &`<literal>`& within
&`<emphasis>`&.
-.section "Unrecognized flag sequences"
+.section "Unrecognized flag sequences" ID10
If an ampersand is not followed by a character sequence in one of the forms
described in the preceding sections, an error occurs.
-.section "Standard flag sequences"
+.section "Standard flag sequences" ID11
These are the standalone flag sequences that are defined in the &_stdflags_&
file in the &X; library:
.display
@@ -415,13 +411,13 @@ convenient.
. ----------------------------------------------------------------------------
-.chapter "Built-in directive processing"
+.chapter "Built-in directive processing" ID12
The directives that are built into the code of &X; are now described in
alphabetical order. You can see more examples of their use in the descriptions
of the standard macros in chapter &<<CHAPstdmac>>&.
-.section "The &*.arg*& directive"
+.section "The &*.arg*& directive" ID13
This directive may appear only within the body of a macro. It must be followed
by a single number, optionally preceded by a minus sign. If the number is
positive (no minus sign), subsequent lines, up to a &*.endarg*& directive, are
@@ -443,23 +439,20 @@ for the given argument. For example:
.endarg
.endmacro
.endd
-.new
Note that if a macro is defined with default values for its arguments, these
are not counted by the &*.arg*& directive, which looks only at the actual
arguments in a particular macro call.
-.wen
The &*.arg*& directive may be nested.
-.section "The &*.eacharg*& directive"
+.section "The &*.eacharg*& directive" ID14
This directive may appear only within the body of a macro. It may optionally be
followed by a single number; if omitted the value is taken to be 1. Subsequent
lines, up to a &*.endeach*& directive, are processed multiple times, once for
-each remaining argument. Unlike &*.arg*&, an argument that is an empty string
-is not treated specially. &new("However, like &*.arg*&, only the actual
-arguments of a macro call are considered. Default argument values do not
-count.")
+each remaining argument. Unlike &*.arg*&, an argument that is an empty string
+is not treated specially. However, like &*.arg*&, only the actual arguments of
+a macro call are considered. Default argument values do not count.
The number given with &*.eacharg*& defines which argument to start with. If the
macro is called with fewer arguments, the lines up to &*.endeach*& are skipped,
@@ -492,26 +485,26 @@ The &*.eacharg*& directive may in principle be nested, though this does not
seem useful in practice.
-.section "The &*.echo*& directive"
+.section "The &*.echo*& directive" ID15
This directive takes a single string argument. It writes it to the standard
error stream. Within a macro, argument substitution takes place, but no other
processing is done on the string. This directive can be useful for debugging
macros or writing comments to the user.
-.section "The &*.endarg*& directive"
+.section "The &*.endarg*& directive" ID16
See the description of &*.arg*& above.
-.section "The &*.endeach*& directive"
+.section "The &*.endeach*& directive" ID17
See the description of &*.eacharg*& above.
-.section "The &*.endinliteral*& directive"
+.section "The &*.endinliteral*& directive" ID18
See the description of &*.inliteral*& below.
-.section "The &*.flag*& directive"
+.section "The &*.flag*& directive" ID19
This directive is used to define flag sequences. The directive must be followed
either by a standalone flag sequence and one string in quotes, or by a flag
pair and two strings in quotes. White space separates these items. For example:
@@ -524,14 +517,16 @@ redefine an existing flag, the new definition overrides the old. There is no
way to revert to the previous definition.
-.section "The &*.include*& directive"
+.section "The &*.include*& directive" ID20
This directive must be followed by a single string argument that is the path to
a file. The contents of the file are read and incorporated into the input at
this point. If the string does not contain any slashes, the path to the &X;
-library is prepended. Otherwise, the path is used unaltered.
+library is prepended. Otherwise, the path is used unaltered. &new("If
+&*.include*& is used inside a macro, it is evaluated each time the macro is
+called, and thus can be used to include a different file on each occasion.")
-.section "The &*.inliteral*& directive"
+.section "The &*.inliteral*& directive" ID21
This directive may appear only within the body of a macro. It must be followed
by one of the words &"layout"&, &"text"&, &"off"&, or &"xml"&. If the current
literal mode does not correspond to the word, subsequent lines, up to a
@@ -539,7 +534,7 @@ literal mode does not correspond to the word, subsequent lines, up to a
nested.
-.section "The &*.literal*& directive"
+.section "The &*.literal*& directive" ID22
This must be followed by one of the words &"layout"&, &"text"&, &"off"&, or
&"xml"&. It forces an end to a previous paragraph, if there is one, and then
switches between processing modes. The default mode is the &"off"& mode, in
@@ -548,7 +543,7 @@ Section &<<SECTliteralprocessing>>& describes how input lines are processed in
the four modes.
-.section "The &*.macro*& directive" "SECTmacro"
+.section "The &*.macro*& directive" "SECTmacro" ID23
This directive is used to define macros. It must be followed by a macro name,
and then, optionally, by any number of arguments. The macro name can be any
sequence of non-whitespace characters. The arguments in the definition provide
@@ -604,8 +599,7 @@ taken with argument references to ensure that substitutions happen at the right
level.
-.new
-.section "The &*.nest*& directive"
+.section "The &*.nest*& directive" ID24
This directive must be followed by one of the words &"begin"& or &"end"&. It is
used to delimit a nested sequence of independent text items that occurs inside
another, such as the contents of a footnote inside a paragraph. This directive
@@ -621,17 +615,16 @@ At the start of a nested sequence, the current mode and paragraph state are
remembered and &X; then reverts to the default mode and &"not in a paragraph"&.
At the end of a nested sequence, if a paragraph has been started, it is
terminated, and then &X; reverts to the previous state.
-.wen
-.section "The &*.nonl*& directive"
+.section "The &*.nonl*& directive" ID25
This directive must be followed by a single string argument. It is processed
-as normal text, but without a newline at the end. This facility is useful in
-macros when constructing a single data line from several text fragments. See
+as &new("an input line") without a newline at the end. This facility is useful
+in macros when constructing a single data line from several text fragments. See
for example the &*.new*& macro in the standard macros.
-.section "The &*.pop*& directive"
+.section "The &*.pop*& directive" ID26
&X; keeps a stack of text strings that are manipulated by the &*.push*& and
&*.pop*& directives. When the end of the input is reached, any strings that
remain on the stack are popped off, processed for flags, and written to the
@@ -647,7 +640,7 @@ If &*.pop*& is given without a following letter, it pops one string off the
stack and writes it out. If there is nothing on the stack, an error occurs.
-.section "The &*.push*& directive"
+.section "The &*.push*& directive" ID27
This directive pushes a string onto the stack. If the rest of the command line
starts with an upper case letter followed by white space, that letter is
associated with the string that is pushed, which consists of the rest of the
@@ -663,7 +656,7 @@ This arrangement ensures that any previous chapter is terminated before
starting a new one, and also when the end of the input is reached.
-.section "The &*.revision*& directive" "SECTrevision"
+.section "The &*.revision*& directive" "SECTrevision" ID28
This directive is provided to make it easy to set the &`revisionflag`&
attribute on XML elements in a given portion of the document. The DocBook
specification states that the &`revisionflag`& attribute is common to all
@@ -696,7 +689,7 @@ standard macros &*.new*& and &*.wen*& are provided (see section
&<<SECTrevmacs>>&).
-.section "The &*.set*& directive"
+.section "The &*.set*& directive" ID29
This directive must be followed by a name and a text string. It defines a user
variable and gives it a name. A reference to the name in the style of an XML
entity causes the string to be substituted, without further processing. For
@@ -712,7 +705,7 @@ has been defined.
. ----------------------------------------------------------------------------
-.chapter "The standard macros for DocBook" "CHAPstdmac" "Standard macros"
+.chapter "The standard macros for DocBook" "CHAPstdmac" "Standard macros" ID30
A set of simple macros for commonly needed DocBook features is provided in
&X;'s library. This may be extended as experience with &X; accumulates. The
standard macros assume that the standard flags are defined, so a document that
@@ -725,7 +718,7 @@ All the standard macros except &*new*&, &*index*&, and &*url*& are intended to
be called as directive lines. Their names are therefore shown with a leading
dot in the discussion below.
-.section "Overall setup"
+.section "Overall setup" ID31
There are two macros that should be used only once, at the start of the
document. The &*.docbook*& macro has no arguments. It inserts into the output
file the standard header material for a DocBook XML file, which is:
@@ -738,7 +731,7 @@ The &*.book*& macro has no arguments. It generates &`<book>`& and pushes
&`</book>`& onto the stack so that it will be output at the end.
-.section "Chapters, sections, and subsections"
+.section "Chapters, sections, and subsections" ID32
Chapters, sections, and subsections are supported by three macros that all
operate in the same way. They are &*.chapter*&, &*.section*&, and
&*.subsection*&. They take either one, two, or three arguments. The first
@@ -773,15 +766,13 @@ subsection is terminated at the correct point. For example, starting a new
section automatically terminates an open subsection and a previous section.
-.new
-.section "Prefaces, appendixes, and colophons"
+.section "Prefaces, appendixes, and colophons" ID33
The macros &*.preface*&, &*.appendix*&, and &*.colophon*& operate in the same
way as &*.chapter*&, except that the first and the last have the default title
strings &"Preface"& and &"Colophon"&.
-.wen
-.section "URL references"
+.section "URL references" ID34
The &*url*& macro generates URL references, and is intended to be called inline
within the text that is being processed. It generates a &`<ulink>`& element,
and has either one or two arguments. The first argument is the URL, and the
@@ -800,7 +791,7 @@ do not want.
-.section "Itemized lists"
+.section "Itemized lists" ID35
The &*.ilist*& macro marks the start of an itemized list, the items of which
are normally rendered with bullets or similar markings. The macro can
optionally be called with one argument, for which there is no default. If the
@@ -822,7 +813,7 @@ For example:
There may be more than one paragraph in an item.
-.section "Ordered lists"
+.section "Ordered lists" ID36
The &*.olist*& macro marks the start of an ordered list, the items of which are
numbered. If no argument is given, arabic numerals are used. One of the
following words can be given as the macro's argument to specify the numeration:
@@ -846,7 +837,7 @@ For example:
There may be more than one paragraph in an item.
-.section "Variable lists"
+.section "Variable lists" ID37
A variable list is one in which each entry is composed of a set of one or more
terms and an associated description. Typically, the terms are printed in a
style that makes them stand out, and the description is indented underneath.
@@ -867,7 +858,7 @@ This is followed by the body of the entry. The list is terminated by the
As for the other lists, there may be more than one paragraph in an item.
-.section "Nested lists"
+.section "Nested lists" ID38
Lists may be nested as required. Some DocBook processors automatically choose
different bullets for nested itemized lists, but others do not. The
&*.endlist*& macro has no useful arguments. Any text that follows it is
@@ -875,7 +866,7 @@ treated as a comment. This can provide an annotation facility that may make the
input easier to understand when lists are nested.
-.section "Displayed text"
+.section "Displayed text" ID39
In displayed text each non-directive input line generates one output line. The
&`<literallayout>`& DocBook element is used to achieve this. Two kinds of
displayed text are supported by the standard macros. They differ in their
@@ -912,12 +903,12 @@ As the examples illustrate, both kinds of display are terminated by the
-.section "Block quotes"
+.section "Block quotes" ID40
The macro pair &*.blockquote*& and &*.endblockquote*& are used to wrap the
lines between them in a &`<blockquote>`& element.
-.section "Revision markings" "SECTrevmacs"
+.section "Revision markings" "SECTrevmacs" ID41
Two macros are provided to simplify setting and unsetting the &"changed"&
revision marking (see section &<<SECTrevision>>&). When the revised text is
substantial (for example, a complete paragraph, table, display, or section), it
@@ -966,14 +957,12 @@ section you can also call &*.new*& with an argument, either as a directive or
inline. This does not work for &*.code*& because its lines are processed in
literal text mode.
-.new
If you want to add revision indications to part of a table, you must use an
inline call of &*new*& within an argument of the &*.row*& macro (see below).
This is the only usage that works in this case.
-.wen
-.section "Informal tables"
+.section "Informal tables" ID42
The &*.itable*& macro starts an informal (untitled) table with some basic
parameterization. If you are working on a large document that has many tables
with the same parameters, the best approach is to define your own table macros,
@@ -1031,8 +1020,7 @@ macro within an entry to generate a &`<phrase>`& element with &`revisionflag`&
set.
-.new
-.section "Formal tables"
+.section "Formal tables" ID43
The &*.table*& macro starts a formal table, that is, a table that has a title,
and which can be cross referenced. The first argument of this macro is the
table's title; the second is an identifier for cross-referencing. If you are
@@ -1048,24 +1036,25 @@ For example:
.endd
-.section "Figures and images"
+.section "Figures and images" ID44
A figure is enclosed between &*.figure*& and &*.endfigure*& macros. The first
argument of &*.figure*& provides a title for the figure. The second is
optional; if present, it is a tag for references to the figure.
A figure normally contains an image. The &*.image*& macro can be used in simple
cases. It generates a &`<mediaobject>`& element containing an
-&`<imageobject>`&. The first argument is the name of the file containing the
-image. The remaining arguments are optional; if any one is not needed, an empty
-string must be supplied as a placeholder.
+&`<imageobject>`&. The first argument is the name of the file containing the
+image. The remaining arguments are optional; &new("an empty string must be
+supplied as a placeholder when one that is not required is followed by one that
+is set.")
.ilist
The second argument specifies a scaling factor for the image, as a percentage.
Thus, a value of 50 reduces the image to half size.
.next
The third argument specifies an alignment for the image. It must be one of
-&`left`&, &`right`& or &`center`& (or even &`centre`& if the DocBook processor
-you are using can handle it).
+&`left`& &new("(default)"), &`right`& or &`center`& (or even &`centre`& if the
+DocBook processor you are using can handle it).
.next
The fourth and fifth arguments specify the depth and width, respectively. How
these values are handled depends on the processing software.
@@ -1087,7 +1076,7 @@ Here is another example, where the figure is reduced to 80% and centred:
.endd
-.section "Footnotes"
+.section "Footnotes" ID45
Footnotes can be specified between &*.footnote*& and &*.endnote*& macros.
Within a footnote there can be any kind of text item, including displays and
tables. When a footnote occurs in the middle of a paragraph, paired flags
@@ -1107,10 +1096,9 @@ The correct markup for this example is:
.endf
&'brown'& fox.
.endd
-.wen
-.section "Indexes"
+.section "Indexes" ID46
The &*.index*& macro generates &`<indexterm>`& elements (index entries) in the
output. It takes one or two arguments. The first is the text for the primary
index term, and the second, if present, specifies a secondary index term. This
@@ -1121,7 +1109,6 @@ example:
.index goose "wild chase"
The chasing of wild geese...
.endd
-.new
You can generate &"see"& and &"see also"& index entries by using &*.index-see*&
and &*.index-seealso*& instead of &*.index*&. The first argument of these
macros is the text for the &"see"&. For example:
@@ -1135,7 +1122,6 @@ This generates:
<see>chase</see>
</indexterm>
.endd
-.wen
If you want to generate an index entry for a range of pages, you can use the
&*.index-from*& and &*.index-to*& macros. The first argument of each of them is
diff --git a/src/dot.c b/src/dot.c
index 2721b15bc..7b6aabdfd 100644
--- a/src/dot.c
+++ b/src/dot.c
@@ -2,7 +2,7 @@
* xfpt - Simple ASCII->Docbook processor *
*************************************************/
-/* Copyright (c) University of Cambridge, 2007 */
+/* Copyright (c) University of Cambridge, 2008 */
/* Written by Philip Hazel. */
/* This module contains code for processing a line that starts with a dot. */
@@ -81,6 +81,7 @@ while (!done)
macroexe *temp = macrocurrent;
macrocurrent = macrocurrent->prev;
free(temp);
+ from_type_ptr--;
break;
}
}
@@ -110,7 +111,7 @@ BOOL mustexist = TRUE;
argstr *arg;
int i, argn;
-if (macrocurrent == NULL) { error(15, US".arg"); return; }
+if (from_type[from_type_ptr] != FROM_MACRO) { error(15, US".arg"); return; }
if (*p == '-')
{
@@ -147,7 +148,7 @@ do_eacharg(uschar *p)
argstr *arg;
int argn, i;
-if (macrocurrent == NULL) { error(15, US".eacharg"); return; }
+if (from_type[from_type_ptr] != FROM_MACRO) { error(15, US".eacharg"); return; }
argn = (*p == 0)? 1 : readnumber(p);
if (argn < 0) return;
@@ -199,7 +200,7 @@ Returns: nothing
static void
do_endarg(uschar *p)
{
-if (macrocurrent == NULL) { error(15, US".endarg"); return; }
+if (from_type[from_type_ptr] != FROM_MACRO) { error(15, US".endarg"); return; }
if (*p != 0) error(19, ".endarg", p, 8, spaces, Ustrlen(p), circumflexes);
}
@@ -222,7 +223,7 @@ do_endeach(uschar *p)
{
int count;
-if (macrocurrent == NULL) { error(15, US".endeach"); return; }
+if (from_type[from_type_ptr] != FROM_MACRO) { error(15, US".endeach"); return; }
count = (*p == 0)? 1 : readnumber(p);
if (count < 0) return;
@@ -251,7 +252,7 @@ Returns: nothing
static void
do_endinliteral(uschar *p)
{
-if (macrocurrent == NULL) { error(15, US".endinliteral"); return; }
+if (from_type[from_type_ptr] != FROM_MACRO) { error(15, US".endinliteral"); return; }
if (*p != 0) error(19, ".endinliteral", p, 8, spaces, Ustrlen(p), circumflexes);
}
@@ -350,8 +351,8 @@ f->next = *ff;
* Handle .include *
*************************************************/
-/* We set up a stack of included files so that the input is treated as one big
-file.
+/* Add to the stack of included files and push a new input type onto the
+from_type stack.
Argument: a single argument string
Returns: nothing
@@ -372,6 +373,8 @@ if (Ustrchr(p, '/') != NULL) Ustrcpy(ist->filename, p);
ist->file = Ufopen(ist->filename, "rb");
if (ist->file == NULL) error(0, ist->filename, strerror(errno)); /* Hard */
+
+from_type[++from_type_ptr] = FROM_FILE;
}
@@ -392,7 +395,7 @@ static void
do_inliteral(uschar *p)
{
int state = -1;
-if (macrocurrent == NULL) { error(15, US".inliteral"); return; }
+if (from_type[from_type_ptr] != FROM_MACRO) { error(15, US".inliteral"); return; }
if (Ustrcmp(p, "layout") == 0) state = LITERAL_LAYOUT;
else if (Ustrcmp(p, "text") == 0) state = LITERAL_TEXT;
else if (Ustrcmp(p, "off") == 0) state = LITERAL_OFF;
@@ -862,13 +865,14 @@ if (md == NULL)
return;
}
-/* Found a macro */
+/* Found a macro. Add it to the chain, and set the input type. */
me = misc_malloc(sizeof(macroexe));
me->prev = macrocurrent;
macrocurrent = me;
me->macro = md;
me->nextline = md->lines;
+from_type[++from_type_ptr] = FROM_MACRO;
me->args = NULL;
pp = &(me->args);
diff --git a/src/error.c b/src/error.c
index b98715be0..431d797fd 100644
--- a/src/error.c
+++ b/src/error.c
@@ -2,7 +2,7 @@
* xfpt - Simple ASCII->Docbook processor *
*************************************************/
-/* Copyright (c) University of Cambridge, 2006 */
+/* Copyright (c) University of Cambridge, 2008 */
/* Written by Philip Hazel. */
/* Error handling routines */
@@ -102,8 +102,9 @@ Returns: nothing, but some errors do not return
void
error(int n, ...)
{
-int ec;
+int ec, i;
macroexe *me;
+istackstr *fe;
va_list ap;
va_start(ap, n);
@@ -128,19 +129,29 @@ else
va_end(ap);
-for (me = macrocurrent; me != NULL; me = me->prev)
- {
- (void)fprintf(stderr, " Processing macro %s\n", me->macro->name);
- }
+me = macrocurrent;
+fe = istack;
-if (istack != NULL)
- {
- (void)fprintf(stderr, " Detected near line %d of %s\n",
- istack->linenumber, istack->filename);
- }
-else
+for (i = from_type_ptr; i >= 0; i--)
{
- (void)fprintf(stderr, " Detected near end of file\n");
+ if (from_type[i] == FROM_MACRO)
+ {
+ (void)fprintf(stderr, " Processing macro %s\n", me->macro->name);
+ me = me->prev;
+ }
+ else
+ {
+ if (fe != NULL)
+ {
+ (void)fprintf(stderr, " Detected near line %d of %s\n",
+ fe->linenumber, fe->filename);
+ fe = fe->prev;
+ }
+ else
+ {
+ (void)fprintf(stderr, " Detected near end of file\n");
+ }
+ }
}
if (ec == ec_warning)
diff --git a/src/globals.c b/src/globals.c
index 2c664db62..44297f127 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -2,7 +2,7 @@
* xfpt - Simple ASCII->Docbook processor *
*************************************************/
-/* Copyright (c) University of Cambridge, 2007 */
+/* Copyright (c) University of Cambridge, 2008 */
/* Written by Philip Hazel. */
/* Allocate storage and initialize global variables */
@@ -11,11 +11,13 @@
uschar *xfpt_share = US DATADIR;
-uschar *xfpt_version = US "0.05 21-September-2007";
+uschar *xfpt_version = US "0.06 06-February-2008";
tree_node *entities = NULL;
flagstr *flaglist = NULL;
+int from_type[FROM_TYPE_STACKSIZE];
+int from_type_ptr = 0;
uschar *inbuffer = NULL;
istackstr *istack = NULL;
diff --git a/src/globals.h b/src/globals.h
index 45bd5ee98..84868fc67 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -18,6 +18,8 @@ extern uschar *xfpt_version;
extern tree_node *entities;
extern flagstr *flaglist;
+extern int from_type[];
+extern int from_type_ptr;
extern uschar *inbuffer;
extern istackstr *istack;
diff --git a/src/para.c b/src/para.c
index 93eef3ef8..4f00a981d 100644
--- a/src/para.c
+++ b/src/para.c
@@ -2,7 +2,7 @@
* xfpt - Simple ASCII->Docbook processor *
*************************************************/
-/* Copyright (c) University of Cambridge, 2007 */
+/* Copyright (c) University of Cambridge, 2008 */
/* Written by Philip Hazel. */
/* This module contains code for processing a paragraph by looking for flag
@@ -53,6 +53,7 @@ me->prev = macrocurrent;
macrocurrent = me;
me->macro = md;
me->nextline = md->lines;
+from_type[++from_type_ptr] = FROM_MACRO;
me->args = NULL;
pp = &(me->args);
@@ -118,6 +119,7 @@ for (;;)
macroexe *temp = macrocurrent;
macrocurrent = macrocurrent->prev;
free(temp);
+ from_type_ptr--;
break;
}
}
diff --git a/src/read.c b/src/read.c
index 8d7c56e41..cd384eeb7 100644
--- a/src/read.c
+++ b/src/read.c
@@ -2,7 +2,7 @@
* xfpt - Simple ASCII->Docbook processor *
*************************************************/
-/* Copyright (c) University of Cambridge, 2006 */
+/* Copyright (c) University of Cambridge, 2008 */
/* Written by Philip Hazel. */
/* This module contains code for reading the input. */
@@ -156,38 +156,6 @@ while (*p != 0)
}
-/*************************************************
-* Get the next line from the current file *
-*************************************************/
-
-/* There may be a stack of included files. This function makes them look like a
-single source of input.
-
-Arguments:
- buffer where to read
- size size of buffer
-
-Returns: buffer pointer or NULL
-*/
-
-static uschar *
-read_nextfileline(uschar *buffer, int size)
-{
-if (istack == NULL) return NULL;
-if (Ufgets(buffer, size, istack->file) == NULL)
- {
- istackstr *prev = istack->prev;
- fclose(istack->file);
- free(istack);
- istack = prev;
- return (istack == NULL)? NULL : read_nextfileline(buffer, size);
- }
-
-istack->linenumber++;
-return buffer;
-}
-
-
/*************************************************
* Get the next line of input *
@@ -195,11 +163,16 @@ return buffer;
/* There may be a saved line already in the buffer, following the reading of a
paragraph or a .nonl directive. Otherwise, take the next line from one of three
-sources, in order:
+sources:
(1) If popto is not negative, get an appropropriate line off the stack.
(2) If we are in a macro, get the next macro line.
- (3) Read a new line from a file and handle any continuations.
+ (3) If we are in a file, read a new line from a file and handle any
+ continuations.
+
+There can be arbitrary nesting of macros and files, because a .include
+directive may appear inside a macro. The current from_type vector is used to
+keep track of what is current.
Arguments: none
Returns: pointer to the next line or NULL
@@ -250,47 +223,77 @@ if (popto > 0)
return inbuffer;
}
-/* Handle the next macro line. */
+/* Get the next line from the current macro or the current file. We need a loop
+for handling the ends of macros and files. */
-while (macrocurrent != NULL)
+for (;;)
{
- if (macrocurrent->nextline == NULL)
+ if (from_type[from_type_ptr] == FROM_MACRO)
{
- macroexe *temp = macrocurrent;
- macrocurrent = macrocurrent->prev;
- free(temp);
+ if (macrocurrent->nextline == NULL)
+ {
+ macroexe *temp = macrocurrent;
+ macrocurrent = macrocurrent->prev;
+ free(temp);
+ }
+ else
+ {
+ read_process_macroline(macrocurrent->nextline->string, inbuffer);
+ macrocurrent->nextline = macrocurrent->nextline->next;
+ break;
+ }
}
+
+ /* When reading from a file, handle continuation lines, but only within the
+ single file. */
+
else
{
- read_process_macroline(macrocurrent->nextline->string, inbuffer);
- macrocurrent->nextline = macrocurrent->nextline->next;
- return inbuffer;
- }
- }
+ if (istack == NULL) return NULL;
+ if (Ufgets(inbuffer, INBUFFSIZE, istack->file) == NULL)
+ {
+ istackstr *prev = istack->prev;
+ fclose(istack->file);
+ free(istack);
+ istack = prev;
+ }
+ else
+ {
+ istack->linenumber++;
-/* Get a line from an input file */
+ q = inbuffer;
+ len = Ustrlen(q);
-if (read_nextfileline(inbuffer, INBUFFSIZE) == NULL) return NULL;
+ for (;;)
+ {
+ p = q + len;
+ while (p > q && isspace(p[-1])) p--;
-q = inbuffer;
-len = Ustrlen(q);
+ if (p - q < 3 || Ustrncmp(p - 3, "&&&", 3) != 0) break;
-for (;;)
- {
- p = q + len;
- while (p > q && isspace(p[-1])) p--;
+ q = p - 3;
+ *q = 0;
+
+ if (istack == NULL ||
+ Ufgets(q, INBUFFSIZE - (q - inbuffer), istack->file) == NULL)
+ break;
- if (p - q < 3 || Ustrncmp(p - 3, "&&&", 3) != 0) break;
+ istack->linenumber++;
+ p = q;
+ while (*p == ' ' || *p == '\t') p++;
+ len = Ustrlen(p);
+ if (p > q) memmove(q, p, len + 1);
+ }
- q = p - 3;
- *q = 0;
+ break;
+ }
+ }
- if (read_nextfileline(q, INBUFFSIZE - (q - inbuffer)) == NULL) break;
+ /* We get here if the end of a macro or a file was reached. The appropriate
+ chain has been popped. Back up the stack of input types before the loop
+ repeats. */
- p = q;
- while (*p == ' ' || *p == '\t') p++;
- len = Ustrlen(p);
- if (p > q) memmove(q, p, len + 1);
+ from_type_ptr--;
}
return inbuffer;
diff --git a/src/xfpt.c b/src/xfpt.c
index 8bdd0e8fa..bb8a74c99 100644
--- a/src/xfpt.c
+++ b/src/xfpt.c
@@ -2,7 +2,7 @@
* xfpt - Simple ASCII->Docbook processor *
*************************************************/
-/* Copyright (c) University of Cambridge, 2007 */
+/* Copyright (c) University of Cambridge, 2008 */
/* Written by Philip Hazel. */
/* This module contains the main program and initialization functions. */
@@ -131,6 +131,9 @@ istack = misc_malloc(sizeof(istackstr));
istack->prev = NULL;
istack->linenumber = 0;
+from_type_ptr = 0;
+from_type[from_type_ptr] = FROM_FILE;
+
if (xfpt_filename == NULL)
{
istack->file = stdin;
diff --git a/src/xfpt.h b/src/xfpt.h
index bdd2c5a74..df19ed4fd 100644
--- a/src/xfpt.h
+++ b/src/xfpt.h
@@ -2,7 +2,7 @@
* xfpt - Simple ASCII->Docbook processor *
*************************************************/
-/* Copyright (c) University of Cambridge, 2006 */
+/* Copyright (c) University of Cambridge, 2008 */
/* Written by Philip Hazel. I wrote this because I found AsciiDoc to be to slow
for large documents, and also to have too many quirks and gotchas. */
@@ -31,10 +31,16 @@ must appear before including the local headers. */
/* These values do not necessarily have to appear before including the local
headers, but they might as well be together with those above. */
-#define INBUFFSIZE 1024
-#define PARABUFFSIZE 10000
-#define FLAGSTACKSIZE 40
-#define MAXNEST 3
+#define INBUFFSIZE 1024
+#define PARABUFFSIZE 10000
+#define FLAGSTACKSIZE 40
+#define MAXNEST 3
+#define FROM_TYPE_STACKSIZE 20
+
+
+/* Type of current input */
+
+enum { FROM_FILE, FROM_MACRO };
/* Nested block indicators for read_paragraph() */
diff --git a/testing/infiles/02 b/testing/infiles/02
index 421294cc3..c4c6e5142 100644
--- a/testing/infiles/02
+++ b/testing/infiles/02
@@ -41,3 +41,13 @@ Try &&abcd without semicolon: &abcd and at EOL &abcd
.x
.nonl more than one argument
+
+.macro a
+.include infiles/02.inc
+.endmacro
+
+.macro b
+.arg 4n
+.endmacro
+
+.a
diff --git a/testing/infiles/02.inc b/testing/infiles/02.inc
new file mode 100644
index 000000000..76202b0e1
--- /dev/null
+++ b/testing/infiles/02.inc
@@ -0,0 +1,3 @@
+.b
+
+.arg 3
diff --git a/testing/infiles/03 b/testing/infiles/03
new file mode 100644
index 000000000..d4d2c65e2
--- /dev/null
+++ b/testing/infiles/03
@@ -0,0 +1,14 @@
+.include stdflags
+.include stdmacs
+
+.macro pic
+.code
+.include infiles/pic$1.aspic.inc
+.endd
+.figure
+.image infiles/pic$1.eps.inc
+.endfigure
+.endmacro
+
+.chapter "Testing"
+.pic 01
diff --git a/testing/infiles/pic01.aspic.inc b/testing/infiles/pic01.aspic.inc
new file mode 100644
index 000000000..52834896c
--- /dev/null
+++ b/testing/infiles/pic01.aspic.inc
@@ -0,0 +1 @@
+box "A"; line; circle "B";
diff --git a/testing/infiles/pic01.eps.inc b/testing/infiles/pic01.eps.inc
new file mode 100644
index 000000000..3f0e7122d
--- /dev/null
+++ b/testing/infiles/pic01.eps.inc
@@ -0,0 +1,47 @@
+%!PS-Adobe-2.0 EPSF-2.0
+%%Title: Unknown
+%%Creator: Unknown, using Aspic 1.04 (30-January-2008)
+%%CreationDate: Wed, 06 Feb 2008 12:05:35 +0000
+%%BoundingBox: 0 0 216.500 72.400
+%%EndComments
+
+/centreshow{dup stringwidth pop 2 div neg 0 rmoveto show}def
+/rightshow{dup stringwidth pop neg 0 rmoveto show}def
+/leftshow{show}def
+/mymove{
+{currentpoint} stopped {moveto}{
+ exch 4 1 roll sub 3 1 roll exch sub
+ dup abs 0.01 lt 3 -1 roll dup abs 0.01 lt
+ 3 -1 roll and {pop pop}{rmoveto} ifelse
+ } ifelse
+}def
+/fonts 64 array def
+/mybindfont{exch findfont exch scalefont fonts 3 1 roll put} def
+/myfont{fonts exch get setfont} def
+
+0 /Times-Roman 12 mybindfont
+0.480 18.360 mymove
+72 0 rlineto
+0 36 rlineto
+-72 0 rlineto
+closepath
+0.500 setlinewidth
+stroke
+0 myfont
+36.480 33.360 mymove
+(A) centreshow
+72.480 36.360 mymove
+72 0 rlineto
+0.400 setlinewidth
+stroke
+216.480 36.360 mymove
+0.480 18.840 -16.080 35.880 -34.920 36 rcurveto
+-18.840 1.080 -36.360 -14.880 -37.080 -33.720 rcurveto
+-1.680 -18.720 13.800 -36.840 32.520 -38.040 rcurveto
+18.720 -2.280 37.200 12.600 39.120 31.320 rcurveto
+0.240 1.440 0.240 3 0.240 4.560 rcurveto
+closepath
+stroke
+180.480 33.360 mymove
+(B) centreshow
+showpage
diff --git a/testing/outfiles/02.err b/testing/outfiles/02.err
index bc5e33c3a..835b6c412 100644
--- a/testing/outfiles/02.err
+++ b/testing/outfiles/02.err
@@ -91,3 +91,15 @@
^^^^^^^^^^^^^^^^^
Detected near line 43 of infiles/02
+** Error: malformed directive
+ .arg 4n
+ Processing macro b
+ Detected near line 1 of infiles/02.inc
+ Processing macro a
+ Detected near line 53 of infiles/02
+
+** Error: .arg is permitted only inside a macro
+ Detected near line 3 of infiles/02.inc
+ Processing macro a
+ Detected near line 53 of infiles/02
+
diff --git a/testing/outfiles/03 b/testing/outfiles/03
new file mode 100644
index 000000000..0e3290abf
--- /dev/null
+++ b/testing/outfiles/03
@@ -0,0 +1,12 @@
+<chapter>
+<title>Testing</title>
+<literallayout class="monospaced">
+box "A"; line; circle "B";
+</literallayout>
+<figure>
+<mediaobject><imageobject>
+<imagedata fileref="infiles/pic01.eps.inc" >
+</imagedata></imageobject></mediaobject>
+</figure>
+</chapter>
+
diff --git a/testing/runtest b/testing/runtest
index efe165c5e..1cd36a638 100755
--- a/testing/runtest
+++ b/testing/runtest
@@ -3,7 +3,7 @@
# Controlling script for xfpt tests
$xfpt = "../src/xfpt -S ../share";
-$cf = "cf";
+$cf = (-f "/usr/local/bin/cf")? "cf" : "diff -u";
$force_update = 0;
$starttest = undef;
@@ -35,9 +35,10 @@ while (scalar @files > 0)
my($options) = $cmd_options;
# Skip . and .. and also skip any file ending in .opt because that
- # contains options for any given test.
+ # contains options for any given test, and any file ending in .inc
+ # because that is an included file.
- next if $file =~ /^\.\.?$|\.opt$/;
+ next if $file =~ /^\.\.?$|\.opt$|\.inc$/;
next if !$started && defined $starttest && $file !~ /^$starttest/;
$started = 1;