summaryrefslogtreecommitdiffstatshomepage
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
commit0eabacb3a7d215c5457b1a90099650131ad91c64 (patch)
tree19aa89508bc4aa37a27a753c032aaca9970e46d0 /mdoc.c
parentb955ea9093c1ade9ae232421ae55b82809cf9e4a (diff)
downloadmandoc-0eabacb3a7d215c5457b1a90099650131ad91c64.tar.gz
mandoc-0eabacb3a7d215c5457b1a90099650131ad91c64.tar.zst
mandoc-0eabacb3a7d215c5457b1a90099650131ad91c64.zip
mdoc error/warn macros replaced with real functions for GCC2 support (miod@openbsd.org).
Diffstat (limited to 'mdoc.c')
-rw-r--r--mdoc.c134
1 files changed, 133 insertions, 1 deletions
diff --git a/mdoc.c b/mdoc.c
index b3ad3f9e..580809ac 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.77 2009/06/12 12:52:51 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.78 2009/06/15 09:55:43 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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)
{