version 1.98, 2014/11/26 23:42:14 |
version 1.106, 2014/12/28 14:42:27 |
|
|
#include "libmandoc.h" |
#include "libmandoc.h" |
#include "mdoc.h" |
#include "mdoc.h" |
#include "man.h" |
#include "man.h" |
#include "main.h" |
|
|
|
#define REPARSE_LIMIT 1000 |
#define REPARSE_LIMIT 1000 |
|
|
Line 97 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
Line 96 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
"lower case character in document title", |
"lower case character in document title", |
"missing manual section, using \"\"", |
"missing manual section, using \"\"", |
"unknown manual section", |
"unknown manual section", |
"unknown manual volume or arch", |
|
"missing date, using today's date", |
"missing date, using today's date", |
"cannot parse date, using it verbatim", |
"cannot parse date, using it verbatim", |
"missing Os macro, using \"\"", |
"missing Os macro, using \"\"", |
Line 121 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
Line 119 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
|
|
/* related to macros and nesting */ |
/* related to macros and nesting */ |
"obsolete macro", |
"obsolete macro", |
|
"macro neither callable nor escaped", |
"skipping paragraph macro", |
"skipping paragraph macro", |
"moving paragraph macro out of list", |
"moving paragraph macro out of list", |
"skipping no-space macro", |
"skipping no-space macro", |
Line 146 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
Line 145 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
"empty list item", |
"empty list item", |
"missing font type, using \\fR", |
"missing font type, using \\fR", |
"unknown font type, using \\fR", |
"unknown font type, using \\fR", |
|
"nothing follows prefix", |
"missing -std argument, adding it", |
"missing -std argument, adding it", |
"missing eqn box, using \"\"", |
"missing eqn box, using \"\"", |
|
|
Line 188 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
Line 188 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
"ignore data in cell", |
"ignore data in cell", |
"data block still open", |
"data block still open", |
"ignoring extra data cells", |
"ignoring extra data cells", |
|
"ignoring macro in table", |
|
|
/* related to document structure and macros */ |
/* related to document structure and macros */ |
"input stack limit exceeded, infinite loop?", |
"input stack limit exceeded, infinite loop?", |
Line 202 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
Line 203 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
/* related to request and macro arguments */ |
/* related to request and macro arguments */ |
"escaped character not allowed in a name", |
"escaped character not allowed in a name", |
"argument count wrong", |
"argument count wrong", |
|
"NOT IMPLEMENTED: Bd -file", |
"missing list type, using -item", |
"missing list type, using -item", |
"missing manual name, using \"\"", |
"missing manual name, using \"\"", |
"uname(3) system call failed, using UNKNOWN", |
"uname(3) system call failed, using UNKNOWN", |
Line 214 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
Line 216 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
"generic fatal error", |
"generic fatal error", |
|
|
"input too large", |
"input too large", |
"NOT IMPLEMENTED: Bd -file", |
|
"NOT IMPLEMENTED: .so with absolute path or \"..\"", |
"NOT IMPLEMENTED: .so with absolute path or \"..\"", |
".so request failed", |
".so request failed", |
|
|
Line 297 choose_parser(struct mparse *curp) |
|
Line 298 choose_parser(struct mparse *curp) |
|
/* Fall back to man(7) as a last resort. */ |
/* Fall back to man(7) as a last resort. */ |
|
|
if (NULL == curp->pman) |
if (NULL == curp->pman) |
curp->pman = man_alloc(curp->roff, curp, |
curp->pman = man_alloc( |
|
curp->roff, curp, curp->defos, |
MPARSE_QUICK & curp->options ? 1 : 0); |
MPARSE_QUICK & curp->options ? 1 : 0); |
assert(curp->pman); |
assert(curp->pman); |
curp->man = curp->pman; |
curp->man = curp->pman; |
Line 317 mparse_buf_r(struct mparse *curp, struct buf blk, size |
|
Line 319 mparse_buf_r(struct mparse *curp, struct buf blk, size |
|
struct buf ln; |
struct buf ln; |
size_t pos; /* byte number in the ln buffer */ |
size_t pos; /* byte number in the ln buffer */ |
enum rofferr rr; |
enum rofferr rr; |
int of, rc; |
int of; |
int lnn; /* line number in the real file */ |
int lnn; /* line number in the real file */ |
unsigned char c; |
unsigned char c; |
|
|
|
|
* Do the same for ROFF_EQN. |
* Do the same for ROFF_EQN. |
*/ |
*/ |
|
|
rc = -1; |
if (rr == ROFF_TBL) { |
|
while ((span = roff_span(curp->roff)) != NULL) |
|
if (curp->man == NULL) |
|
mdoc_addspan(curp->mdoc, span); |
|
else |
|
man_addspan(curp->man, span); |
|
} else if (rr == ROFF_EQN) { |
|
if (curp->man == NULL) |
|
mdoc_addeqn(curp->mdoc, roff_eqn(curp->roff)); |
|
else |
|
man_addeqn(curp->man, roff_eqn(curp->roff)); |
|
} else if ((curp->man == NULL ? |
|
mdoc_parseln(curp->mdoc, curp->line, ln.buf, of) : |
|
man_parseln(curp->man, curp->line, ln.buf, of)) == 2) |
|
break; |
|
|
if (ROFF_TBL == rr) |
|
while (NULL != (span = roff_span(curp->roff))) { |
|
rc = curp->man ? |
|
man_addspan(curp->man, span) : |
|
mdoc_addspan(curp->mdoc, span); |
|
if (0 == rc) |
|
break; |
|
} |
|
else if (ROFF_EQN == rr) |
|
rc = curp->mdoc ? |
|
mdoc_addeqn(curp->mdoc, |
|
roff_eqn(curp->roff)) : |
|
man_addeqn(curp->man, |
|
roff_eqn(curp->roff)); |
|
else if (curp->man || curp->mdoc) |
|
rc = curp->man ? |
|
man_parseln(curp->man, |
|
curp->line, ln.buf, of) : |
|
mdoc_parseln(curp->mdoc, |
|
curp->line, ln.buf, of); |
|
|
|
if (0 == rc) { |
|
assert(MANDOCLEVEL_FATAL <= curp->file_status); |
|
break; |
|
} else if (2 == rc) |
|
break; |
|
|
|
/* Temporary buffers typically are not full. */ |
/* Temporary buffers typically are not full. */ |
|
|
if (0 == start && '\0' == blk.buf[i]) |
if (0 == start && '\0' == blk.buf[i]) |
Line 708 mparse_end(struct mparse *curp) |
|
Line 697 mparse_end(struct mparse *curp) |
|
curp->mdoc = curp->pmdoc; |
curp->mdoc = curp->pmdoc; |
else { |
else { |
if (curp->pman == NULL) |
if (curp->pman == NULL) |
curp->pman = man_alloc(curp->roff, curp, |
curp->pman = man_alloc( |
|
curp->roff, curp, curp->defos, |
curp->options & MPARSE_QUICK ? 1 : 0); |
curp->options & MPARSE_QUICK ? 1 : 0); |
curp->man = curp->pman; |
curp->man = curp->pman; |
} |
} |
Line 768 mparse_parse_buffer(struct mparse *curp, struct buf bl |
|
Line 758 mparse_parse_buffer(struct mparse *curp, struct buf bl |
|
} |
} |
|
|
enum mandoclevel |
enum mandoclevel |
mparse_readmem(struct mparse *curp, const void *buf, size_t len, |
mparse_readmem(struct mparse *curp, void *buf, size_t len, |
const char *file) |
const char *file) |
{ |
{ |
struct buf blk; |
struct buf blk; |
|
|
blk.buf = UNCONST(buf); |
blk.buf = buf; |
blk.sz = len; |
blk.sz = len; |
|
|
mparse_parse_buffer(curp, blk, file); |
mparse_parse_buffer(curp, blk, file); |
Line 952 mparse_alloc(int options, enum mandoclevel wlevel, man |
|
Line 942 mparse_alloc(int options, enum mandoclevel wlevel, man |
|
curp->roff, curp, curp->defos, |
curp->roff, curp, curp->defos, |
curp->options & MPARSE_QUICK ? 1 : 0); |
curp->options & MPARSE_QUICK ? 1 : 0); |
if (curp->options & MPARSE_MAN) |
if (curp->options & MPARSE_MAN) |
curp->pman = man_alloc(curp->roff, curp, |
curp->pman = man_alloc( |
|
curp->roff, curp, curp->defos, |
curp->options & MPARSE_QUICK ? 1 : 0); |
curp->options & MPARSE_QUICK ? 1 : 0); |
|
|
return(curp); |
return(curp); |