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 /mdoc.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 'mdoc.c')
-rw-r--r-- | mdoc.c | 28 |
1 files changed, 6 insertions, 22 deletions
@@ -192,14 +192,13 @@ mdoc_free(struct mdoc *mdoc) * Allocate volatile and non-volatile parse resources. */ struct mdoc * -mdoc_alloc(struct regset *regs, void *data, mandocmsg msg) +mdoc_alloc(struct regset *regs, struct mparse *parse) { struct mdoc *p; p = mandoc_calloc(1, sizeof(struct mdoc)); - p->msg = msg; - p->data = data; + p->parse = parse; p->regs = regs; mdoc_hash_init(); @@ -302,22 +301,6 @@ mdoc_parseln(struct mdoc *m, int ln, char *buf, int offs) mdoc_ptext(m, ln, buf, offs)); } - -void -mdoc_vmsg(struct mdoc *mdoc, 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); - - (*mdoc->msg)(t, mdoc->data, ln, pos, buf); -} - - int mdoc_macro(MACRO_PROT_ARGS) { @@ -345,8 +328,8 @@ mdoc_macro(MACRO_PROT_ARGS) if (NULL == m->meta.os) m->meta.os = mandoc_strdup("LOCAL"); if (NULL == m->meta.date) - m->meta.date = mandoc_normdate(NULL, - m->msg, m->data, line, ppos); + m->meta.date = mandoc_normdate + (m->parse, NULL, line, ppos); m->flags |= MDOC_PBODY; } @@ -849,7 +832,8 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) tok = (j > 1 || j < 4) ? mdoc_hash_find(mac) : MDOC_MAX; if (MDOC_MAX == tok) { - mdoc_vmsg(m, MANDOCERR_MACRO, ln, sv, "%s", buf + sv - 1); + mandoc_vmsg(MANDOCERR_MACRO, m->parse, + ln, sv, "%s", buf + sv - 1); return(1); } |