-/* $Id: main.c,v 1.154 2011/03/20 11:41:24 kristaps Exp $ */
+/* $Id: main.c,v 1.158 2011/03/22 10:35:26 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
#include "main.h"
#include "mdoc.h"
#include "man.h"
-#include "roff.h"
#if !defined(__GNUC__) || (__GNUC__ < 2)
# if !defined(lint)
struct curparse {
struct mparse *mp;
- const char *file; /* current file-name */
enum mandoclevel wlevel; /* ignore messages below this */
int wstop; /* stop after a file with a warning */
enum outt outtype; /* which output to use */
"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",
"generic fatal error",
+ "not a manual",
"column syntax is inconsistent",
"NOT IMPLEMENTED: .Bd -file",
"line scope broken, syntax violated",
"static buffer exhausted",
};
-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 *);
/* NOTREACHED */
}
- curp.mp = mparse_alloc(type, evt_open, evt_close, mmsg, &curp);
+ curp.mp = mparse_alloc(type, curp.wlevel, mmsg, &curp);
argc -= optind;
argv += optind;
exit((int)MANDOCLEVEL_BADARG);
}
-static int
-evt_open(void *arg, const char *file)
-{
-
- evt_close(arg, file);
- return(1);
-}
-
-static void
-evt_close(void *arg, const char *file)
-{
- struct curparse *p;
-
- p = (struct curparse *)arg;
- p->file = file;
-}
-
static void
parse(struct curparse *curp, int fd,
const char *file, enum mandoclevel *level)
}
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);
}