-/* $Id: main.c,v 1.34 2009/07/04 11:10:36 kristaps Exp $ */
+/* $Id: main.c,v 1.38 2009/07/07 09:52:08 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
const char *file; /* Current parse. */
int fd; /* Current parse. */
int wflags;
-#define WARN_WALL 0x03 /* All-warnings mask. */
-#define WARN_WCOMPAT (1 << 0) /* Compatibility warnings. */
-#define WARN_WSYNTAX (1 << 1) /* Syntax warnings. */
+#define WARN_WALL (1 << 0) /* All-warnings mask. */
#define WARN_WERR (1 << 2) /* Warnings->errors. */
int fflags;
#define IGN_SCOPE (1 << 0) /* Ignore scope errors. */
static int moptions(enum intt *, char *);
static int woptions(int *, char *);
static int merr(void *, int, int, const char *);
-static int manwarn(void *, int, int, const char *);
-static int mdocwarn(void *, int, int,
- enum mdoc_warn, const char *);
+static int mwarn(void *, int, int, const char *);
static int ffile(struct buf *, struct buf *,
const char *, struct curparse *);
static int fdesc(struct buf *, struct buf *,
struct man_cb mancb;
mancb.man_err = merr;
- mancb.man_warn = manwarn;
+ mancb.man_warn = mwarn;
/* Defaults from mandoc.1. */
struct mdoc_cb mdoccb;
mdoccb.mdoc_err = merr;
- mdoccb.mdoc_warn = mdocwarn;
+ mdoccb.mdoc_warn = mwarn;
/* Defaults from mandoc.1. */
woptions(int *wflags, char *arg)
{
char *v, *o;
- char *toks[5];
+ char *toks[3];
toks[0] = "all";
- toks[1] = "compat";
- toks[2] = "syntax";
- toks[3] = "error";
- toks[4] = NULL;
+ toks[1] = "error";
+ toks[2] = NULL;
while (*arg) {
o = arg;
*wflags |= WARN_WALL;
break;
case (1):
- *wflags |= WARN_WCOMPAT;
- break;
- case (2):
- *wflags |= WARN_WSYNTAX;
- break;
- case (3):
*wflags |= WARN_WERR;
break;
default:
struct curparse *curp;
curp = (struct curparse *)arg;
+
warnx("%s:%d: error: %s (column %d)",
curp->file, line, msg, col);
static int
-mdocwarn(void *arg, int line, int col,
- enum mdoc_warn type, const char *msg)
+mwarn(void *arg, int line, int col, const char *msg)
{
struct curparse *curp;
- char *wtype;
curp = (struct curparse *)arg;
- wtype = NULL;
- switch (type) {
- case (WARN_COMPAT):
- wtype = "compat";
- if (curp->wflags & WARN_WCOMPAT)
- break;
- return(1);
- case (WARN_SYNTAX):
- wtype = "syntax";
- if (curp->wflags & WARN_WSYNTAX)
- break;
+ if ( ! (curp->wflags & WARN_WALL))
return(1);
- }
- assert(wtype);
- warnx("%s:%d: %s warning: %s (column %d)",
- curp->file, line, wtype, msg, col);
+ warnx("%s:%d: warning: %s (column %d)",
+ curp->file, line, msg, col);
if ( ! (curp->wflags & WARN_WERR))
return(1);
return(0);
}
-
-static int
-manwarn(void *arg, int line, int col, const char *msg)
-{
- struct curparse *curp;
-
- curp = (struct curparse *)arg;
-
- if ( ! (curp->wflags & WARN_WSYNTAX))
- return(1);
-
- warnx("%s:%d: syntax warning: %s (column %d)",
- curp->file, line, msg, col);
-
- if ( ! (curp->wflags & WARN_WERR))
- return(1);
-
- warnx("considering warnings as errors");
- return(0);
-}