Revamp of the Halibut error handling mechanism.
[sgt/halibut] / keywords.c
index 6e8a230..14aa6bd 100644 (file)
@@ -33,7 +33,7 @@ keyword *kw_lookup(keywordlist *kl, wchar_t *str) {
  */
 keywordlist *get_keywords(paragraph *source) {
     int errors = FALSE;
-    keywordlist *kl = mknew(keywordlist);
+    keywordlist *kl = snew(keywordlist);
     numberstate *n = number_init();
     int prevpara = para_NotParaType;
 
@@ -62,20 +62,19 @@ keywordlist *get_keywords(paragraph *source) {
         * This also sets up the `parent', `child' and `sibling'
         * links.
         */
-       source->kwtext = number_mktext(n, source, q, prevpara, &errors);
-       prevpara = source->type;
+       source->kwtext = number_mktext(n, source, q, &prevpara, &errors);
 
        if (p && *p) {
            if (source->kwtext || source->type == para_Biblio) {
                keyword *kw, *ret;
 
-               kw = mknew(keyword);
+               kw = snew(keyword);
                kw->key = p;
                kw->text = source->kwtext;
                kw->para = source;
                ret = add234(kl->keys, kw);
                if (ret != kw) {
-                   error(err_multikw, &source->fpos, &ret->para->fpos, p);
+                   err_multikw(&source->fpos, &ret->para->fpos, p);
                    sfree(kw);
                    /* FIXME: what happens to kw->text? Does it leak? */
                }
@@ -83,7 +82,8 @@ keywordlist *get_keywords(paragraph *source) {
        } else {
            if (kl->nlooseends >= kl->looseendssize) {
                kl->looseendssize = kl->nlooseends + 32;
-               kl->looseends = resize(kl->looseends, kl->looseendssize);
+               kl->looseends = sresize(kl->looseends, kl->looseendssize,
+                                       word *);
            }
            kl->looseends[kl->nlooseends++] = source->kwtext;
        }
@@ -124,7 +124,7 @@ void subst_keywords(paragraph *source, keywordlist *kl) {
 
                kw = kw_lookup(kl, ptr->text);
                if (!kw) {
-                   error(err_nosuchkw, &ptr->fpos, ptr->text);
+                   err_nosuchkw(&ptr->fpos, ptr->text);
                    subst = NULL;
                } else
                    subst = dup_word_list(kw->text);
@@ -134,7 +134,7 @@ void subst_keywords(paragraph *source, keywordlist *kl) {
                    kw->para->type != para_BiblioCited)
                    ustrlow(subst->text);
 
-               close = mknew(word);
+               close = snew(word);
                close->text = NULL;
                close->alt = NULL;
                close->type = word_XrefEnd;