-/* $Id: read.c,v 1.98 2014/11/26 23:42:14 schwarze Exp $ */
+/* $Id: read.c,v 1.104 2014/12/01 04:14:14 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
#include "libmandoc.h"
#include "mdoc.h"
#include "man.h"
-#include "main.h"
#define REPARSE_LIMIT 1000
"lower case character in document title",
"missing manual section, using \"\"",
"unknown manual section",
- "unknown manual volume or arch",
"missing date, using today's date",
"cannot parse date, using it verbatim",
"missing Os macro, using \"\"",
/* related to macros and nesting */
"obsolete macro",
+ "macro neither callable nor escaped",
"skipping paragraph macro",
"moving paragraph macro out of list",
"skipping no-space macro",
"empty list item",
"missing font type, using \\fR",
"unknown font type, using \\fR",
+ "nothing follows prefix",
"missing -std argument, adding it",
"missing eqn box, using \"\"",
/* related to request and macro arguments */
"escaped character not allowed in a name",
"argument count wrong",
+ "NOT IMPLEMENTED: Bd -file",
"missing list type, using -item",
"missing manual name, using \"\"",
"uname(3) system call failed, using UNKNOWN",
"generic fatal error",
"input too large",
- "NOT IMPLEMENTED: Bd -file",
"NOT IMPLEMENTED: .so with absolute path or \"..\"",
".so request failed",
struct buf ln;
size_t pos; /* byte number in the ln buffer */
enum rofferr rr;
- int of, rc;
+ int of;
int lnn; /* line number in the real file */
unsigned char c;
* Do the same for ROFF_EQN.
*/
- rc = -1;
-
- 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;
+ 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;
/* Temporary buffers typically are not full. */
}
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)
{
struct buf blk;
- blk.buf = UNCONST(buf);
+ blk.buf = buf;
blk.sz = len;
mparse_parse_buffer(curp, blk, file);