=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mandocdb.c,v retrieving revision 1.210 retrieving revision 1.211 diff -c -r1.210 -r1.211 *** src/usr.bin/mandoc/mandocdb.c 2018/12/14 01:17:46 1.210 --- src/usr.bin/mandoc/mandocdb.c 2018/12/30 00:48:47 1.211 *************** *** 1,4 **** ! /* $OpenBSD: mandocdb.c,v 1.210 2018/12/14 01:17:46 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011-2018 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: mandocdb.c,v 1.211 2018/12/30 00:48:47 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011-2018 Ingo Schwarze *************** *** 323,328 **** --- 323,329 ---- goto usage; \ } while (/*CONSTCOND*/0) + mparse_options = MPARSE_VALIDATE; path_arg = NULL; op = OP_DEFAULT; *************** *** 1077,1084 **** { struct mpage *mpage, *mpage_dest; struct mlink *mlink, *mlink_dest; ! struct roff_man *man; ! char *sodest; char *cp; int fd; --- 1078,1084 ---- { struct mpage *mpage, *mpage_dest; struct mlink *mlink, *mlink_dest; ! struct roff_meta *meta; char *cp; int fd; *************** *** 1091,1098 **** mandoc_ohash_init(&names, 4, offsetof(struct str, key)); mandoc_ohash_init(&strings, 6, offsetof(struct str, key)); mparse_reset(mp); ! man = NULL; ! sodest = NULL; if ((fd = mparse_open(mp, mlink->file)) == -1) { say(mlink->file, "&open"); --- 1091,1097 ---- mandoc_ohash_init(&names, 4, offsetof(struct str, key)); mandoc_ohash_init(&strings, 6, offsetof(struct str, key)); mparse_reset(mp); ! meta = NULL; if ((fd = mparse_open(mp, mlink->file)) == -1) { say(mlink->file, "&open"); *************** *** 1107,1120 **** mparse_readfd(mp, fd, mlink->file); close(fd); fd = -1; ! mparse_result(mp, &man, &sodest); } ! if (sodest != NULL) { mlink_dest = ohash_find(&mlinks, ! ohash_qlookup(&mlinks, sodest)); if (mlink_dest == NULL) { ! mandoc_asprintf(&cp, "%s.gz", sodest); mlink_dest = ohash_find(&mlinks, ohash_qlookup(&mlinks, cp)); free(cp); --- 1106,1119 ---- mparse_readfd(mp, fd, mlink->file); close(fd); fd = -1; ! meta = mparse_result(mp); } ! if (meta != NULL && meta->sodest != NULL) { mlink_dest = ohash_find(&mlinks, ! ohash_qlookup(&mlinks, meta->sodest)); if (mlink_dest == NULL) { ! mandoc_asprintf(&cp, "%s.gz", meta->sodest); mlink_dest = ohash_find(&mlinks, ohash_qlookup(&mlinks, cp)); free(cp); *************** *** 1151,1189 **** mpage->mlinks = NULL; } goto nextpage; ! } else if (man != NULL && man->macroset == MACROSET_MDOC) { ! mdoc_validate(man); mpage->form = FORM_SRC; ! mpage->sec = man->meta.msec; mpage->sec = mandoc_strdup( mpage->sec == NULL ? "" : mpage->sec); ! mpage->arch = man->meta.arch; mpage->arch = mandoc_strdup( mpage->arch == NULL ? "" : mpage->arch); ! mpage->title = mandoc_strdup(man->meta.title); ! } else if (man != NULL && man->macroset == MACROSET_MAN) { ! man_validate(man); ! if (*man->meta.msec != '\0' || ! *man->meta.title != '\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); parse_cat(mpage, fd); ! } else if (man->macroset == MACROSET_MDOC) ! parse_mdoc(mpage, &man->meta, man->first); else ! parse_man(mpage, &man->meta, man->first); if (mpage->desc == NULL) { mpage->desc = mandoc_strdup(mlink->name); if (warnings) --- 1150,1185 ---- mpage->mlinks = NULL; } goto nextpage; ! } else if (meta != NULL && meta->macroset == MACROSET_MDOC) { mpage->form = FORM_SRC; ! mpage->sec = meta->msec; mpage->sec = mandoc_strdup( mpage->sec == NULL ? "" : mpage->sec); ! mpage->arch = meta->arch; mpage->arch = mandoc_strdup( mpage->arch == NULL ? "" : mpage->arch); ! mpage->title = mandoc_strdup(meta->title); ! } else if (meta != NULL && meta->macroset == MACROSET_MAN) { ! if (*meta->msec != '\0' || *meta->title != '\0') { mpage->form = FORM_SRC; ! mpage->sec = mandoc_strdup(meta->msec); mpage->arch = mandoc_strdup(mlink->arch); ! mpage->title = mandoc_strdup(meta->title); } else ! meta = NULL; } assert(mpage->desc == NULL); ! if (meta == NULL) { mpage->form = FORM_CAT; mpage->sec = mandoc_strdup(mlink->dsec); mpage->arch = mandoc_strdup(mlink->arch); mpage->title = mandoc_strdup(mlink->name); parse_cat(mpage, fd); ! } else if (meta->macroset == MACROSET_MDOC) ! parse_mdoc(mpage, meta, meta->first); else ! parse_man(mpage, meta, meta->first); if (mpage->desc == NULL) { mpage->desc = mandoc_strdup(mlink->name); if (warnings)