summaryrefslogtreecommitdiffstats
path: root/man.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-03-20 16:02:05 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-03-20 16:02:05 +0000
commit80339b751a1833d9bbbf9856e7f48f56d91ba1d3 (patch)
tree4e59124e25202b7fa3543b670ae8434c1256cd45 /man.c
parent7ff718a5d9d20e97b6431bb61dc4cb34a1f431c7 (diff)
downloadmandoc-80339b751a1833d9bbbf9856e7f48f56d91ba1d3.tar.gz
Consolidate messages. Have all parse-time messages (in libmdoc,
libroff, etc., etc.) route into mandoc_msg() and mandoc_vmsg(), for the time being in libmandoc.h. This requires struct mparse to be passed into the allocation routines instead of mandocmsg and a void pointer. Then, move some of the functionality of the old mmsg() into read.c's mparse_mmsg() (check against wlevel and setting of file_status) and use main.c's mmsg() as simply a printing tool.
Diffstat (limited to 'man.c')
-rw-r--r--man.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/man.c b/man.c
index c3ff9430..5b302bc1 100644
--- a/man.c
+++ b/man.c
@@ -95,15 +95,14 @@ man_free(struct man *man)
struct man *
-man_alloc(struct regset *regs, void *data, mandocmsg msg)
+man_alloc(struct regset *regs, struct mparse *parse)
{
struct man *p;
p = mandoc_calloc(1, sizeof(struct man));
man_hash_init();
- p->data = data;
- p->msg = msg;
+ p->parse = parse;
p->regs = regs;
man_alloc1(p);
@@ -521,7 +520,8 @@ man_pmacro(struct man *m, int ln, char *buf, int offs)
tok = (j > 0 && j < 4) ? man_hash_find(mac) : MAN_MAX;
if (MAN_MAX == tok) {
- man_vmsg(m, MANDOCERR_MACRO, ln, ppos, "%s", buf + ppos - 1);
+ mandoc_vmsg(MANDOCERR_MACRO, m->parse, ln,
+ ppos, "%s", buf + ppos - 1);
return(1);
}
@@ -554,8 +554,8 @@ man_pmacro(struct man *m, int ln, char *buf, int offs)
if (MAN_NSCOPED & man_macros[n->tok].flags)
n = n->parent;
- man_vmsg(m, MANDOCERR_LINESCOPE, n->line, n->pos,
- "%s", man_macronames[n->tok]);
+ mandoc_vmsg(MANDOCERR_LINESCOPE, m->parse, n->line,
+ n->pos, "%s", man_macronames[n->tok]);
man_node_delete(m, n);
m->flags &= ~MAN_ELINE;
@@ -621,21 +621,6 @@ err: /* Error out. */
return(0);
}
-
-void
-man_vmsg(struct man *man, enum mandocerr t,
- int ln, int pos, const char *fmt, ...)
-{
- char buf[256];
- va_list ap;
-
- va_start(ap, fmt);
- vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
- va_end(ap);
- (*man->msg)(t, man->data, ln, pos, buf);
-}
-
-
/*
* Unlink a node from its context. If "m" is provided, the last parse
* point will also be adjusted accordingly.