From 3df9170d3de4c2e6db515283aeb375d34e819233 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Wed, 15 Apr 2009 20:10:21 +0000 Subject: Replace variadic macros with real functions, so that this compiles on platforms still using gcc 2. ok deraadt@ --- usr.bin/mandoc/mdoc.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 134 insertions(+), 3 deletions(-) (limited to 'usr.bin/mandoc/mdoc.c') 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 * @@ -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; @@ -294,6 +293,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) -- cgit v1.2.3