From f9f94bf2b405aa2b72bbd6dea60036b3798796a1 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 1 Oct 2022 18:11:30 +0300 Subject: [PATCH 40/40] Meson: Define HAVE_VSNPRINTF and HAVE_WORKING_VSNPRINTF Have a dynamic existence of vsnprintf(), and assume it to be working one except on Windows. See osdn #45706 Signed-off-by: Marko Lindqvist --- gen_headers/meson_fc_config.h.in | 9 +++++++++ meson.build | 21 ++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/gen_headers/meson_fc_config.h.in b/gen_headers/meson_fc_config.h.in index 787a69405f..5e28d2ff91 100644 --- a/gen_headers/meson_fc_config.h.in +++ b/gen_headers/meson_fc_config.h.in @@ -227,6 +227,15 @@ #define HAVE_WORKING_VFORK 1 #endif +/* Define if there's vsnprintf function at all */ +#mesondefine HAVE_VSNPRINTF + +#ifdef HAVE_VSNPRINTF +/* Define if the version of the 'vsnprintf' function honours the + size argument and has a proper return value. */ +#mesondefine HAVE_WORKING_VSNPRINTF +#endif + /* iconv() available */ #mesondefine HAVE_ICONV diff --git a/meson.build b/meson.build index 833851bfbc..75b0bca815 100644 --- a/meson.build +++ b/meson.build @@ -153,13 +153,19 @@ if host_system == 'windows' priv_conf_data.set('ALWAYS_ROOT', 1) add_global_arguments('-D_WIN32_WINNT=0x0603', language : ['c', 'cpp']) net_dep = c_compiler.find_library('ws2_32') -elif host_system == 'haiku' - net_dep = c_compiler.find_library('network') - pub_conf_data.set('FREECIV_HAVE_PTHREAD', 1) - priv_conf_data.set('ALWAYS_ROOT', 1) else - pub_conf_data.set('FREECIV_HAVE_PTHREAD', 1) - net_dep = [] + # Assume that vsnprintf() is a working one, if it's found + # (that's checked separately) + priv_conf_data.set('HAVE_WORKING_VSNPRINTF', 1) + + if host_system == 'haiku' + net_dep = c_compiler.find_library('network') + pub_conf_data.set('FREECIV_HAVE_PTHREAD', 1) + priv_conf_data.set('ALWAYS_ROOT', 1) + else + pub_conf_data.set('FREECIV_HAVE_PTHREAD', 1) + net_dep = [] + endif endif pub_headers = [ @@ -292,7 +298,8 @@ priv_functions = [ '_strcoll', '_stricoll', 'fcntl', - 'ioctl' + 'ioctl', + 'vsnprintf' ] foreach func : priv_functions -- 2.35.1