diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-01-27 01:09:14 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-01-27 01:09:14 +0000 |
commit | 289b180171f7df834e7549ccea9a8ed716976850 (patch) | |
tree | 767c9134dca915db7431ad266cfed170cf9c0141 | |
parent | f4f3ff2a22776dac1056b1df38593aada770e186 (diff) | |
download | mandoc-289b180171f7df834e7549ccea9a8ed716976850.tar.gz |
If parsing a page reveals that it is neither mdoc(7) nor man(7),
fall back to treating it as preformatted rather than treating
it as man(7) anyway.
-rw-r--r-- | mandocdb.c | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -1153,6 +1153,7 @@ mpages_merge(struct dba *dba, struct mparse *mp) if (mlink->dform != FORM_CAT || mlink->fform != FORM_CAT) { mparse_readfd(mp, fd, mlink->file); close(fd); + fd = -1; mparse_result(mp, &man, &sodest); } @@ -1209,24 +1210,27 @@ mpages_merge(struct dba *dba, struct mparse *mp) mpage->title = mandoc_strdup(man->meta.title); } else if (man != NULL && man->macroset == MACROSET_MAN) { man_validate(man); - mpage->form = FORM_SRC; - mpage->sec = mandoc_strdup(man->meta.msec); - mpage->arch = mandoc_strdup(mlink->arch); - mpage->title = mandoc_strdup(man->meta.title); - } else { + if (*man->meta.msec != '\0' || + *man->meta.msec != '\0') { + mpage->form = FORM_SRC; + mpage->sec = mandoc_strdup(man->meta.msec); + mpage->arch = mandoc_strdup(mlink->arch); + mpage->title = mandoc_strdup(man->meta.title); + } else + man = NULL; + } + + assert(mpage->desc == NULL); + if (man == NULL) { mpage->form = FORM_CAT; mpage->sec = mandoc_strdup(mlink->dsec); mpage->arch = mandoc_strdup(mlink->arch); mpage->title = mandoc_strdup(mlink->name); - } - - assert(mpage->desc == NULL); - if (man != NULL && man->macroset == MACROSET_MDOC) + parse_cat(mpage, fd); + } else if (man->macroset == MACROSET_MDOC) parse_mdoc(mpage, &man->meta, man->first); - else if (man != NULL) - parse_man(mpage, &man->meta, man->first); else - parse_cat(mpage, fd); + parse_man(mpage, &man->meta, man->first); if (mpage->desc == NULL) mpage->desc = mandoc_strdup(mpage->mlinks->name); |