summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-01-15 17:38:57 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-01-15 17:38:57 +0000
commit49aead8ab67de188578d52298d35707f7a62a695 (patch)
tree2a01361f65d5a4fb73dc96b290c5c0c664d2a12f
parentfbf268cbe56d069d49e3960a6a269662a47bbd79 (diff)
downloadmandoc-49aead8ab67de188578d52298d35707f7a62a695.tar.gz
Broken build (changing err/warn/msg function prototypes for clarity).
-rw-r--r--macro.c6
-rw-r--r--mdoc.c56
-rw-r--r--mdoc.h68
-rw-r--r--mdocml.c277
-rw-r--r--private.h66
-rw-r--r--validate.c18
6 files changed, 168 insertions, 323 deletions
diff --git a/macro.c b/macro.c
index 51de7ddd..83547260 100644
--- a/macro.c
+++ b/macro.c
@@ -355,7 +355,7 @@ rewind_subblock(enum mdoc_type type, struct mdoc *mdoc, int tok)
break;
else if (rewind_dobreak(tok, type, n))
continue;
- return(mdoc_verr(mdoc, n, ERR_SCOPE_BREAK));
+ return(mdoc_nerr(mdoc, n, "body scope broken"));
}
assert(n);
@@ -384,7 +384,7 @@ rewind_expblock(struct mdoc *mdoc, int tok)
break;
else if (rewind_dobreak(tok, MDOC_BLOCK, n))
continue;
- return(mdoc_verr(mdoc, n, ERR_SCOPE_BREAK));
+ return(mdoc_nerr(mdoc, n, "macro scope broken"));
}
assert(n);
@@ -414,7 +414,7 @@ rewind_impblock(struct mdoc *mdoc, int tok)
break;
else if (rewind_dobreak(tok, MDOC_BLOCK, n))
continue;
- return(mdoc_verr(mdoc, n, ERR_SCOPE_BREAK));
+ return(mdoc_nerr(mdoc, n, "macro scope broken"));
}
assert(n);
diff --git a/mdoc.c b/mdoc.c
index a910823c..e3ba2b93 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -288,7 +288,7 @@ mdoc_parseln(struct mdoc *mdoc, int line, char *buf)
mdoc->next = MDOC_NEXT_SIBLING;
return(1);
}
- return(mdoc_perr(mdoc, line, 0, ERR_SYNTAX_NOTEXT));
+ return(mdoc_perr(mdoc, line, 0, "text disallowed"));
}
if (buf[1] && '\\' == buf[1])
@@ -301,10 +301,10 @@ mdoc_parseln(struct mdoc *mdoc, int line, char *buf)
if (i == (int)sizeof(tmp)) {
mdoc->flags |= MDOC_HALT;
- return(mdoc_perr(mdoc, line, 1, ERR_MACRO_NOTSUP));
+ return(mdoc_perr(mdoc, line, 1, "unknown macro"));
} else if (i <= 2) {
mdoc->flags |= MDOC_HALT;
- return(mdoc_perr(mdoc, line, 1, ERR_MACRO_NOTSUP));
+ return(mdoc_perr(mdoc, line, 1, "unknown macro"));
}
i--;
@@ -314,7 +314,7 @@ mdoc_parseln(struct mdoc *mdoc, int line, char *buf)
if (MDOC_MAX == (c = mdoc_find(mdoc, tmp))) {
mdoc->flags |= MDOC_HALT;
- return(mdoc_perr(mdoc, line, 1, ERR_MACRO_NOTSUP));
+ return(mdoc_perr(mdoc, line, 1, "unknown macro"));
}
while (buf[i] && isspace(buf[i]))
@@ -329,45 +329,52 @@ mdoc_parseln(struct mdoc *mdoc, int line, char *buf)
void
-mdoc_msg(struct mdoc *mdoc, const char *fmt, ...)
+mdoc_vmsg(struct mdoc *mdoc, int ln, int pos, const char *fmt, ...)
{
- struct mdoc_node *n;
- va_list ap;
char buf[256];
+ va_list ap;
if (NULL == mdoc->cb.mdoc_msg)
return;
- n = mdoc->last;
- assert(n);
-
va_start(ap, fmt);
- (void)vsnprintf(buf, sizeof(buf), fmt, ap);
+ (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
va_end(ap);
-
- (*mdoc->cb.mdoc_msg)(mdoc->data, n->line, n->pos, buf);
+ (*mdoc->cb.mdoc_msg)(mdoc->data, ln, pos, buf);
}
int
-mdoc_perr(struct mdoc *mdoc,
- int line, int pos, enum mdoc_err type)
+mdoc_verr(struct mdoc *mdoc, int ln, int pos,
+ const char *fmt, ...)
{
+ char buf[256];
+ va_list ap;
if (NULL == mdoc->cb.mdoc_err)
return(0);
- return((*mdoc->cb.mdoc_err)(mdoc->data, line, pos, type));
+
+ va_start(ap, fmt);
+ (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
+ va_end(ap);
+ return((*mdoc->cb.mdoc_err)(mdoc->data, ln, pos, buf));
}
int
-mdoc_pwarn(struct mdoc *mdoc,
- int line, int pos, enum mdoc_warn type)
+mdoc_vwarn(struct mdoc *mdoc, int ln, int pos,
+ enum mdoc_warn type, const char *fmt, ...)
{
+ char buf[256];
+ va_list ap;
if (NULL == mdoc->cb.mdoc_warn)
return(0);
- return((*mdoc->cb.mdoc_warn)(mdoc->data, line, pos, type));
+
+ va_start(ap, fmt);
+ (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
+ va_end(ap);
+ return((*mdoc->cb.mdoc_warn)(mdoc->data, ln, pos, type, buf));
}
@@ -376,16 +383,13 @@ mdoc_macro(struct mdoc *mdoc, int tok,
int ln, int ppos, int *pos, char *buf)
{
+ assert(mdoc_macros[tok].fp);
+
if ( ! (MDOC_PROLOGUE & mdoc_macros[tok].flags) &&
SEC_PROLOGUE == mdoc->sec_lastn)
- return(mdoc_perr(mdoc, ln, ppos, ERR_SEC_PROLOGUE));
-
- if (NULL == (mdoc_macros[tok].fp))
- return(mdoc_perr(mdoc, ln, ppos, ERR_MACRO_NOTSUP));
-
+ return(mdoc_perr(mdoc, ln, ppos, "macro disallowed in document prologue"));
if (1 != ppos && ! (MDOC_CALLABLE & mdoc_macros[tok].flags))
- return(mdoc_perr(mdoc, ln, ppos, ERR_MACRO_NOTCALL));
-
+ return(mdoc_perr(mdoc, ln, ppos, "macro not callable"));
return((*mdoc_macros[tok].fp)(mdoc, tok, ln, ppos, pos, buf));
}
diff --git a/mdoc.h b/mdoc.h
index 9c05c0f4..66a0ce6f 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -19,8 +19,12 @@
#ifndef MDOC_H
#define MDOC_H
+/* FIXME: move this elsewhere (it's 9, too). */
+
#define MDOC_LINEARG_MAX 12
+/* What follows is a list of ALL possible macros. */
+
#define MDOC___ 0
#define MDOC_Dd 1
#define MDOC_Dt 2
@@ -129,6 +133,8 @@
#define MDOC_Ud 105
#define MDOC_MAX 106
+/* What follows is a list of ALL possible macro arguments. */
+
#define MDOC_Split 0
#define MDOC_Nosplit 1
#define MDOC_Ragged 2
@@ -193,42 +199,9 @@
#define MDOC_Symbolic 61
#define MDOC_ARG_MAX 62
-/* FIXME: have these be generic groups. */
-
-enum mdoc_err {
- ERR_SYNTAX_QUOTE, /* NOTUSED */
- ERR_SYNTAX_UNQUOTE,
- ERR_SYNTAX_NOPUNCT,
- ERR_SYNTAX_WS,
- ERR_SYNTAX_ARG,
- ERR_SYNTAX_ARGFORM,
- ERR_SYNTAX_ARGVAL,
- ERR_SYNTAX_ARGBAD,
- ERR_SYNTAX_ARGMISS,
- ERR_SYNTAX_ARGMANY,
- ERR_MACRO_NOTSUP,
- ERR_MACRO_NOTCALL,
- ERR_SCOPE_BREAK,
- ERR_SCOPE_NOCTX,
- ERR_SCOPE_NONEST,
- ERR_SEC_PROLOGUE,
- ERR_SEC_NPROLOGUE,
- ERR_SEC_PROLOGUE_OO,
- ERR_SEC_PROLOGUE_REP,
- ERR_SEC_NAME,
- ERR_ARGS_EQ0,
- ERR_ARGS_EQ1,
- ERR_ARGS_GE1,
- ERR_ARGS_LE2,
- ERR_ARGS_LE8,
- ERR_ARGS_MANY,
- ERR_SYNTAX_CHILDBAD,
- ERR_SYNTAX_PARENTBAD,
- ERR_SYNTAX_CHILDHEAD,
- ERR_SYNTAX_CHILDBODY,
- ERR_SYNTAX_EMPTYBODY,
- ERR_SYNTAX_EMPTYHEAD,
- ERR_SYNTAX_NOTEXT
+enum mdoc_warn {
+ WARN_SYNTAX, /* Syntax warn (at line/col). */
+ WARN_COMPAT /* Groff compat warn (at line/col). */
};
enum mdoc_att {
@@ -247,24 +220,6 @@ enum mdoc_att {
ATT_V4
};
-enum mdoc_warn {
- WARN_SYNTAX_WS_EOLN,
- WARN_SYNTAX_MACLIKE,
- WARN_SYNTAX_ARGLIKE,
- WARN_SYNTAX_QUOTED,
- WARN_SYNTAX_EMPTYHEAD,
- WARN_SYNTAX_EMPTYBODY,
- WARN_SYNTAX_NOBODY,
- WARN_IGN_AFTER_BLK,
- WARN_IGN_BEFORE_BLK,
- WARN_IGN_OBSOLETE,
- WARN_SEC_OO,
- WARN_SEC_REP,
- WARN_ARGS_GE1,
- WARN_ARGS_EQ0,
- WARN_COMPAT_TROFF
-};
-
struct mdoc_arg {
int arg;
int line;
@@ -417,9 +372,10 @@ struct mdoc_node {
};
struct mdoc_cb {
- int (*mdoc_err)(void *, int, int, enum mdoc_err);
- int (*mdoc_warn)(void *, int, int, enum mdoc_warn);
void (*mdoc_msg)(void *, int, int, const char *);
+ int (*mdoc_err)(void *, int, int, const char *);
+ int (*mdoc_warn)(void *, int, int,
+ enum mdoc_warn, const char *);
};
extern const char *const *mdoc_macronames;
diff --git a/mdocml.c b/mdocml.c
index 74e7910d..2896c417 100644
--- a/mdocml.c
+++ b/mdocml.c
@@ -30,20 +30,28 @@
#include "mdoc.h"
-#define MD_LINE_SZ (256)
+#define xfprintf (void)fprintf
+#define xprintf (void)printf
+#define xvfprintf (void)fvprintf
+
+#define MD_LINE_SZ (256) /* Max input line size. */
struct md_parse {
- int warn;
-#define MD_WARN_ALL (1 << 0)
-#define MD_WARN_ERR (1 << 1)
- int dbg;
- struct mdoc *mdoc;
- char *buf;
- u_long bufsz;
- char *name;
- int fd;
+ int warn; /* Warning flags. */
+#define MD_WARN_SYNTAX (1 << 0) /* Show syntax warnings. */
+#define MD_WARN_COMPAT (1 << 1) /* Show compat warnings. */
+#define MD_WARN_ALL (0x03) /* Show all warnings. */
+#define MD_WARN_ERR (1 << 2) /* Make warnings->errors. */
+ int dbg; /* Debug level. */
+ struct mdoc *mdoc; /* Active parser. */
+ char *buf; /* Input buffer. */
+ u_long bufsz; /* Input buffer size. */
+ char *name; /* Input file name. */
+ int fd; /* Input file desc. */
};
+extern char *__progname;
+
static void usage(void);
static int parse_begin(struct md_parse *);
@@ -53,9 +61,10 @@ static int io_leave(struct md_parse *, int);
static int buf_begin(struct md_parse *);
static int buf_leave(struct md_parse *, int);
-static int msg_err(void *, int, int, enum mdoc_err);
-static int msg_warn(void *, int, int, enum mdoc_warn);
static void msg_msg(void *, int, int, const char *);
+static int msg_err(void *, int, int, const char *);
+static int msg_warn(void *, int, int,
+ enum mdoc_warn, const char *);
#ifdef __linux__
extern int getsubopt(char **, char *const *, char **);
@@ -68,8 +77,11 @@ main(int argc, char *argv[])
struct md_parse parser;
char *opts, *v;
#define ALL 0
-#define ERROR 1
- char *toks[] = { "all", "error", NULL };
+#define COMPAT 1
+#define SYNTAX 2
+#define ERROR 3
+ char *toks[] = { "all", "compat", "syntax",
+ "error", NULL };
extern char *optarg;
extern int optind;
@@ -88,6 +100,12 @@ main(int argc, char *argv[])
case (ALL):
parser.warn |= MD_WARN_ALL;
break;
+ case (COMPAT):
+ parser.warn |= MD_WARN_COMPAT;
+ break;
+ case (SYNTAX):
+ parser.warn |= MD_WARN_SYNTAX;
+ break;
case (ERROR):
parser.warn |= MD_WARN_ERR;
break;
@@ -186,15 +204,13 @@ print_node(const struct mdoc_node *n, int indent)
struct mdoc_arg *argv;
argv = NULL;
- argc = 0;
+ argc = sz = 0;
params = NULL;
- sz = 0;
t = mdoc_type2a(n->type);
switch (n->type) {
case (MDOC_TEXT):
- assert(NULL == n->child);
p = n->data.text.string;
break;
case (MDOC_BODY):
@@ -225,23 +241,23 @@ print_node(const struct mdoc_node *n, int indent)
}
for (i = 0; i < indent; i++)
- (void)printf(" ");
- (void)printf("%s (%s)", p, t);
+ xprintf(" ");
+ xprintf("%s (%s)", p, t);
for (i = 0; i < (int)argc; i++) {
- (void)printf(" -%s", mdoc_argnames[argv[i].arg]);
+ xprintf(" -%s", mdoc_argnames[argv[i].arg]);
if (argv[i].sz > 0)
- (void)printf(" [");
+ xprintf(" [");
for (j = 0; j < (int)argv[i].sz; j++)
- (void)printf(" [%s]", argv[i].value[j]);
+ xprintf(" [%s]", argv[i].value[j]);
if (argv[i].sz > 0)
- (void)printf(" ]");
+ xprintf(" ]");
}
for (i = 0; i < (int)sz; i++)
- (void)printf(" [%s]", params[i]);
+ xprintf(" [%s]", params[i]);
- (void)printf(" %d:%d\n", n->line, n->pos);
+ xprintf(" %d:%d\n", n->line, n->pos);
if (n->child)
print_node(n->child, indent + 1);
@@ -274,7 +290,7 @@ parse_begin(struct md_parse *p)
{
ssize_t sz, i;
size_t pos;
- char line[256], sv[256];
+ char line[MD_LINE_SZ];
struct mdoc_cb cb;
int lnn;
@@ -295,9 +311,7 @@ parse_begin(struct md_parse *p)
for (i = 0; i < sz; i++) {
if ('\n' != p->buf[i]) {
if (pos < sizeof(line)) {
- sv[(int)pos] = p->buf[(int)i];
- line[(int)pos++] =
- p->buf[(int)i];
+ line[(int)pos++] = p->buf[(int)i];
continue;
}
warnx("%s: line %d too long",
@@ -305,7 +319,7 @@ parse_begin(struct md_parse *p)
return(parse_leave(p, 0));
}
- line[(int)pos] = sv[(int)pos] = 0;
+ line[(int)pos] = 0;
if ( ! mdoc_parseln(p->mdoc, lnn, line))
return(parse_leave(p, 0));
@@ -319,122 +333,14 @@ parse_begin(struct md_parse *p)
static int
-msg_err(void *arg, int line, int col, enum mdoc_err type)
+msg_err(void *arg, int line, int col, const char *msg)
{
- char *lit;
struct md_parse *p;
p = (struct md_parse *)arg;
- lit = NULL;
-
- switch (type) {
- case (ERR_SYNTAX_NOTEXT):
- lit = "syntax: context-free text disallowed";
- break;
- case (ERR_SYNTAX_QUOTE):
- lit = "syntax: disallowed argument quotation";
- break;
- case (ERR_SYNTAX_UNQUOTE):
- lit = "syntax: unterminated quotation";
- break;
- case (ERR_SYNTAX_WS):
- lit = "syntax: whitespace in argument";
- break;
- case (ERR_SYNTAX_ARGFORM):
- lit = "syntax: macro arguments malformed";
- break;
- case (ERR_SYNTAX_NOPUNCT):
- lit = "syntax: macro doesn't understand punctuation";
- break;
- case (ERR_SYNTAX_ARG):
- lit = "syntax: unknown argument for macro";
- break;
- case (ERR_SCOPE_BREAK):
- lit = "scope: macro breaks prior scope";
- break;
- case (ERR_SCOPE_NOCTX):
- lit = "scope: closure macro has no context";
- break;
- case (ERR_SCOPE_NONEST):
- lit = "scope: macro may not be nested in the current context";
- break;
- case (ERR_MACRO_NOTSUP):
- lit = "macro not supported";
- break;
- case (ERR_MACRO_NOTCALL):
- lit = "macro not callable";
- break;
- case (ERR_SEC_PROLOGUE):
- lit = "macro cannot be called in the prologue";
- break;
- case (ERR_SEC_NPROLOGUE):
- lit = "macro called outside of prologue";
- break;
- case (ERR_ARGS_EQ0):
- lit = "macro expects zero arguments";
- break;
- case (ERR_ARGS_EQ1):
- lit = "macro expects one argument";
- break;
- case (ERR_ARGS_GE1):
- lit = "macro expects one or more arguments";
- break;
- case (ERR_ARGS_LE2):
- lit = "macro expects two or fewer arguments";
- break;
- case (ERR_ARGS_LE8):
- lit = "macro expects eight or fewer arguments";
- break;
- case (ERR_ARGS_MANY):
- lit = "macro has too many arguments";
- break;
- case (ERR_SEC_PROLOGUE_OO):
- lit = "prologue macro is out-of-order";
- break;
- case (ERR_SEC_PROLOGUE_REP):
- lit = "prologue macro repeated";
- break;
- case (ERR_SEC_NAME):
- lit = "`NAME' section must be first";
- break;
- case (ERR_SYNTAX_ARGVAL):
- lit = "syntax: expected value for macro argument";
- break;
- case (ERR_SYNTAX_ARGBAD):
- lit = "syntax: invalid value(s) for macro argument";
- break;
- case (ERR_SYNTAX_ARGMISS):
- lit = "syntax: missing required argument(s) for macro";
- break;
- case (ERR_SYNTAX_ARGMANY):
- lit = "syntax: too many values for macro argument";
- break;
- case (ERR_SYNTAX_CHILDBAD):
- lit = "syntax: invalid child for parent macro";
- break;
- case (ERR_SYNTAX_PARENTBAD):
- lit = "syntax: invalid parent for macro";
- break;
- case (ERR_SYNTAX_CHILDHEAD):
- lit = "syntax: expected only block-header section";
- break;
- case (ERR_SYNTAX_CHILDBODY):
- lit = "syntax: expected only a block-body section";
- break;
- case (ERR_SYNTAX_EMPTYHEAD):
- lit = "syntax: block-header section may not be empty";
- break;
- case (ERR_SYNTAX_EMPTYBODY):
- lit = "syntax: block-body section may not be empty";
- break;
- default:
- abort();
- /* NOTREACHED */
- }
-
- (void)fprintf(stderr, "%s:%d: error: %s (column %d)\n",
- p->name, line, lit, col);
+ xfprintf(stderr, "%s:%d: error: %s (column %d)",
+ p->name, line, msg, col);
return(0);
}
@@ -446,99 +352,50 @@ msg_msg(void *arg, int line, int col, const char *msg)
p = (struct md_parse *)arg;
- if (p->dbg < 2)
+ if (0 == p->dbg)
return;
- (void)printf("%s:%d: %s (column %d)\n",
+ xfprintf(stderr, "%s:%d: debug: %s (column %d)",
p->name, line, msg, col);
}
static int
-msg_warn(void *arg, int line, int col, enum mdoc_warn type)
+msg_warn(void *arg, int line, int col,
+ enum mdoc_warn type, const char *msg)
{
- char *lit;
struct md_parse *p;
- extern char *__progname;
p = (struct md_parse *)arg;
- if ( ! (p->warn & MD_WARN_ALL))
- return(1);
-
- lit = NULL;
-
switch (type) {
- case (WARN_SYNTAX_WS_EOLN):
- lit = "syntax: whitespace at end-of-line";
- break;
- case (WARN_SYNTAX_QUOTED):
- lit = "syntax: quotation mark starting string";
- break;
- case (WARN_SYNTAX_MACLIKE):
- lit = "syntax: macro-like argument";
- break;
- case (WARN_SYNTAX_ARGLIKE):
- lit = "syntax: argument-like value";
- break;
- case (WARN_SYNTAX_EMPTYBODY):
- lit = "syntax: macro suggests non-empty block-body section";
- break;
- case (WARN_SYNTAX_EMPTYHEAD):
- lit = "syntax: macro suggests non-empty block-head section";
- break;
- case (WARN_SYNTAX_NOBODY):
- lit = "syntax: macro suggests empty block-body section";
- break;
- case (WARN_SEC_OO):
- lit = "section is out of conventional order";
- break;
- case (WARN_SEC_REP):
- lit = "section repeated";
- break;
- case (WARN_ARGS_GE1):
- lit = "macro suggests one or more arguments";
- break;
- case (WARN_ARGS_EQ0):
- lit = "macro suggests zero arguments";
- break;
- case (WARN_IGN_AFTER_BLK):
- lit = "ignore: macro ignored after block macro";
- break;
- case (WARN_IGN_OBSOLETE):
- lit = "ignore: macro is obsolete";
- break;
- case (WARN_IGN_BEFORE_BLK):
- lit = "ignore: macro before block macro ignored";
- break;
- case (WARN_COMPAT_TROFF):
- lit = "compat: macro behaves differently in troff and nroff";
- break;
- default:
- abort();
- /* NOTREACHED */
+ case (WARN_COMPAT):
+ if (p->warn & MD_WARN_COMPAT)
+ break;
+ return(1);
+ case (WARN_SYNTAX):
+ if (p->warn & MD_WARN_SYNTAX)
+ break;
+ return(1);
}
+ xfprintf(stderr, "%s:%d: warning: %s (column %d)\n",
+ p->name, line, msg, col);
- (void)fprintf(stderr, "%s:%d: warning: %s (column %d)\n",
- p->name, line, lit, col);
-
- if (p->warn & MD_WARN_ERR) {
- (void)fprintf(stderr, "%s: considering warnings as "
- "errors\n", __progname);
- return(0);
- }
+ if ( ! (p->warn & MD_WARN_ERR))
+ return(1);
- return(1);
+ xfprintf(stderr, "%s: considering warnings as errors\n",
+ __progname);
+ return(0);
}
static void
usage(void)
{
- extern char *__progname;
- (void)fprintf(stderr, "usage: %s [-v] [-Wwarn...] [infile]\n",
+ xfprintf(stderr, "usage: %s [-v] [-Wwarn...] [infile]\n",
__progname);
}
diff --git a/private.h b/private.h
index 9b716559..751c0617 100644
--- a/private.h
+++ b/private.h
@@ -45,31 +45,59 @@ struct mdoc {
int ppos, int *pos, char *buf
struct mdoc_macro {
- int (*fp)(MACRO_PROT_ARGS);
- int flags;
-#define MDOC_CALLABLE (1 << 0)
-#define MDOC_PARSED (1 << 1)
-#define MDOC_EXPLICIT (1 << 2)
-#define MDOC_QUOTABLE (1 << 3)
-#define MDOC_PROLOGUE (1 << 4)
-#define MDOC_TABSEP (1 << 5)
+ int (*fp)(MACRO_PROT_ARGS);
+ int flags;
+#define MDOC_CALLABLE (1 << 0)
+#define MDOC_PARSED (1 << 1)
+#define MDOC_EXPLICIT (1 << 2)
+#define MDOC_QUOTABLE (1 << 3)
+#define MDOC_PROLOGUE (1 << 4)
+#define MDOC_TABSEP (1 << 5)
};
+#define mdoc_nwarn(mdoc, node, type, fmt, ...) \
+ mdoc_vwarn((mdoc), (node)->line, \
+ (node)->pos, (type), (fmt), ##__VA_ARGS__)
+
+#define mdoc_nerr(mdoc, node, fmt, ...) \
+ mdoc_verr((mdoc), (node)->line, \
+ (node)->pos, (fmt), ##__VA_ARGS__)
+
+#define mdoc_warn(mdoc, type, fmt, ...) \
+ mdoc_vwarn((mdoc), (mdoc)->last->line, \
+ (mdoc)->last->pos, (type), (fmt), ##__VA_ARGS__)
+
+#define mdoc_err(mdoc, fmt, ...) \
+ mdoc_verr((mdoc), (mdoc)->last->line, \
+ (mdoc)->last->pos, (fmt), ##__VA_ARGS__)
+
+#define mdoc_msg(mdoc, fmt, ...) \
+ mdoc_vmsg((mdoc), (mdoc)->last->line, \
+ (mdoc)->last->pos, (fmt), ##__VA_ARGS__)
+
+#define mdoc_pmsg(mdoc, line, pos, fmt, ...) \
+ mdoc_vmsg((mdoc), (line), \
+ (pos), (fmt), ##__VA_ARGS__)
+
+#define mdoc_pwarn(mdoc, line, pos, type, fmt, ...) \
+ mdoc_vwarn((mdoc), (line), \
+ (pos), (type), (fmt), ##__VA_ARGS__)
+
+#define mdoc_perr(mdoc, line, pos, fmt, ...) \
+ mdoc_verr((mdoc), (line), \
+ (pos), (fmt), ##__VA_ARGS__)
+
extern const struct mdoc_macro *const mdoc_macros;
__BEGIN_DECLS
-#define mdoc_vwarn(m, n, t) \
- mdoc_pwarn((m), (n)->line, (n)->pos, (t))
-#define mdoc_verr(m, n, t) \
- mdoc_perr((m), (n)->line, (n)->pos, (t))
-#define mdoc_warn(m, t) \
- mdoc_pwarn((m), (m)->last->line, (m)->last->pos, (t))
-#define mdoc_err(m, t) \
- mdoc_perr((m), (m)->last->line, (m)->last->pos, (t))
-int mdoc_pwarn(struct mdoc *, int, int, enum mdoc_warn);
-int mdoc_perr(struct mdoc *, int, int, enum mdoc_err);
-void mdoc_msg(struct mdoc *, const char *, ...);
+int mdoc_vwarn(struct mdoc *, int, int,
+ enum mdoc_warn, const char *, ...);
+void mdoc_vmsg(struct mdoc *, int, int,
+ const char *, ...);
+int mdoc_verr(struct mdoc *, int, int,
+ const char *, ...);
+
int mdoc_macro(MACRO_PROT_ARGS);
int mdoc_find(const struct mdoc *, const char *);
int mdoc_word_alloc(struct mdoc *,
diff --git a/validate.c b/validate.c
index 179c119f..dbc59292 100644
--- a/validate.c
+++ b/validate.c
@@ -312,7 +312,7 @@ pre_display(struct mdoc *mdoc, struct mdoc_node *node)
break;
if (NULL == n)
return(1);
- return(mdoc_verr(mdoc, node, ERR_SCOPE_NONEST));
+ return(mdoc_nerr(mdoc, node, ERR_SCOPE_NONEST));
}
@@ -427,9 +427,9 @@ pre_it(struct mdoc *mdoc, struct mdoc_node *node)
assert(MDOC_It == mdoc->last->tok);
if (MDOC_BODY != mdoc->last->parent->type)
- return(mdoc_verr(mdoc, node, ERR_SYNTAX_PARENTBAD));
+ return(mdoc_nerr(mdoc, node, ERR_SYNTAX_PARENTBAD));
if (MDOC_Bl != mdoc->last->parent->tok)
- return(mdoc_verr(mdoc, node, ERR_SYNTAX_PARENTBAD));
+ return(mdoc_nerr(mdoc, node, ERR_SYNTAX_PARENTBAD));
return(1);
}
@@ -440,7 +440,7 @@ pre_prologue(struct mdoc *mdoc, struct mdoc_node *node)
{
if (SEC_PROLOGUE != mdoc->sec_lastn)
- return(mdoc_verr(mdoc, node, ERR_SEC_NPROLOGUE));
+ return(mdoc_nerr(mdoc, node, ERR_SEC_NPROLOGUE));
assert(MDOC_ELEM == node->type);
/* Check for ordering. */
@@ -449,15 +449,15 @@ pre_prologue(struct mdoc *mdoc, struct mdoc_node *node)
case (MDOC_Os):
if (mdoc->meta.title[0] && mdoc->meta.date)
break;
- return(mdoc_verr(mdoc, node, ERR_SEC_PROLOGUE_OO));
+ return(mdoc_nerr(mdoc, node, ERR_SEC_PROLOGUE_OO));
case (MDOC_Dt):
if (0 == mdoc->meta.title[0] && mdoc->meta.date)
break;
- return(mdoc_verr(mdoc, node, ERR_SEC_PROLOGUE_OO));
+ return(mdoc_nerr(mdoc, node, ERR_SEC_PROLOGUE_OO));
case (MDOC_Dd):
if (0 == mdoc->meta.title[0] && 0 == mdoc->meta.date)
break;
- return(mdoc_verr(mdoc, node, ERR_SEC_PROLOGUE_OO));
+ return(mdoc_nerr(mdoc, node, ERR_SEC_PROLOGUE_OO));
default:
abort();
/* NOTREACHED */
@@ -483,7 +483,7 @@ pre_prologue(struct mdoc *mdoc, struct mdoc_node *node)
/* NOTREACHED */
}
- return(mdoc_verr(mdoc, node, ERR_SEC_PROLOGUE_REP));
+ return(mdoc_nerr(mdoc, node, ERR_SEC_PROLOGUE_REP));
}
@@ -618,7 +618,7 @@ post_bl(struct mdoc *mdoc)
}
if (NULL == n)
return(1);
- return(mdoc_verr(mdoc, n, ERR_SYNTAX_CHILDBAD));
+ return(mdoc_nerr(mdoc, n, ERR_SYNTAX_CHILDBAD));
}