summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2019-01-10 06:29:00 +0000
committerIngo Schwarze <schwarze@openbsd.org>2019-01-10 06:29:00 +0000
commit4bfa887201da03d46daafa5d4426ba288eb6e8e7 (patch)
tree9f25c924ba628935483f3831cd0e4125f350c7a8
parentda0aa06476cbc1023f263447977a576ef15a6090 (diff)
downloadmandoc-4bfa887201da03d46daafa5d4426ba288eb6e8e7.tar.gz
Initializers for file-scope static variables should be compile-time
constants, and while stderr is a compile-time constant in OpenBSD, Kelvin Sherlock <ksherlock at gmail dot com> reports that it isn't on some other systems, for example on FreeBSD or Linux. So do the initialization by calling mandoc_msg_setoutfile() from main() instead.
-rw-r--r--main.c3
-rw-r--r--mandoc_msg.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/main.c b/main.c
index a0878099..400e7e65 100644
--- a/main.c
+++ b/main.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2012, 2014-2018 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2012, 2014-2019 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -148,6 +148,7 @@ main(int argc, char *argv[])
setprogname(progname);
#endif
+ mandoc_msg_setoutfile(stderr);
if (strncmp(progname, "mandocdb", 8) == 0 ||
strcmp(progname, BINM_MAKEWHATIS) == 0)
return mandocdb(argc, argv);
diff --git a/mandoc_msg.c b/mandoc_msg.c
index 9f366cef..1a133f1c 100644
--- a/mandoc_msg.c
+++ b/mandoc_msg.c
@@ -240,7 +240,7 @@ static const char *const type_message[MANDOCERR_MAX] = {
"ignoring macro in table",
};
-static FILE *fileptr = stderr;
+static FILE *fileptr = NULL;
static const char *filename = NULL;
static enum mandocerr min_type = MANDOCERR_MAX;
static enum mandoclevel rc = MANDOCLEVEL_OK;