=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/read.c,v retrieving revision 1.111 retrieving revision 1.112 diff -c -r1.111 -r1.112 *** src/usr.bin/mandoc/read.c 2015/04/18 17:01:28 1.111 --- src/usr.bin/mandoc/read.c 2015/04/18 17:28:08 1.112 *************** *** 1,4 **** ! /* $OpenBSD: read.c,v 1.111 2015/04/18 17:01:28 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2015 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: read.c,v 1.112 2015/04/18 17:28:08 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2015 Ingo Schwarze *************** *** 284,309 **** } } ! if (format == MPARSE_MDOC) { ! if (curp->man == NULL) ! curp->man = mdoc_alloc( ! curp->roff, curp, curp->defos, ! MPARSE_QUICK & curp->options ? 1 : 0); ! else ! curp->man->macroset = MACROSET_MDOC; ! mdoc_hash_init(); ! return; } ! /* Fall back to man(7) as a last resort. */ ! ! if (curp->man == NULL) ! curp->man = man_alloc( ! curp->roff, curp, curp->defos, ! MPARSE_QUICK & curp->options ? 1 : 0); ! else curp->man->macroset = MACROSET_MAN; ! man_hash_init(); } /* --- 284,305 ---- } } ! if (curp->man == NULL) { ! curp->man = roff_man_alloc(curp->roff, curp, curp->defos, ! curp->options & MPARSE_QUICK ? 1 : 0); ! curp->man->macroset = MACROSET_MAN; ! curp->man->first->tok = MDOC_MAX; } ! if (format == MPARSE_MDOC) { ! mdoc_hash_init(); ! curp->man->macroset = MACROSET_MDOC; ! curp->man->first->tok = MDOC_MAX; ! } else { ! man_hash_init(); curp->man->macroset = MACROSET_MAN; ! curp->man->first->tok = MAN_MAX; ! } } /* *************** *** 683,689 **** { if (curp->man == NULL && curp->sodest == NULL) ! curp->man = man_alloc(curp->roff, curp, curp->defos, curp->options & MPARSE_QUICK ? 1 : 0); if (curp->man->macroset == MACROSET_NONE) curp->man->macroset = MACROSET_MAN; --- 679,685 ---- { if (curp->man == NULL && curp->sodest == NULL) ! curp->man = roff_man_alloc(curp->roff, curp, curp->defos, curp->options & MPARSE_QUICK ? 1 : 0); if (curp->man->macroset == MACROSET_NONE) curp->man->macroset = MACROSET_MAN; *************** *** 870,888 **** curp->mchars = mchars; curp->roff = roff_alloc(curp, curp->mchars, options); if (curp->options & MPARSE_MDOC) { - curp->man = mdoc_alloc( - curp->roff, curp, curp->defos, - curp->options & MPARSE_QUICK ? 1 : 0); mdoc_hash_init(); ! } ! if (curp->options & MPARSE_MAN) { ! curp->man = man_alloc( ! curp->roff, curp, curp->defos, ! curp->options & MPARSE_QUICK ? 1 : 0); man_hash_init(); } - return(curp); } --- 866,882 ---- curp->mchars = mchars; curp->roff = roff_alloc(curp, curp->mchars, options); + curp->man = roff_man_alloc( curp->roff, curp, curp->defos, + curp->options & MPARSE_QUICK ? 1 : 0); if (curp->options & MPARSE_MDOC) { mdoc_hash_init(); ! curp->man->macroset = MACROSET_MDOC; ! curp->man->first->tok = MDOC_MAX; ! } else if (curp->options & MPARSE_MAN) { man_hash_init(); + curp->man->macroset = MACROSET_MAN; + curp->man->first->tok = MAN_MAX; } return(curp); } *************** *** 892,904 **** roff_reset(curp->roff); ! if (curp->man != NULL) { ! if (curp->man->macroset == MACROSET_MDOC) ! mdoc_reset(curp->man); ! else ! man_reset(curp->man); ! curp->man->macroset = MACROSET_NONE; ! } if (curp->secondary) curp->secondary->sz = 0; --- 886,893 ---- roff_reset(curp->roff); ! if (curp->man != NULL) ! roff_man_reset(curp->man); if (curp->secondary) curp->secondary->sz = 0; *************** *** 912,921 **** mparse_free(struct mparse *curp) { ! if (curp->man->macroset == MACROSET_MDOC) ! mdoc_free(curp->man); ! if (curp->man->macroset == MACROSET_MAN) ! man_free(curp->man); if (curp->roff) roff_free(curp->roff); if (curp->secondary) --- 901,907 ---- mparse_free(struct mparse *curp) { ! roff_man_free(curp->man); if (curp->roff) roff_free(curp->roff); if (curp->secondary)