=================================================================== RCS file: /cvs/mandoc/mandocdb.c,v retrieving revision 1.73 retrieving revision 1.77 diff -u -p -r1.73 -r1.77 --- mandoc/mandocdb.c 2013/10/18 23:07:23 1.73 +++ mandoc/mandocdb.c 2013/12/26 19:02:04 1.77 @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.73 2013/10/18 23:07:23 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.77 2013/12/26 19:02:04 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013 Ingo Schwarze @@ -836,13 +836,13 @@ ofadd(int dform, const char *file, const char *name, c if (NULL == arch) arch = ""; - sform = FORM_NONE; - if (NULL != sec && *sec <= '9' && *sec >= '1') - sform = FORM_SRC; - else if (NULL != sec && *sec == '0') { + if ('0' == *sec) { sec = dsec; sform = FORM_CAT; - } + } else if ('1' <= *sec && '9' >= *sec) + sform = FORM_SRC; + else + sform = FORM_NONE; of = mandoc_calloc(1, sizeof(struct of)); strlcpy(of->file, file, PATH_MAX); @@ -950,10 +950,6 @@ ofmerge(struct mchars *mc, struct mparse *mp, int chec mparse_reset(mp); mdoc = NULL; man = NULL; - form = 0; - msec = of->dsec; - march = of->arch; - mtitle = of->name; match = 1; /* @@ -961,11 +957,11 @@ ofmerge(struct mchars *mc, struct mparse *mp, int chec * source code, unless it is already known to be * formatted. Fall back to formatted mode. */ - if (FORM_SRC == of->dform || FORM_SRC == of->sform) { + if (FORM_CAT != of->dform || FORM_CAT != of->sform) { lvl = mparse_readfd(mp, -1, of->file); if (lvl < MANDOCLEVEL_FATAL) mparse_result(mp, &mdoc, &man); - } + } if (NULL != mdoc) { form = 1; @@ -975,15 +971,20 @@ ofmerge(struct mchars *mc, struct mparse *mp, int chec } else if (NULL != man) { form = 1; msec = man_meta(man)->msec; - march = ""; + march = of->arch; mtitle = man_meta(man)->title; - } + } else { + form = 0; + msec = of->dsec; + march = of->arch; + mtitle = of->name; + } - if (NULL == msec) + if (NULL == msec) msec = ""; - if (NULL == march) + if (NULL == march) march = ""; - if (NULL == mtitle) + if (NULL == mtitle) mtitle = ""; /* @@ -1365,8 +1366,11 @@ parse_man(struct of *of, const struct man_node *n) } } - for (n = n->child; n; n = n->next) + for (n = n->child; n; n = n->next) { + if (NULL != of->desc) + break; parse_man(of, n); + } } static void