-/* $Id: mandoc_msg.c,v 1.4 2018/12/16 00:21:05 schwarze Exp $ */
+/* $Id: mandoc_msg.c,v 1.10 2020/01/19 18:02:00 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2014-2020 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include "config.h"
+
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
MANDOCERR_WARNING,
MANDOCERR_ERROR,
MANDOCERR_UNSUPP,
- MANDOCERR_MAX,
- MANDOCERR_MAX
+ MANDOCERR_BADARG,
+ MANDOCERR_SYSERR
};
static const char *const level_name[MANDOCLEVEL_MAX] = {
"missing manual title, using \"\"",
"missing manual section, using \"\"",
"unknown manual section",
- "missing date, using today's date",
+ "missing date, using \"\"",
"cannot parse date, using it verbatim",
"date in the future, using it anyway",
"missing Os macro, using \"\"",
"data block open at end of tbl",
/* related to document structure and macros */
- NULL,
"duplicate prologue macro",
"skipping late title macro",
"input stack limit exceeded, infinite loop?",
"excessive shift",
"NOT IMPLEMENTED: .so with absolute path or \"..\"",
".so request failed",
+ "skipping tag containing whitespace",
"skipping all arguments",
"skipping excess arguments",
"divide by zero",
"eqn delim option in tbl",
"unsupported tbl layout modifier",
"ignoring macro in table",
+
+ /* bad command line arguments */
+ NULL,
+ "bad command line argument",
+ "duplicate command line argument",
+ "option has a superfluous value",
+ "missing option value",
+ "bad option value",
+ "duplicate option value",
+ "no such tag",
+
+ /* system errors */
+ NULL,
+ "dup",
+ "exec",
+ "fdopen",
+ "fflush",
+ "fork",
+ "fstat",
+ "getline",
+ "glob",
+ "gzclose",
+ "gzdopen",
+ "mkstemp",
+ "open",
+ "pledge",
+ "read",
+ "wait",
+ "write",
};
-static FILE *fileptr = stderr;
+static FILE *fileptr = NULL;
static const char *filename = NULL;
-static enum mandocerr min_type = MANDOCERR_MAX;
+static enum mandocerr min_type = MANDOCERR_BADARG;
static enum mandoclevel rc = MANDOCLEVEL_OK;
va_list ap;
enum mandoclevel level;
- if (t < min_type && t != MANDOCERR_FILE)
+ if (t < min_type)
return;
- level = MANDOCLEVEL_UNSUPP;
+ level = MANDOCLEVEL_SYSERR;
while (t < lowest_type[level])
level--;
mandoc_msg_setrc(level);
}
fputc('\n', fileptr);
}
+
+void
+mandoc_msg_summary(void)
+{
+ if (fileptr != NULL && rc != MANDOCLEVEL_OK)
+ fprintf(fileptr,
+ "%s: see above the output for %s messages\n",
+ getprogname(), level_name[rc]);
+}