summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-03-20 16:02:05 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-03-20 16:02:05 +0000
commit80339b751a1833d9bbbf9856e7f48f56d91ba1d3 (patch)
tree4e59124e25202b7fa3543b670ae8434c1256cd45 /main.c
parent7ff718a5d9d20e97b6431bb61dc4cb34a1f431c7 (diff)
downloadmandoc-80339b751a1833d9bbbf9856e7f48f56d91ba1d3.tar.gz
Consolidate messages. Have all parse-time messages (in libmdoc,
libroff, etc., etc.) route into mandoc_msg() and mandoc_vmsg(), for the time being in libmandoc.h. This requires struct mparse to be passed into the allocation routines instead of mandocmsg and a void pointer. Then, move some of the functionality of the old mmsg() into read.c's mparse_mmsg() (check against wlevel and setting of file_status) and use main.c's mmsg() as simply a printing tool.
Diffstat (limited to 'main.c')
-rw-r--r--main.c37
1 files changed, 8 insertions, 29 deletions
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);
}