summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libman.h9
-rw-r--r--libmandoc.h16
-rw-r--r--libmdoc.h11
-rw-r--r--libroff.h8
-rw-r--r--main.c37
-rw-r--r--man.c27
-rw-r--r--man.h2
-rw-r--r--man_argv.c2
-rw-r--r--man_macro.c1
-rw-r--r--man_validate.c21
-rw-r--r--mandoc.c16
-rw-r--r--mandoc.h8
-rw-r--r--mdoc.c28
-rw-r--r--mdoc.h2
-rw-r--r--mdoc_macro.c15
-rw-r--r--mdoc_validate.c20
-rw-r--r--read.c87
-rw-r--r--roff.c58
-rw-r--r--roff.h2
-rw-r--r--tbl.c17
-rw-r--r--tbl_data.c11
-rw-r--r--tbl_layout.c28
-rw-r--r--tbl_opts.c24
23 files changed, 225 insertions, 225 deletions
diff --git a/libman.h b/libman.h
index 595d8187..d9318a59 100644
--- a/libman.h
+++ b/libman.h
@@ -25,8 +25,7 @@ enum man_next {
};
struct man {
- void *data; /* private application data */
- mandocmsg msg; /* output message handler */
+ struct mparse *parse; /* parse pointer */
int flags; /* parse flags */
#define MAN_HALT (1 << 0) /* badness happened: die */
#define MAN_ELINE (1 << 1) /* Next-line element scope. */
@@ -64,9 +63,9 @@ extern const struct man_macro *const man_macros;
__BEGIN_DECLS
#define man_pmsg(m, l, p, t) \
- (*(m)->msg)((t), (m)->data, (l), (p), NULL)
+ mandoc_msg((t), (m)->parse, (l), (p), NULL)
#define man_nmsg(m, n, t) \
- (*(m)->msg)((t), (m)->data, (n)->line, (n)->pos, NULL)
+ mandoc_msg((t), (m)->parse, (n)->line, (n)->pos, NULL)
int man_word_alloc(struct man *, int, int, const char *);
int man_block_alloc(struct man *, int, int, enum mant);
int man_head_alloc(struct man *, int, int, enum mant);
@@ -81,8 +80,6 @@ int man_args(struct man *, int, int *, char *, char **);
#define ARGS_EOLN (0)
#define ARGS_WORD (1)
#define ARGS_QWORD (1)
-void man_vmsg(struct man *, enum mandocerr,
- int, int, const char *, ...);
int man_valid_post(struct man *);
int man_valid_pre(struct man *, struct man_node *);
int man_unscope(struct man *,
diff --git a/libmandoc.h b/libmandoc.h
index f7a54f2b..2cdd1095 100644
--- a/libmandoc.h
+++ b/libmandoc.h
@@ -19,12 +19,16 @@
__BEGIN_DECLS
-int mandoc_special(char *);
-char *mandoc_strdup(const char *);
-char *mandoc_getarg(char **, mandocmsg, void *, int, int *);
-char *mandoc_normdate(char *, mandocmsg, void *, int, int);
-int mandoc_eos(const char *, size_t, int);
-int mandoc_hyph(const char *, const char *);
+void mandoc_msg(enum mandocerr, struct mparse *,
+ int, int, const char *);
+void mandoc_vmsg(enum mandocerr, struct mparse *,
+ int, int, const char *, ...);
+int mandoc_special(char *);
+char *mandoc_strdup(const char *);
+char *mandoc_getarg(struct mparse *, char **, int, int *);
+char *mandoc_normdate(struct mparse *, char *, int, int);
+int mandoc_eos(const char *, size_t, int);
+int mandoc_hyph(const char *, const char *);
__END_DECLS
diff --git a/libmdoc.h b/libmdoc.h
index 9a493730..d4ae2e2f 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -25,9 +25,8 @@ enum mdoc_next {
};
struct mdoc {
- void *data; /* private application data */
- mandocmsg msg; /* message callback */
- int flags;
+ struct mparse *parse; /* parse pointer */
+ int flags; /* parse flags */
#define MDOC_HALT (1 << 0) /* error in parse: halt */
#define MDOC_LITERAL (1 << 1) /* in a literal scope */
#define MDOC_PBODY (1 << 2) /* in the document body */
@@ -86,11 +85,9 @@ extern const struct mdoc_macro *const mdoc_macros;
__BEGIN_DECLS
#define mdoc_pmsg(m, l, p, t) \
- (*(m)->msg)((t), (m)->data, (l), (p), NULL)
+ mandoc_msg((t), (m)->parse, (l), (p), NULL)
#define mdoc_nmsg(m, n, t) \
- (*(m)->msg)((t), (m)->data, (n)->line, (n)->pos, NULL)
-void mdoc_vmsg(struct mdoc *, enum mandocerr,
- int, int, const char *, ...);
+ mandoc_msg((t), (m)->parse, (n)->line, (n)->pos, NULL)
int mdoc_macro(MACRO_PROT_ARGS);
int mdoc_word_alloc(struct mdoc *,
int, int, const char *);
diff --git a/libroff.h b/libroff.h
index 6d236dbe..d3af0fde 100644
--- a/libroff.h
+++ b/libroff.h
@@ -27,8 +27,7 @@ enum tbl_part {
};
struct tbl_node {
- mandocmsg msg; /* status messages */
- void *data; /* privdata for messages */
+ struct mparse *parse; /* parse point */
int pos; /* invocation column */
int line; /* invocation line */
enum tbl_part part;
@@ -48,10 +47,7 @@ struct eqn_node {
struct eqn_node *next;
};
-#define TBL_MSG(tblp, type, line, col) \
- (*(tblp)->msg)((type), (tblp)->data, (line), (col), NULL)
-
-struct tbl_node *tbl_alloc(int, int, void *, mandocmsg);
+struct tbl_node *tbl_alloc(int, int, struct mparse *);
void tbl_restart(int, int, struct tbl_node *);
void tbl_free(struct tbl_node *);
void tbl_reset(struct tbl_node *);
diff --git a/main.c b/main.c
index 4aac64e5..2099b110 100644
--- a/main.c
+++ b/main.c
@@ -75,16 +75,6 @@ static const char * const mandoclevels[MANDOCLEVEL_MAX] = {
"SYSERR"
};
-static const enum mandocerr mandoclimits[MANDOCLEVEL_MAX] = {
- MANDOCERR_OK,
- MANDOCERR_WARNING,
- MANDOCERR_WARNING,
- MANDOCERR_ERROR,
- MANDOCERR_FATAL,
- MANDOCERR_MAX,
- MANDOCERR_MAX
-};
-
static const char * const mandocerrs[MANDOCERR_MAX] = {
"ok",
@@ -195,8 +185,8 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
static void evt_close(void *, const char *);
static int evt_open(void *, const char *);
static int moptions(enum mparset *, char *);
-static void mmsg(enum mandocerr, void *,
- int, int, const char *);
+static void mmsg(enum mandocerr, enum mandoclevel,
+ const char *, int, int, const char *);
static void parse(struct curparse *, int,
const char *, enum mandoclevel *);
static int toptions(struct curparse *, char *);
@@ -253,7 +243,7 @@ main(int argc, char *argv[])
/* NOTREACHED */
}
- curp.mp = mparse_alloc(type, evt_open, evt_close, mmsg, &curp);
+ curp.mp = mparse_alloc(type, evt_open, evt_close, curp.wlevel, mmsg, &curp);
argc -= optind;
argv += optind;
@@ -501,27 +491,16 @@ woptions(struct curparse *curp, char *arg)
}
static void
-mmsg(enum mandocerr t, void *arg, int ln, int col, const char *msg)
+mmsg(enum mandocerr t, enum mandoclevel lvl,
+ const char *file, int line, int col, const char *msg)
{
- struct curparse *cp;
- enum mandoclevel level;
-
- level = MANDOCLEVEL_FATAL;
- while (t < mandoclimits[level])
- /* LINTED */
- level--;
- cp = (struct curparse *)arg;
- if (level < cp->wlevel)
- return;
-
- fprintf(stderr, "%s:%d:%d: %s: %s", cp->file, ln, col + 1,
- mandoclevels[level], mandocerrs[t]);
+ fprintf(stderr, "%s:%d:%d: %s: %s",
+ file, line, col + 1,
+ mandoclevels[lvl], mandocerrs[t]);
if (msg)
fprintf(stderr, ": %s", msg);
fputc('\n', stderr);
-
- mparse_setstatus(cp->mp, level);
}
diff --git a/man.c b/man.c
index c3ff9430..5b302bc1 100644
--- a/man.c
+++ b/man.c
@@ -95,15 +95,14 @@ man_free(struct man *man)
struct man *
-man_alloc(struct regset *regs, void *data, mandocmsg msg)
+man_alloc(struct regset *regs, struct mparse *parse)
{
struct man *p;
p = mandoc_calloc(1, sizeof(struct man));
man_hash_init();
- p->data = data;
- p->msg = msg;
+ p->parse = parse;
p->regs = regs;
man_alloc1(p);
@@ -521,7 +520,8 @@ man_pmacro(struct man *m, int ln, char *buf, int offs)
tok = (j > 0 && j < 4) ? man_hash_find(mac) : MAN_MAX;
if (MAN_MAX == tok) {
- man_vmsg(m, MANDOCERR_MACRO, ln, ppos, "%s", buf + ppos - 1);
+ mandoc_vmsg(MANDOCERR_MACRO, m->parse, ln,
+ ppos, "%s", buf + ppos - 1);
return(1);
}
@@ -554,8 +554,8 @@ man_pmacro(struct man *m, int ln, char *buf, int offs)
if (MAN_NSCOPED & man_macros[n->tok].flags)
n = n->parent;
- man_vmsg(m, MANDOCERR_LINESCOPE, n->line, n->pos,
- "%s", man_macronames[n->tok]);
+ mandoc_vmsg(MANDOCERR_LINESCOPE, m->parse, n->line,
+ n->pos, "%s", man_macronames[n->tok]);
man_node_delete(m, n);
m->flags &= ~MAN_ELINE;
@@ -621,21 +621,6 @@ err: /* Error out. */
return(0);
}
-
-void
-man_vmsg(struct man *man, enum mandocerr t,
- int ln, int pos, const char *fmt, ...)
-{
- char buf[256];
- va_list ap;
-
- va_start(ap, fmt);
- vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
- va_end(ap);
- (*man->msg)(t, man->data, ln, pos, buf);
-}
-
-
/*
* Unlink a node from its context. If "m" is provided, the last parse
* point will also be adjusted accordingly.
diff --git a/man.h b/man.h
index c92ef9f8..f9b19bd1 100644
--- a/man.h
+++ b/man.h
@@ -117,7 +117,7 @@ __BEGIN_DECLS
struct man;
void man_free(struct man *);
-struct man *man_alloc(struct regset *, void *, mandocmsg);
+struct man *man_alloc(struct regset *, struct mparse *);
void man_reset(struct man *);
int man_parseln(struct man *, int, char *, int);
int man_endparse(struct man *);
diff --git a/man_argv.c b/man_argv.c
index f091d0f2..6771e53c 100644
--- a/man_argv.c
+++ b/man_argv.c
@@ -39,6 +39,6 @@ man_args(struct man *m, int line, int *pos, char *buf, char **v)
if ('\0' == *start)
return(ARGS_EOLN);
- *v = mandoc_getarg(v, m->msg, m->data, line, pos);
+ *v = mandoc_getarg(m->parse, v, line, pos);
return('"' == *start ? ARGS_QWORD : ARGS_WORD);
}
diff --git a/man_macro.c b/man_macro.c
index 0c731e7f..c5149b81 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -24,6 +24,7 @@
#include <string.h>
#include "mandoc.h"
+#include "libmandoc.h"
#include "libman.h"
enum rew {
diff --git a/man_validate.c b/man_validate.c
index eba9cf6d..ed8d2475 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -196,8 +196,8 @@ check_root(CHKARGS)
m->meta.title = mandoc_strdup("unknown");
m->meta.msec = mandoc_strdup("1");
- m->meta.date = mandoc_normdate(NULL,
- m->msg, m->data, n->line, n->pos);
+ m->meta.date = mandoc_normdate
+ (m->parse, NULL, n->line, n->pos);
}
return(1);
@@ -247,7 +247,7 @@ check_##name(CHKARGS) \
{ \
if (n->nchild ineq (x)) \
return(1); \
- man_vmsg(m, MANDOCERR_ARGCOUNT, n->line, n->pos, \
+ mandoc_vmsg(MANDOCERR_ARGCOUNT, m->parse, n->line, n->pos, \
"line arguments %s %d (have %d)", \
#ineq, (x), n->nchild); \
return(1); \
@@ -299,14 +299,17 @@ check_ft(CHKARGS)
}
if (0 == ok) {
- man_vmsg(m, MANDOCERR_BADFONT,
- n->line, n->pos, "%s", cp);
+ mandoc_vmsg
+ (MANDOCERR_BADFONT, m->parse,
+ n->line, n->pos, "%s", cp);
*cp = '\0';
}
if (1 < n->nchild)
- man_vmsg(m, MANDOCERR_ARGCOUNT, n->line, n->pos,
- "want one child (have %d)", n->nchild);
+ mandoc_vmsg
+ (MANDOCERR_ARGCOUNT, m->parse, n->line,
+ n->pos, "want one child (have %d)",
+ n->nchild);
return(1);
}
@@ -426,8 +429,8 @@ post_TH(CHKARGS)
n = n->next;
if (n)
pos = n->pos;
- m->meta.date = mandoc_normdate(n ? n->string : NULL,
- m->msg, m->data, line, pos);
+ m->meta.date = mandoc_normdate
+ (m->parse, n ? n->string : NULL, line, pos);
/* TITLE MSEC DATE ->SOURCE<- VOL */
diff --git a/mandoc.c b/mandoc.c
index 2e3caf21..99c70393 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -296,7 +296,7 @@ mandoc_strdup(const char *ptr)
* or to the null byte terminating the argument line.
*/
char *
-mandoc_getarg(char **cpp, mandocmsg msg, void *data, int ln, int *pos)
+mandoc_getarg(struct mparse *parse, char **cpp, int ln, int *pos)
{
char *start, *cp;
int quoted, pairs, white;
@@ -343,8 +343,8 @@ mandoc_getarg(char **cpp, mandocmsg msg, void *data, int ln, int *pos)
}
/* Quoted argument without a closing quote. */
- if (1 == quoted && msg)
- (*msg)(MANDOCERR_BADQUOTE, data, ln, *pos, NULL);
+ if (1 == quoted)
+ mandoc_msg(MANDOCERR_BADQUOTE, parse, ln, *pos, NULL);
/* Null-terminate this argument and move to the next one. */
if (pairs)
@@ -357,8 +357,8 @@ mandoc_getarg(char **cpp, mandocmsg msg, void *data, int ln, int *pos)
*pos += (int)(cp - start) + (quoted ? 1 : 0);
*cpp = cp;
- if ('\0' == *cp && msg && (white || ' ' == cp[-1]))
- (*msg)(MANDOCERR_EOLNSPACE, data, ln, *pos, NULL);
+ if ('\0' == *cp && (white || ' ' == cp[-1]))
+ mandoc_msg(MANDOCERR_EOLNSPACE, parse, ln, *pos, NULL);
return(start);
}
@@ -416,20 +416,20 @@ fail:
}
char *
-mandoc_normdate(char *in, mandocmsg msg, void *data, int ln, int pos)
+mandoc_normdate(struct mparse *parse, char *in, int ln, int pos)
{
char *out;
time_t t;
if (NULL == in || '\0' == *in ||
0 == strcmp(in, "$" "Mdocdate$")) {
- (*msg)(MANDOCERR_NODATE, data, ln, pos, NULL);
+ mandoc_msg(MANDOCERR_NODATE, parse, ln, pos, NULL);
time(&t);
}
else if (!a2time(&t, "$" "Mdocdate: %b %d %Y $", in) &&
!a2time(&t, "%b %d, %Y", in) &&
!a2time(&t, "%Y-%m-%d", in)) {
- (*msg)(MANDOCERR_BADDATE, data, ln, pos, NULL);
+ mandoc_msg(MANDOCERR_BADDATE, parse, ln, pos, NULL);
t = 0;
}
out = t ? time2a(t) : NULL;
diff --git a/mandoc.h b/mandoc.h
index ee835a84..9ebc0c8d 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -339,8 +339,8 @@ enum mparset {
MPARSE_MAN /* assume -man */
};
-typedef void (*mandocmsg)(enum mandocerr, void *,
- int, int, const char *);
+typedef void (*mandocmsg)(enum mandocerr, enum mandoclevel,
+ const char *, int, int, const char *);
typedef int (*mevt_open)(void *, const char *);
typedef void (*mevt_close)(void *, const char *);
@@ -353,8 +353,8 @@ __BEGIN_DECLS
void mparse_free(struct mparse *);
void mparse_reset(struct mparse *);
struct mparse *mparse_alloc(enum mparset, mevt_open,
- mevt_close, mandocmsg, void *);
-void mparse_setstatus(struct mparse *, enum mandoclevel);
+ mevt_close,
+ enum mandoclevel, mandocmsg, void *);
enum mandoclevel mparse_readfd(struct mparse *, int, const char *);
void mparse_result(struct mparse *, struct mdoc **, struct man **);
diff --git a/mdoc.c b/mdoc.c
index 348e58cd..736275fe 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -192,14 +192,13 @@ mdoc_free(struct mdoc *mdoc)
* Allocate volatile and non-volatile parse resources.
*/
struct mdoc *
-mdoc_alloc(struct regset *regs, void *data, mandocmsg msg)
+mdoc_alloc(struct regset *regs, struct mparse *parse)
{
struct mdoc *p;
p = mandoc_calloc(1, sizeof(struct mdoc));
- p->msg = msg;
- p->data = data;
+ p->parse = parse;
p->regs = regs;
mdoc_hash_init();
@@ -302,22 +301,6 @@ mdoc_parseln(struct mdoc *m, int ln, char *buf, int offs)
mdoc_ptext(m, ln, buf, offs));
}
-
-void
-mdoc_vmsg(struct mdoc *mdoc, enum mandocerr t,
- int ln, int pos, const char *fmt, ...)
-{
- char buf[256];
- va_list ap;
-
- va_start(ap, fmt);
- vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
- va_end(ap);
-
- (*mdoc->msg)(t, mdoc->data, ln, pos, buf);
-}
-
-
int
mdoc_macro(MACRO_PROT_ARGS)
{
@@ -345,8 +328,8 @@ mdoc_macro(MACRO_PROT_ARGS)
if (NULL == m->meta.os)
m->meta.os = mandoc_strdup("LOCAL");
if (NULL == m->meta.date)
- m->meta.date = mandoc_normdate(NULL,
- m->msg, m->data, line, ppos);
+ m->meta.date = mandoc_normdate
+ (m->parse, NULL, line, ppos);
m->flags |= MDOC_PBODY;
}
@@ -849,7 +832,8 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs)
tok = (j > 1 || j < 4) ? mdoc_hash_find(mac) : MDOC_MAX;
if (MDOC_MAX == tok) {
- mdoc_vmsg(m, MANDOCERR_MACRO, ln, sv, "%s", buf + sv - 1);
+ mandoc_vmsg(MANDOCERR_MACRO, m->parse,
+ ln, sv, "%s", buf + sv - 1);
return(1);
}
diff --git a/mdoc.h b/mdoc.h
index 26dcd4da..349f65a0 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -424,7 +424,7 @@ __BEGIN_DECLS
struct mdoc;
void mdoc_free(struct mdoc *);
-struct mdoc *mdoc_alloc(struct regset *, void *, mandocmsg);
+struct mdoc *mdoc_alloc(struct regset *, struct mparse *);
void mdoc_reset(struct mdoc *);
int mdoc_parseln(struct mdoc *, int, char *, int);
const struct mdoc_node *mdoc_node(const struct mdoc *);
diff --git a/mdoc_macro.c b/mdoc_macro.c
index d1354c6e..aee2cad3 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -513,9 +513,9 @@ make_pending(struct mdoc_node *broken, enum mdoct tok,
taker->pending = broken->pending;
}
broken->pending = breaker;
- mdoc_vmsg(m, MANDOCERR_SCOPENEST, line, ppos,
- "%s breaks %s", mdoc_macronames[tok],
- mdoc_macronames[broken->tok]);
+ mandoc_vmsg(MANDOCERR_SCOPENEST, m->parse, line, ppos,
+ "%s breaks %s", mdoc_macronames[tok],
+ mdoc_macronames[broken->tok]);
return(1);
}
@@ -541,9 +541,10 @@ rew_sub(enum mdoc_type t, struct mdoc *m,
case (REWIND_THIS):
break;
case (REWIND_FORCE):
- mdoc_vmsg(m, MANDOCERR_SCOPEBROKEN, line, ppos,
- "%s breaks %s", mdoc_macronames[tok],
- mdoc_macronames[n->tok]);
+ mandoc_vmsg(MANDOCERR_SCOPEBROKEN, m->parse,
+ line, ppos, "%s breaks %s",
+ mdoc_macronames[tok],
+ mdoc_macronames[n->tok]);
/* FALLTHROUGH */
case (REWIND_MORE):
n = n->parent;
@@ -1298,7 +1299,7 @@ blk_part_imp(MACRO_PROT_ARGS)
* crufty use of `Op' breakage.
*/
if (n != body)
- mdoc_vmsg(m, MANDOCERR_SCOPENEST, line, ppos,
+ mandoc_vmsg(MANDOCERR_SCOPENEST, m->parse, line, ppos,
"%s broken", mdoc_macronames[tok]);
if (n && ! rew_sub(MDOC_BODY, m, tok, line, ppos))
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 9bbb0b9a..0ccc3758 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -446,7 +446,7 @@ check_count(struct mdoc *m, enum mdoc_type type,
}
t = lvl == CHECK_WARN ? MANDOCERR_ARGCWARN : MANDOCERR_ARGCOUNT;
- mdoc_vmsg(m, t, m->last->line, m->last->pos,
+ mandoc_vmsg(t, m->parse, m->last->line, m->last->pos,
"want %s%d children (have %d)",
p, val, m->last->nchild);
return(1);
@@ -581,10 +581,9 @@ check_parent(PRE_ARGS, enum mdoct tok, enum mdoc_type t)
(t == n->parent->type))
return(1);
- mdoc_vmsg(mdoc, MANDOCERR_SYNTCHILD,
- n->line, n->pos, "want parent %s",
- MDOC_ROOT == t ? "<root>" :
- mdoc_macronames[tok]);
+ mandoc_vmsg(MANDOCERR_SYNTCHILD, mdoc->parse, n->line,
+ n->pos, "want parent %s", MDOC_ROOT == t ?
+ "<root>" : mdoc_macronames[tok]);
return(0);
}
@@ -1332,7 +1331,8 @@ post_it(POST_ARGS)
else
er = MANDOCERR_SYNTARGCOUNT;
- mdoc_vmsg(mdoc, er, mdoc->last->line, mdoc->last->pos,
+ mandoc_vmsg(er, mdoc->parse, mdoc->last->line,
+ mdoc->last->pos,
"columns == %d (have %d)", cols, i);
return(MANDOCERR_ARGCOUNT == er);
default:
@@ -2001,16 +2001,16 @@ post_dd(POST_ARGS)
n = mdoc->last;
if (NULL == n->child || '\0' == n->child->string[0]) {
- mdoc->meta.date = mandoc_normdate(NULL,
- mdoc->msg, mdoc->data, n->line, n->pos);
+ mdoc->meta.date = mandoc_normdate
+ (mdoc->parse, NULL, n->line, n->pos);
return(1);
}
if ( ! concat(mdoc, buf, n->child, DATESIZE))
return(0);
- mdoc->meta.date = mandoc_normdate(buf,
- mdoc->msg, mdoc->data, n->line, n->pos);
+ mdoc->meta.date = mandoc_normdate
+ (mdoc->parse, buf, n->line, n->pos);
return(1);
}
diff --git a/read.c b/read.c
index b150b868..8f401733 100644
--- a/read.c
+++ b/read.c
@@ -21,12 +21,14 @@
#include <assert.h>
#include <ctype.h>
#include <fcntl.h>
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "mandoc.h"
+#include "libmandoc.h"
#include "mdoc.h"
#include "man.h"
#include "roff.h"
@@ -44,6 +46,7 @@ struct buf {
struct mparse {
enum mandoclevel file_status; /* status of current parse */
+ enum mandoclevel wlevel; /* ignore messages below this */
int line; /* line number in the file */
enum mparset inttype; /* which parser to use */
struct man *pman; /* persistent man parser */
@@ -57,7 +60,7 @@ struct mparse {
void *arg; /* argument to mmsg */
mevt_open evt_open; /* file-open event */
mevt_close evt_close; /* file-close event */
- const char *svfile;
+ const char *file;
};
static void resize_buf(struct buf *, size_t);
@@ -68,6 +71,16 @@ static void pdesc(struct mparse *, const char *, int);
static int read_whole_file(const char *, int, struct buf *, int *);
static void mparse_end(struct mparse *);
+static const enum mandocerr mandoclimits[MANDOCLEVEL_MAX] = {
+ MANDOCERR_OK,
+ MANDOCERR_WARNING,
+ MANDOCERR_WARNING,
+ MANDOCERR_ERROR,
+ MANDOCERR_FATAL,
+ MANDOCERR_MAX,
+ MANDOCERR_MAX
+};
+
static void
resize_buf(struct buf *buf, size_t initial)
{
@@ -103,15 +116,13 @@ pset(const char *buf, int pos, struct mparse *curp)
switch (curp->inttype) {
case (MPARSE_MDOC):
if (NULL == curp->pmdoc)
- curp->pmdoc = mdoc_alloc
- (&curp->regs, curp->arg, curp->mmsg);
+ curp->pmdoc = mdoc_alloc(&curp->regs, curp);
assert(curp->pmdoc);
curp->mdoc = curp->pmdoc;
return;
case (MPARSE_MAN):
if (NULL == curp->pman)
- curp->pman = man_alloc
- (&curp->regs, curp->arg, curp->mmsg);
+ curp->pman = man_alloc(&curp->regs, curp);
assert(curp->pman);
curp->man = curp->pman;
return;
@@ -121,16 +132,14 @@ pset(const char *buf, int pos, struct mparse *curp)
if (pos >= 3 && 0 == memcmp(buf, ".Dd", 3)) {
if (NULL == curp->pmdoc)
- curp->pmdoc = mdoc_alloc
- (&curp->regs, curp->arg, curp->mmsg);
+ curp->pmdoc = mdoc_alloc(&curp->regs, curp);
assert(curp->pmdoc);
curp->mdoc = curp->pmdoc;
return;
}
if (NULL == curp->pman)
- curp->pman = man_alloc
- (&curp->regs, curp->arg, curp->mmsg);
+ curp->pman = man_alloc(&curp->regs, curp);
assert(curp->pman);
curp->man = curp->pman;
}
@@ -195,7 +204,7 @@ mparse_buf_r(struct mparse *curp, struct buf blk, int start)
if ( ! (isascii(c) &&
(isgraph(c) || isblank(c)))) {
- curp->mmsg(MANDOCERR_BADCHAR, curp->arg,
+ mandoc_msg(MANDOCERR_BADCHAR, curp,
curp->line, pos, "ignoring byte");
i++;
continue;
@@ -282,7 +291,7 @@ rerun:
if (REPARSE_LIMIT >= ++curp->reparse_count)
mparse_buf_r(curp, ln, 0);
else
- curp->mmsg(MANDOCERR_ROFFLOOP, curp->arg,
+ mandoc_msg(MANDOCERR_ROFFLOOP, curp,
curp->line, pos, NULL);
pos = 0;
continue;
@@ -491,7 +500,7 @@ mparse_end(struct mparse *curp)
}
#if 0
- /* NOTE a parser may not have been assigned, yet. */
+ /* FIXME: NOTE a parser may not have been assigned, yet. */
if ( ! (curp->man || curp->mdoc)) {
/* FIXME: make into an mandoc.h error. */
@@ -521,8 +530,8 @@ mparse_readfd_r(struct mparse *curp, int fd, const char *file, int re)
return;
}
- svfile = curp->svfile;
- curp->svfile = file;
+ svfile = curp->file;
+ curp->file = file;
pdesc(curp, file, fd);
@@ -532,8 +541,8 @@ mparse_readfd_r(struct mparse *curp, int fd, const char *file, int re)
if (STDIN_FILENO != fd && -1 == close(fd))
perror(file);
- (*curp->evt_close)(curp->arg, svfile);
- curp->svfile = svfile;
+ (*curp->evt_close)(curp->arg, file);
+ curp->file = svfile;
}
enum mandoclevel
@@ -544,29 +553,22 @@ mparse_readfd(struct mparse *curp, int fd, const char *file)
return(curp->file_status);
}
-void
-mparse_setstatus(struct mparse *curp, enum mandoclevel lvl)
-{
-
- if (curp->file_status < lvl)
- curp->file_status = lvl;
-}
-
struct mparse *
mparse_alloc(enum mparset inttype, mevt_open eopen,
- mevt_close eclose, mandocmsg mmsg, void *arg)
+ mevt_close eclose, enum mandoclevel wlevel, mandocmsg mmsg, void *arg)
{
struct mparse *curp;
curp = mandoc_calloc(1, sizeof(struct mparse));
+ curp->wlevel = wlevel;
curp->mmsg = mmsg;
curp->arg = arg;
curp->inttype = inttype;
curp->evt_open = eopen;
curp->evt_close = eclose;
- curp->roff = roff_alloc(&curp->regs, arg, mmsg);
+ curp->roff = roff_alloc(&curp->regs, curp);
return(curp);
}
@@ -609,3 +611,36 @@ mparse_result(struct mparse *curp, struct mdoc **mdoc, struct man **man)
*mdoc = curp->mdoc;
*man = curp->man;
}
+
+void
+mandoc_vmsg(enum mandocerr t, struct mparse *m,
+ int ln, int pos, const char *fmt, ...)
+{
+ char buf[256];
+ va_list ap;
+
+ va_start(ap, fmt);
+ vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
+ va_end(ap);
+
+ mandoc_msg(t, m, ln, pos, buf);
+}
+
+void
+mandoc_msg(enum mandocerr er, struct mparse *m,
+ int ln, int col, const char *msg)
+{
+ enum mandoclevel level;
+
+ level = MANDOCLEVEL_FATAL;
+ while (er < mandoclimits[level])
+ level--;
+
+ if (level < m->wlevel)
+ return;
+
+ (*m->mmsg)(er, level, m->file, ln, col, msg);
+
+ if (m->file_status < level)
+ m->file_status = level;
+}
diff --git a/roff.c b/roff.c
index 7290e4df..4b862e9b 100644
--- a/roff.c
+++ b/roff.c
@@ -84,9 +84,8 @@ struct roffstr {
};
struct roff {
+ struct mparse *parse; /* parse point */
struct roffnode *last; /* leaf of stack */
- mandocmsg msg; /* err/warn/fatal messages */
- void *data; /* privdata for messages */
enum roffrule rstack[RSTACK_MAX]; /* stack of !`ie' rules */
int rstackpos; /* position in rstack */
struct regset *regs; /* read/writable registers */
@@ -361,14 +360,13 @@ roff_free(struct roff *r)
struct roff *
-roff_alloc(struct regset *regs, void *data, const mandocmsg msg)
+roff_alloc(struct regset *regs, struct mparse *parse)
{
struct roff *r;
r = mandoc_calloc(1, sizeof(struct roff));
r->regs = regs;
- r->msg = msg;
- r->data = data;
+ r->parse = parse;
r->rstackpos = -1;
roff_hash_init();
@@ -555,18 +553,18 @@ roff_endparse(struct roff *r)
{
if (r->last)
- (*r->msg)(MANDOCERR_SCOPEEXIT, r->data,
+ mandoc_msg(MANDOCERR_SCOPEEXIT, r->parse,
r->last->line, r->last->col, NULL);
if (r->eqn) {
- (*r->msg)(MANDOCERR_SCOPEEXIT, r->data,
+ mandoc_msg(MANDOCERR_SCOPEEXIT, r->parse,
r->eqn->eqn.line, r->eqn->eqn.pos, NULL);
eqn_end(r->eqn);
r->eqn = NULL;
}
if (r->tbl) {
- (*r->msg)(MANDOCERR_SCOPEEXIT, r->data,
+ mandoc_msg(MANDOCERR_SCOPEEXIT, r->parse,
r->tbl->line, r->tbl->pos, NULL);
tbl_end(r->tbl);
r->tbl = NULL;
@@ -639,7 +637,7 @@ roff_cblock(ROFF_ARGS)
*/
if (NULL == r->last) {
- (*r->msg)(MANDOCERR_NOSCOPE, r->data, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
return(ROFF_IGN);
}
@@ -658,12 +656,12 @@ roff_cblock(ROFF_ARGS)
case (ROFF_ig):
break;
default:
- (*r->msg)(MANDOCERR_NOSCOPE, r->data, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
return(ROFF_IGN);
}
if ((*bufp)[pos])
- (*r->msg)(MANDOCERR_ARGSLOST, r->data, ln, pos, NULL);
+ mandoc_msg(MANDOCERR_ARGSLOST, r->parse, ln, pos, NULL);
roffnode_pop(r);
roffnode_cleanscope(r);
@@ -690,7 +688,7 @@ roff_ccond(ROFF_ARGS)
{
if (NULL == r->last) {
- (*r->msg)(MANDOCERR_NOSCOPE, r->data, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
return(ROFF_IGN);
}
@@ -702,17 +700,17 @@ roff_ccond(ROFF_ARGS)
case (ROFF_if):
break;
default:
- (*r->msg)(MANDOCERR_NOSCOPE, r->data, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
return(ROFF_IGN);
}
if (r->last->endspan > -1) {
- (*r->msg)(MANDOCERR_NOSCOPE, r->data, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
return(ROFF_IGN);
}
if ((*bufp)[pos])
- (*r->msg)(MANDOCERR_ARGSLOST, r->data, ln, pos, NULL);
+ mandoc_msg(MANDOCERR_ARGSLOST, r->parse, ln, pos, NULL);
roffnode_pop(r);
roffnode_cleanscope(r);
@@ -732,7 +730,7 @@ roff_block(ROFF_ARGS)
if (ROFF_ig != tok) {
if ('\0' == (*bufp)[pos]) {
- (*r->msg)(MANDOCERR_NOARGS, r->data, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_NOARGS, r->parse, ln, ppos, NULL);
return(ROFF_IGN);
}
@@ -746,7 +744,7 @@ roff_block(ROFF_ARGS)
if (ROFF_de == tok)
name = *bufp + pos;
else
- (*r->msg)(MANDOCERR_REQUEST, r->data, ln, ppos,
+ mandoc_msg(MANDOCERR_REQUEST, r->parse, ln, ppos,
roffs[tok].name);
while ((*bufp)[pos] && ' ' != (*bufp)[pos])
@@ -796,7 +794,7 @@ roff_block(ROFF_ARGS)
r->last->end[(int)sz] = '\0';
if ((*bufp)[pos])
- (*r->msg)(MANDOCERR_ARGSLOST, r->data, ln, pos, NULL);
+ mandoc_msg(MANDOCERR_ARGSLOST, r->parse, ln, pos, NULL);
return(ROFF_IGN);
}
@@ -977,7 +975,7 @@ roff_line_ignore(ROFF_ARGS)
{
if (ROFF_it == tok)
- (*r->msg)(MANDOCERR_REQUEST, r->data, ln, ppos, "it");
+ mandoc_msg(MANDOCERR_REQUEST, r->parse, ln, ppos, "it");
return(ROFF_IGN);
}
@@ -992,7 +990,7 @@ roff_cond(ROFF_ARGS)
/* Stack overflow! */
if (ROFF_ie == tok && r->rstackpos == RSTACK_MAX - 1) {
- (*r->msg)(MANDOCERR_MEM, r->data, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_MEM, r->parse, ln, ppos, NULL);
return(ROFF_ERR);
}
@@ -1023,7 +1021,7 @@ roff_cond(ROFF_ARGS)
*/
if ('\0' == (*bufp)[pos] && sv != pos) {
- (*r->msg)(MANDOCERR_NOARGS, r->data, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_NOARGS, r->parse, ln, ppos, NULL);
return(ROFF_IGN);
}
@@ -1150,7 +1148,7 @@ roff_TE(ROFF_ARGS)
{
if (NULL == r->tbl)
- (*r->msg)(MANDOCERR_NOSCOPE, r->data, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
else
tbl_end(r->tbl);
@@ -1164,7 +1162,7 @@ roff_T_(ROFF_ARGS)
{
if (NULL == r->tbl)
- (*r->msg)(MANDOCERR_NOSCOPE, r->data, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
else
tbl_restart(ppos, ln, r->tbl);
@@ -1194,7 +1192,7 @@ static enum rofferr
roff_EN(ROFF_ARGS)
{
- (*r->msg)(MANDOCERR_NOSCOPE, r->data, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
return(ROFF_IGN);
}
@@ -1205,11 +1203,11 @@ roff_TS(ROFF_ARGS)
struct tbl_node *t;
if (r->tbl) {
- (*r->msg)(MANDOCERR_SCOPEBROKEN, r->data, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_SCOPEBROKEN, r->parse, ln, ppos, NULL);
tbl_end(r->tbl);
}
- t = tbl_alloc(ppos, ln, r->data, r->msg);
+ t = tbl_alloc(ppos, ln, r->parse);
if (r->last_tbl)
r->last_tbl->next = t;
@@ -1226,7 +1224,7 @@ roff_so(ROFF_ARGS)
{
char *name;
- (*r->msg)(MANDOCERR_SO, r->data, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_SO, r->parse, ln, ppos, NULL);
/*
* Handle `so'. Be EXTREMELY careful, as we shouldn't be
@@ -1237,7 +1235,7 @@ roff_so(ROFF_ARGS)
name = *bufp + pos;
if ('/' == *name || strstr(name, "../") || strstr(name, "/..")) {
- (*r->msg)(MANDOCERR_SOPATH, r->data, ln, pos, NULL);
+ mandoc_msg(MANDOCERR_SOPATH, r->parse, ln, pos, NULL);
return(ROFF_ERR);
}
@@ -1260,7 +1258,7 @@ roff_userdef(ROFF_ARGS)
cp = *bufp + pos;
for (i = 0; i < 9; i++)
arg[i] = '\0' == *cp ? "" :
- mandoc_getarg(&cp, r->msg, r->data, ln, &pos);
+ mandoc_getarg(r->parse, &cp, ln, &pos);
/*
* Expand macro arguments.
@@ -1316,7 +1314,7 @@ roff_getname(struct roff *r, char **cpp, int ln, int pos)
cp++;
if ('\\' == *cp)
continue;
- (*r->msg)(MANDOCERR_NAMESC, r->data, ln, pos, NULL);
+ mandoc_msg(MANDOCERR_NAMESC, r->parse, ln, pos, NULL);
*cp = '\0';
name = cp;
}
diff --git a/roff.h b/roff.h
index 089d6603..95d6d108 100644
--- a/roff.h
+++ b/roff.h
@@ -34,7 +34,7 @@ __BEGIN_DECLS
struct roff;
void roff_free(struct roff *);
-struct roff *roff_alloc(struct regset *, void *, mandocmsg);
+struct roff *roff_alloc(struct regset *, struct mparse *);
void roff_reset(struct roff *);
enum rofferr roff_parseln(struct roff *, int,
char **, size_t *, int, int *);
diff --git a/tbl.c b/tbl.c
index 98bde3dd..7bc66cf1 100644
--- a/tbl.c
+++ b/tbl.c
@@ -67,15 +67,14 @@ tbl_read(struct tbl_node *tbl, int ln, const char *p, int offs)
}
struct tbl_node *
-tbl_alloc(int pos, int line, void *data, const mandocmsg msg)
+tbl_alloc(int pos, int line, struct mparse *parse)
{
struct tbl_node *p;
p = mandoc_calloc(1, sizeof(struct tbl_node));
p->line = line;
p->pos = pos;
- p->data = data;
- p->msg = msg;
+ p->parse = parse;
p->part = TBL_PART_OPTS;
p->opts.tab = '\t';
p->opts.linesize = 12;
@@ -126,14 +125,16 @@ void
tbl_restart(int line, int pos, struct tbl_node *tbl)
{
if (TBL_PART_CDATA == tbl->part)
- TBL_MSG(tbl, MANDOCERR_TBLBLOCK, tbl->line, tbl->pos);
+ mandoc_msg(MANDOCERR_TBLBLOCK, tbl->parse,
+ tbl->line, tbl->pos, NULL);
tbl->part = TBL_PART_LAYOUT;
tbl->line = line;
tbl->pos = pos;
if (NULL == tbl->first_span || NULL == tbl->first_span->first)
- TBL_MSG(tbl, MANDOCERR_TBLNODATA, tbl->line, tbl->pos);
+ mandoc_msg(MANDOCERR_TBLNODATA, tbl->parse,
+ tbl->line, tbl->pos, NULL);
}
const struct tbl_span *
@@ -154,12 +155,14 @@ tbl_end(struct tbl_node *tbl)
{
if (NULL == tbl->first_span || NULL == tbl->first_span->first)
- TBL_MSG(tbl, MANDOCERR_TBLNODATA, tbl->line, tbl->pos);
+ mandoc_msg(MANDOCERR_TBLNODATA, tbl->parse,
+ tbl->line, tbl->pos, NULL);
if (tbl->last_span)
tbl->last_span->flags |= TBL_SPAN_LAST;
if (TBL_PART_CDATA == tbl->part)
- TBL_MSG(tbl, MANDOCERR_TBLBLOCK, tbl->line, tbl->pos);
+ mandoc_msg(MANDOCERR_TBLBLOCK, tbl->parse,
+ tbl->line, tbl->pos, NULL);
}
diff --git a/tbl_data.c b/tbl_data.c
index 6d86e4c0..00ab56a3 100644
--- a/tbl_data.c
+++ b/tbl_data.c
@@ -64,7 +64,8 @@ data(struct tbl_node *tbl, struct tbl_span *dp,
*/
if (NULL == cp) {
- TBL_MSG(tbl, MANDOCERR_TBLEXTRADAT, ln, *pos);
+ mandoc_msg(MANDOCERR_TBLEXTRADAT,
+ tbl->parse, ln, *pos, NULL);
/* Skip to the end... */
while (p[*pos])
(*pos)++;
@@ -130,7 +131,8 @@ data(struct tbl_node *tbl, struct tbl_span *dp,
TBL_CELL_DHORIZ == dat->layout->pos ||
TBL_CELL_DOWN == dat->layout->pos)
if (TBL_DATA_DATA == dat->pos && '\0' != *dat->string)
- TBL_MSG(tbl, MANDOCERR_TBLIGNDATA, ln, sv);
+ mandoc_msg(MANDOCERR_TBLIGNDATA,
+ tbl->parse, ln, sv, NULL);
return(1);
}
@@ -172,7 +174,8 @@ tbl_cdata(struct tbl_node *tbl, int ln, const char *p)
dat->string = mandoc_strdup(p);
if (TBL_CELL_DOWN == dat->layout->pos)
- TBL_MSG(tbl, MANDOCERR_TBLIGNDATA, ln, pos);
+ mandoc_msg(MANDOCERR_TBLIGNDATA,
+ tbl->parse, ln, pos, NULL);
return(0);
}
@@ -210,7 +213,7 @@ tbl_data(struct tbl_node *tbl, int ln, const char *p)
pos = 0;
if ('\0' == p[pos]) {
- TBL_MSG(tbl, MANDOCERR_TBL, ln, pos);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse, ln, pos, NULL);
return(0);
}
diff --git a/tbl_layout.c b/tbl_layout.c
index 7063aaff..c8722ae6 100644
--- a/tbl_layout.c
+++ b/tbl_layout.c
@@ -100,7 +100,8 @@ mod:
(*pos)++;
goto mod;
}
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos);
+ mandoc_msg(MANDOCERR_TBLLAYOUT,
+ tbl->parse, ln, *pos, NULL);
return(0);
}
@@ -117,7 +118,8 @@ mod:
/* No greater than 4 digits. */
if (4 == i) {
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos);
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
+ ln, *pos, NULL);
return(0);
}
@@ -156,7 +158,8 @@ mod:
(*pos)--;
break;
default:
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
+ ln, *pos - 1, NULL);
return(0);
}
@@ -171,7 +174,8 @@ mod:
break;
}
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
+ ln, *pos - 1, NULL);
return(0);
}
@@ -189,7 +193,8 @@ cell(struct tbl_node *tbl, struct tbl_row *rp,
break;
if (KEYS_MAX == i) {
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos);
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
+ ln, *pos, NULL);
return(0);
}
@@ -205,7 +210,8 @@ cell(struct tbl_node *tbl, struct tbl_row *rp,
if (TBL_CELL_SPAN == c) {
if (NULL == rp->first) {
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos);
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
+ ln, *pos, NULL);
return(0);
} else if (rp->last)
switch (rp->last->pos) {
@@ -213,7 +219,8 @@ cell(struct tbl_node *tbl, struct tbl_row *rp,
case (TBL_CELL_DVERT):
case (TBL_CELL_HORIZ):
case (TBL_CELL_DHORIZ):
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos);
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
+ ln, *pos, NULL);
return(0);
default:
break;
@@ -226,7 +233,7 @@ cell(struct tbl_node *tbl, struct tbl_row *rp,
*/
if (TBL_CELL_DOWN == c && rp == tbl->first_row) {
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos);
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, ln, *pos, NULL);
return(0);
}
@@ -244,7 +251,7 @@ cell(struct tbl_node *tbl, struct tbl_row *rp,
if (rp->last && (TBL_CELL_VERT == c || TBL_CELL_DVERT == c) &&
(TBL_CELL_VERT == rp->last->pos ||
TBL_CELL_DVERT == rp->last->pos)) {
- TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, ln, *pos - 1, NULL);
return(0);
}
@@ -285,7 +292,8 @@ cell:
if ('.' == p[*pos]) {
tbl->part = TBL_PART_DATA;
if (NULL == tbl->first_row)
- TBL_MSG(tbl, MANDOCERR_TBLNOLAYOUT, ln, *pos);
+ mandoc_msg(MANDOCERR_TBLNOLAYOUT, tbl->parse,
+ ln, *pos, NULL);
(*pos)++;
return;
}
diff --git a/tbl_opts.c b/tbl_opts.c
index c8c2f71e..3e3d7673 100644
--- a/tbl_opts.c
+++ b/tbl_opts.c
@@ -20,6 +20,7 @@
#include <string.h>
#include "mandoc.h"
+#include "libmandoc.h"
#include "libroff.h"
enum tbl_ident {
@@ -88,7 +89,8 @@ arg(struct tbl_node *tbl, int ln, const char *p, int *pos, enum tbl_ident key)
/* Arguments always begin with a parenthesis. */
if ('(' != p[*pos]) {
- TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse,
+ ln, *pos, NULL);
return(0);
}
@@ -103,12 +105,14 @@ arg(struct tbl_node *tbl, int ln, const char *p, int *pos, enum tbl_ident key)
switch (key) {
case (KEY_DELIM):
if ('\0' == p[(*pos)++]) {
- TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse,
+ ln, *pos - 1, NULL);
return(0);
}
if ('\0' == p[(*pos)++]) {
- TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse,
+ ln, *pos - 1, NULL);
return(0);
}
break;
@@ -116,7 +120,8 @@ arg(struct tbl_node *tbl, int ln, const char *p, int *pos, enum tbl_ident key)
if ('\0' != (tbl->opts.tab = p[(*pos)++]))
break;
- TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse,
+ ln, *pos - 1, NULL);
return(0);
case (KEY_LINESIZE):
for (i = 0; i < KEY_MAXNUMSZ && p[*pos]; i++, (*pos)++) {
@@ -131,13 +136,14 @@ arg(struct tbl_node *tbl, int ln, const char *p, int *pos, enum tbl_ident key)
break;
}
- (*tbl->msg)(MANDOCERR_TBL, tbl->data, ln, *pos, NULL);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse, ln, *pos, NULL);
return(0);
case (KEY_DPOINT):
if ('\0' != (tbl->opts.decimal = p[(*pos)++]))
break;
- TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse,
+ ln, *pos - 1, NULL);
return(0);
default:
abort();
@@ -149,7 +155,7 @@ arg(struct tbl_node *tbl, int ln, const char *p, int *pos, enum tbl_ident key)
if (')' == p[(*pos)++])
return(1);
- TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos - 1);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse, ln, *pos - 1, NULL);
return(0);
}
@@ -196,7 +202,7 @@ again: /*
/* Exit if buffer is empty (or overrun). */
if (KEY_MAXNAME == i || 0 == i) {
- TBL_MSG(tbl, MANDOCERR_TBL, ln, *pos);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse, ln, *pos, NULL);
return;
}
@@ -235,7 +241,7 @@ again: /*
*/
if (KEY_MAXKEYS == i)
- TBL_MSG(tbl, MANDOCERR_TBLOPT, ln, sv);
+ mandoc_msg(MANDOCERR_TBLOPT, tbl->parse, ln, sv, NULL);
goto again;
/* NOTREACHED */