summaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-04-12 08:38:28 +0000
committerSimon Tatham <anakin@pobox.com>2005-04-12 08:38:28 +0000
commite0cce79cf40ca89ded697a27af804355ef9512a3 (patch)
treed65ddca5ede51cc4336b7173e0bd2dcbabc94aed /input.c
parent2fd0d2ed0c7f939e3f3cd8175395373da4a7718e (diff)
downloadhalibut-e0cce79cf40ca89ded697a27af804355ef9512a3.zip
halibut-e0cce79cf40ca89ded697a27af804355ef9512a3.tar.gz
halibut-e0cce79cf40ca89ded697a27af804355ef9512a3.tar.bz2
halibut-e0cce79cf40ca89ded697a27af804355ef9512a3.tar.xz
input.c was capable of generating a paragraph structure with no text
in it, if the input paragraph contained (say) an unrecognised control command and nothing else. Such paragraphs can confuse back ends later on, so input.c should refrain from generating them. Added a check and a polite error message (just in case the user manages to generate an empty paragraph using otherwise legal syntax). [originally from svn r5629]
Diffstat (limited to 'input.c')
-rw-r--r--input.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/input.c b/input.c
index 493449c..d8d44f9 100644
--- a/input.c
+++ b/input.c
@@ -1529,7 +1529,19 @@ static void read_file(paragraph ***ret, input *in, indexdata *idx,
}
stk_free(parsestk);
prev_para_type = par.type;
- addpara(par, ret);
+ /*
+ * Before we add the paragraph to the output list, we
+ * should check that there was any text in it at all; there
+ * might not be if (for example) the paragraph contained
+ * nothing but an unrecognised command sequence, and if we
+ * put an empty paragraph on the list it may confuse the
+ * back ends later on.
+ */
+ if (par.words) {
+ addpara(par, ret);
+ } else {
+ error(err_emptypara, &par.fpos);
+ }
if (t.type == tok_eof)
already = TRUE;
}