summaryrefslogtreecommitdiffstats
path: root/mdoc.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-06-15 09:55:43 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-06-15 09:55:43 +0000
commit6750956aa375ffc51c5434356b28b9fb570bb1dd (patch)
treec77433c815ef41932f89824dc6c30a6540461fff /mdoc.c
parent9e7021023952321677456dcd229745ea500abdf5 (diff)
downloadmandoc-6750956aa375ffc51c5434356b28b9fb570bb1dd.tar.gz
mdoc error/warn macros replaced with real functions for GCC2 support (miod@openbsd.org).
Diffstat (limited to 'mdoc.c')
-rw-r--r--mdoc.c132
1 files changed, 132 insertions, 0 deletions
diff --git a/mdoc.c b/mdoc.c
index 74c6b953..9e5bf545 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -293,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)
{