summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--error.c5
-rw-r--r--halibut.h1
-rw-r--r--input.c14
3 files changed, 19 insertions, 1 deletions
diff --git a/error.c b/error.c
index 3635f0f..b1e74a1 100644
--- a/error.c
+++ b/error.c
@@ -278,6 +278,11 @@ static void do_error(int code, va_list ap) {
flags = FILEPOS;
sfree(sp);
break;
+ case err_emptypara:
+ fpos = *va_arg(ap, filepos *);
+ sprintf(error, "found no text in paragraph");
+ flags = FILEPOS;
+ break;
case err_whatever:
sp = va_arg(ap, char *);
vsprintf(error, sp, ap);
diff --git a/halibut.h b/halibut.h
index ed2a0da..99b9a0e 100644
--- a/halibut.h
+++ b/halibut.h
@@ -244,6 +244,7 @@ enum {
err_text_codeline, /* \c line too long in text backend */
err_htmlver, /* unrecognised HTML version keyword */
err_charset, /* unrecognised character set name */
+ err_emptypara, /* paragraph contains no actual text */
err_whatever /* random error of another type */
};
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;
}