version 1.136, 2015/04/18 17:01:58 |
version 1.139, 2015/04/19 14:25:41 |
|
|
#include "mdoc.h" |
#include "mdoc.h" |
#include "man.h" |
#include "man.h" |
#include "libmandoc.h" |
#include "libmandoc.h" |
|
#include "roff_int.h" |
|
|
#define REPARSE_LIMIT 1000 |
#define REPARSE_LIMIT 1000 |
|
|
Line 289 choose_parser(struct mparse *curp) |
|
Line 290 choose_parser(struct mparse *curp) |
|
} |
} |
} |
} |
|
|
if (format == MPARSE_MDOC) { |
if (curp->man == NULL) { |
if (curp->man == NULL) |
curp->man = roff_man_alloc(curp->roff, curp, curp->defos, |
curp->man = mdoc_alloc( |
curp->options & MPARSE_QUICK ? 1 : 0); |
curp->roff, curp, curp->defos, |
curp->man->macroset = MACROSET_MAN; |
MPARSE_QUICK & curp->options ? 1 : 0); |
curp->man->first->tok = TOKEN_NONE; |
else |
|
curp->man->macroset = MACROSET_MDOC; |
|
mdoc_hash_init(); |
|
return; |
|
} |
} |
|
|
/* Fall back to man(7) as a last resort. */ |
if (format == MPARSE_MDOC) { |
|
mdoc_hash_init(); |
if (curp->man == NULL) |
curp->man->macroset = MACROSET_MDOC; |
curp->man = man_alloc( |
curp->man->first->tok = TOKEN_NONE; |
curp->roff, curp, curp->defos, |
} else { |
MPARSE_QUICK & curp->options ? 1 : 0); |
man_hash_init(); |
else |
|
curp->man->macroset = MACROSET_MAN; |
curp->man->macroset = MACROSET_MAN; |
man_hash_init(); |
curp->man->first->tok = TOKEN_NONE; |
|
} |
} |
} |
|
|
/* |
/* |
|
|
* Do the same for ROFF_EQN. |
* Do the same for ROFF_EQN. |
*/ |
*/ |
|
|
if (rr == ROFF_TBL) { |
if (rr == ROFF_TBL) |
while ((span = roff_span(curp->roff)) != NULL) |
while ((span = roff_span(curp->roff)) != NULL) |
if (curp->man->macroset == MACROSET_MDOC) |
roff_addtbl(curp->man, span); |
mdoc_addspan(curp->man, span); |
else if (rr == ROFF_EQN) |
else |
roff_addeqn(curp->man, roff_eqn(curp->roff)); |
man_addspan(curp->man, span); |
else if ((curp->man->macroset == MACROSET_MDOC ? |
} else if (rr == ROFF_EQN) { |
|
if (curp->man->macroset == MACROSET_MDOC) |
|
mdoc_addeqn(curp->man, roff_eqn(curp->roff)); |
|
else |
|
man_addeqn(curp->man, roff_eqn(curp->roff)); |
|
} else if ((curp->man->macroset == MACROSET_MDOC ? |
|
mdoc_parseln(curp->man, curp->line, ln.buf, of) : |
mdoc_parseln(curp->man, curp->line, ln.buf, of) : |
man_parseln(curp->man, curp->line, ln.buf, of)) == 2) |
man_parseln(curp->man, curp->line, ln.buf, of)) == 2) |
break; |
break; |
Line 690 mparse_end(struct mparse *curp) |
|
Line 681 mparse_end(struct mparse *curp) |
|
{ |
{ |
|
|
if (curp->man == NULL && curp->sodest == NULL) |
if (curp->man == NULL && curp->sodest == NULL) |
curp->man = man_alloc(curp->roff, curp, curp->defos, |
curp->man = roff_man_alloc(curp->roff, curp, curp->defos, |
curp->options & MPARSE_QUICK ? 1 : 0); |
curp->options & MPARSE_QUICK ? 1 : 0); |
if (curp->man->macroset == MACROSET_NONE) |
if (curp->man->macroset == MACROSET_NONE) |
curp->man->macroset = MACROSET_MAN; |
curp->man->macroset = MACROSET_MAN; |
Line 892 mparse_alloc(int options, enum mandoclevel wlevel, man |
|
Line 883 mparse_alloc(int options, enum mandoclevel wlevel, man |
|
|
|
curp->mchars = mchars; |
curp->mchars = mchars; |
curp->roff = roff_alloc(curp, curp->mchars, options); |
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) { |
if (curp->options & MPARSE_MDOC) { |
curp->man = mdoc_alloc( |
|
curp->roff, curp, curp->defos, |
|
curp->options & MPARSE_QUICK ? 1 : 0); |
|
mdoc_hash_init(); |
mdoc_hash_init(); |
} |
curp->man->macroset = MACROSET_MDOC; |
if (curp->options & MPARSE_MAN) { |
} else if (curp->options & MPARSE_MAN) { |
curp->man = man_alloc( |
|
curp->roff, curp, curp->defos, |
|
curp->options & MPARSE_QUICK ? 1 : 0); |
|
man_hash_init(); |
man_hash_init(); |
|
curp->man->macroset = MACROSET_MAN; |
} |
} |
|
curp->man->first->tok = TOKEN_NONE; |
return(curp); |
return(curp); |
} |
} |
|
|
Line 914 mparse_reset(struct mparse *curp) |
|
Line 902 mparse_reset(struct mparse *curp) |
|
|
|
roff_reset(curp->roff); |
roff_reset(curp->roff); |
|
|
if (curp->man != NULL) { |
if (curp->man != NULL) |
if (curp->man->macroset == MACROSET_MDOC) |
roff_man_reset(curp->man); |
mdoc_reset(curp->man); |
|
else |
|
man_reset(curp->man); |
|
curp->man->macroset = MACROSET_NONE; |
|
} |
|
if (curp->secondary) |
if (curp->secondary) |
curp->secondary->sz = 0; |
curp->secondary->sz = 0; |
|
|
|
|
mparse_free(struct mparse *curp) |
mparse_free(struct mparse *curp) |
{ |
{ |
|
|
if (curp->man->macroset == MACROSET_MDOC) |
roff_man_free(curp->man); |
mdoc_free(curp->man); |
|
if (curp->man->macroset == MACROSET_MAN) |
|
man_free(curp->man); |
|
if (curp->roff) |
if (curp->roff) |
roff_free(curp->roff); |
roff_free(curp->roff); |
if (curp->secondary) |
if (curp->secondary) |