From 86ee1722f58531328124dcf2f714dd1ae8f94e1d Mon Sep 17 00:00:00 2001 From: daan Date: Fri, 30 Aug 2019 14:34:46 -0700 Subject: [PATCH 1/2] in verbose mode, list all options at startup --- src/options.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/options.c b/src/options.c index cd9b4e48..06d876fc 100644 --- a/src/options.c +++ b/src/options.c @@ -80,7 +80,12 @@ static void mi_option_init(mi_option_desc_t* desc); void _mi_options_init(void) { // called on process load for(int i = 0; i < _mi_option_last; i++ ) { - mi_option_get((mi_option_t)i); // initialize + mi_option_t option = (mi_option_t)i; + mi_option_get(option); // initialize + if (option != mi_option_verbose) { + mi_option_desc_t* desc = &options[option]; + _mi_verbose_message("option '%s': %ld\n", desc->name, desc->value); + } } } @@ -89,10 +94,7 @@ long mi_option_get(mi_option_t option) { mi_option_desc_t* desc = &options[option]; mi_assert(desc->option == option); // index should match the option if (mi_unlikely(desc->init == UNINIT)) { - mi_option_init(desc); - if (option != mi_option_verbose) { - _mi_verbose_message("option '%s': %ld\n", desc->name, desc->value); - } + mi_option_init(desc); } return desc->value; } From 9fc726619a182744362f07ff4f51b7660133c4d4 Mon Sep 17 00:00:00 2001 From: daan Date: Fri, 30 Aug 2019 14:37:04 -0700 Subject: [PATCH 2/2] guard against passing stdin/stderr as output --- src/options.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/options.c b/src/options.c index 06d876fc..ff0c4e03 100644 --- a/src/options.c +++ b/src/options.c @@ -150,6 +150,7 @@ static void mi_out_stderr(const char* msg) { // Default output handler // -------------------------------------------------------- +#pragma warning(suppress:4180) static volatile _Atomic(mi_output_fun*) mi_out_default; // = NULL static mi_output_fun* mi_out_get_default(void) { @@ -179,7 +180,7 @@ static void mi_vfprintf( mi_output_fun* out, const char* prefix, const char* fmt if (fmt==NULL) return; if (_mi_preloading() || recurse) return; recurse = true; - if (out==NULL) out = mi_out_get_default(); + if (out==NULL || (FILE*)out==stdout || (FILE*)out==stderr) out = mi_out_get_default(); vsnprintf(buf,sizeof(buf)-1,fmt,args); if (prefix != NULL) out(prefix); out(buf);