From 6719c1661f033ee6a197313c077e571a96ce1359 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Thu, 10 Jan 2019 06:29:00 +0000 Subject: Initializers for file-scope static variables should be compile-time constants, and while stderr is a compile-time constant in OpenBSD, Kelvin Sherlock 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. --- main.c | 5 +++-- mandoc_msg.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 22175639..1f738439 100644 --- a/main.c +++ b/main.c @@ -1,7 +1,7 @@ -/* $Id: main.c,v 1.316 2019/01/01 08:18:11 schwarze Exp $ */ +/* $Id: main.c,v 1.317 2019/01/10 06:29:00 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons - * Copyright (c) 2010-2012, 2014-2018 Ingo Schwarze + * Copyright (c) 2010-2012, 2014-2019 Ingo Schwarze * Copyright (c) 2010 Joerg Sonnenberger * * 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 5dfa26d1..4c4fabb9 100644 --- a/mandoc_msg.c +++ b/mandoc_msg.c @@ -1,4 +1,4 @@ -/* $Id: mandoc_msg.c,v 1.4 2018/12/16 00:21:05 schwarze Exp $ */ +/* $Id: mandoc_msg.c,v 1.5 2019/01/10 06:29:00 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze @@ -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; -- cgit v1.2.3-56-ge451