diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-03-20 16:02:05 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-03-20 16:02:05 +0000 |
commit | 80339b751a1833d9bbbf9856e7f48f56d91ba1d3 (patch) | |
tree | 4e59124e25202b7fa3543b670ae8434c1256cd45 /man.c | |
parent | 7ff718a5d9d20e97b6431bb61dc4cb34a1f431c7 (diff) | |
download | mandoc-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.c | 27 |
1 files changed, 6 insertions, 21 deletions
@@ -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. |