summaryrefslogtreecommitdiff
path: root/keywords.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2001-10-25 19:28:43 +0000
committerSimon Tatham <anakin@pobox.com>2001-10-25 19:28:43 +0000
commit3e043306f1594f7528788a1c593995b391fc7a5a (patch)
tree614dbae4b9d0b18ffaed645887e8243c21c809a7 /keywords.c
parentdd9eaf09d344a4b18b2750cef08795a097891c08 (diff)
downloadhalibut-3e043306f1594f7528788a1c593995b391fc7a5a.zip
halibut-3e043306f1594f7528788a1c593995b391fc7a5a.tar.gz
halibut-3e043306f1594f7528788a1c593995b391fc7a5a.tar.bz2
halibut-3e043306f1594f7528788a1c593995b391fc7a5a.tar.xz
Enforce proper ordering of heading levels: specifically, ensure the
user doesn't skip a heading level (\H before any \C or \A, or \S straight after \C with no intervening \H). The precise criterion is that when creating section a.b.c.d, sections a.b.c, a.b and a should already exist. This ensures the section tree really is a properly formed tree with no missing nodes. [originally from svn r1329]
Diffstat (limited to 'keywords.c')
-rw-r--r--keywords.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/keywords.c b/keywords.c
index d0d0b4d..7dd35b1 100644
--- a/keywords.c
+++ b/keywords.c
@@ -86,6 +86,7 @@ keyword *kw_lookup(keywordlist *kl, wchar_t *str) {
* finish).
*/
keywordlist *get_keywords(paragraph *source) {
+ int errors = FALSE;
keywordlist *kl = mknew(keywordlist);
numberstate *n = number_init();
int prevpara = para_NotParaType;
@@ -102,7 +103,15 @@ keywordlist *get_keywords(paragraph *source) {
* Number the chapter / section / list-item / whatever.
*/
source->kwtext = number_mktext(n, source->type, source->aux,
- prevpara, &source->kwtext2);
+ prevpara, &source->kwtext2,
+ source->fpos);
+ if (!source->kwtext) {
+ /* There was an error collecting the section numbers.
+ * number_mktext has reported it; we record it and bail
+ * out at the end. */
+ errors = TRUE;
+ continue;
+ }
prevpara = source->type;
if (source->keyword && *source->keyword) {
@@ -128,6 +137,11 @@ keywordlist *get_keywords(paragraph *source) {
number_free(n);
+ if (errors) {
+ free_keywords(kl);
+ return NULL;
+ }
+
heap_sort(kl);
return kl;