aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandoc_msg.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2019-07-10 19:39:01 +0000
committerIngo Schwarze <schwarze@openbsd.org>2019-07-10 19:39:01 +0000
commita597f1a3e2780fed1216f2237e8a276110b0daef (patch)
treee59b39076a9f1141d186002bff45c25d72423539 /mandoc_msg.c
parent589c83d3597ba6229a69bda10630710c515d2508 (diff)
downloadmandoc-a597f1a3e2780fed1216f2237e8a276110b0daef.tar.gz
mandoc-a597f1a3e2780fed1216f2237e8a276110b0daef.tar.zst
mandoc-a597f1a3e2780fed1216f2237e8a276110b0daef.zip
Some time ago, i simplified mandoc_msg() such that it can be used
everywhere and not only in the parsers. For more uniform messages, use it at more places instead of err(3), in particular in the main program. While here, integrate a few trivial functions called at exactly one place into the main option parser, and let a few more functions use the normal convention of returning 0 for success and -1 for error.
Diffstat (limited to 'mandoc_msg.c')
-rw-r--r--mandoc_msg.c44
1 files changed, 36 insertions, 8 deletions
diff --git a/mandoc_msg.c b/mandoc_msg.c
index ff4d8031..f3377640 100644
--- a/mandoc_msg.c
+++ b/mandoc_msg.c
@@ -1,7 +1,7 @@
-/* $Id: mandoc_msg.c,v 1.6 2019/03/06 15:55:38 schwarze Exp $ */
+/* $Id: mandoc_msg.c,v 1.7 2019/07/10 19:39:01 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-2019 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
@@ -29,8 +29,8 @@ static const enum mandocerr lowest_type[MANDOCLEVEL_MAX] = {
MANDOCERR_WARNING,
MANDOCERR_ERROR,
MANDOCERR_UNSUPP,
- MANDOCERR_MAX,
- MANDOCERR_MAX
+ MANDOCERR_BADARG,
+ MANDOCERR_SYSERR
};
static const char *const level_name[MANDOCLEVEL_MAX] = {
@@ -193,7 +193,6 @@ static const char *const type_message[MANDOCERR_MAX] = {
"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?",
@@ -240,11 +239,40 @@ static const char *const type_message[MANDOCERR_MAX] = {
"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 = 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;
@@ -297,10 +325,10 @@ mandoc_msg(enum mandocerr t, int line, int col, const char *fmt, ...)
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);