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).
git-svn-id: svn://svn.tartarus.org/sgt/halibut@5629
cda61777-01e9-0310-a592-
d414129be87e
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);
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 */
};
}
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;
}