diff options
Diffstat (limited to 'usr.bin/mandoc/mdoc.c')
-rw-r--r-- | usr.bin/mandoc/mdoc.c | 137 |
1 files changed, 134 insertions, 3 deletions
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c index ca4a42f74dc..d1c84c6c870 100644 --- a/usr.bin/mandoc/mdoc.c +++ b/usr.bin/mandoc/mdoc.c @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.1 2009/04/06 20:30:40 kristaps Exp $ */ +/* $Id: mdoc.c,v 1.2 2009/04/15 20:10:20 miod Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org> * @@ -261,8 +261,7 @@ mdoc_vmsg(struct mdoc *mdoc, int ln, int pos, const char *fmt, ...) int -mdoc_verr(struct mdoc *mdoc, int ln, int pos, - const char *fmt, ...) +mdoc_verr(struct mdoc *mdoc, int ln, int pos, const char *fmt, ...) { char buf[256]; va_list ap; @@ -295,6 +294,138 @@ mdoc_vwarn(struct mdoc *mdoc, int ln, int pos, int +mdoc_nwarn(struct mdoc *mdoc, const struct mdoc_node *node, enum mdoc_warn type, + const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_warn) + return(0); + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + return((*mdoc->cb.mdoc_warn)(mdoc->data, node->line, node->pos, type, + buf)); +} + +int +mdoc_nerr(struct mdoc *mdoc, const struct mdoc_node *node, const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_err) + return(0); + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + return((*mdoc->cb.mdoc_err)(mdoc->data, node->line, node->pos, buf)); +} + + +int +mdoc_warn(struct mdoc *mdoc, enum mdoc_warn type, const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_warn) + return(0); + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + return((*mdoc->cb.mdoc_warn)(mdoc->data, mdoc->last->line, + mdoc->last->pos, type, buf)); +} + + +int +mdoc_err(struct mdoc *mdoc, const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_err) + return(0); + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + return((*mdoc->cb.mdoc_err)(mdoc->data, mdoc->last->line, + mdoc->last->pos, buf)); +} + + +void +mdoc_msg(struct mdoc *mdoc, const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_msg) + return; + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + (*mdoc->cb.mdoc_msg)(mdoc->data, mdoc->last->line, mdoc->last->pos, + buf); +} + + +void +mdoc_pmsg(struct mdoc *mdoc, int line, int pos, const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_msg) + return; + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + (*mdoc->cb.mdoc_msg)(mdoc->data, line, pos, buf); +} + + +int +mdoc_pwarn(struct mdoc *mdoc, int line, int pos, enum mdoc_warn type, + const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_warn) + return(0); + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + return((*mdoc->cb.mdoc_warn)(mdoc->data, line, pos, type, buf)); +} + +int +mdoc_perr(struct mdoc *mdoc, int line, int pos, const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_err) + return(0); + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + return((*mdoc->cb.mdoc_err)(mdoc->data, line, pos, buf)); +} + + +int mdoc_macro(struct mdoc *m, int tok, int ln, int pp, int *pos, char *buf) { |