From 2a0a0d8d6adfc82395ab2c4b17c41873664afa99 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Wed, 27 Sep 2017 16:56:09 +0200 Subject: [PATCH] buildsys: add check for asprintf to enable alt implementation Some platforms (like Solaris 10) lack asprintf. The implementation made for Windows works fine there, so use autoconf to determine whether asprintf exists, and if not, enable compiling the replacement implementation. To further simplify the guard logic, define HAVE_ASPRINTF for MinGW when appropriate in e_msoft.h. --- configure.ac | 1 + main/e_msoft.h | 4 ++++ main/options.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ecb1d1024b..2cfe8c83c3 100644 --- a/configure.ac +++ b/configure.ac @@ -485,6 +485,7 @@ AC_SUBST([FNMATCH_CPPFLAGS]) AC_CHECK_HEADERS(fnmatch.h) AM_CONDITIONAL([HAVE_FNMATCH], [test "x$have_fnmatch" = "xyes"]) +AC_CHECK_FUNCS(asprintf) AC_CHECK_FUNCS(strstr) AC_CHECK_FUNCS(strcasecmp stricmp, break) AC_CHECK_FUNCS(strncasecmp strnicmp, break) diff --git a/main/e_msoft.h b/main/e_msoft.h index c97f5bbc58..95242c8148 100644 --- a/main/e_msoft.h +++ b/main/e_msoft.h @@ -66,6 +66,10 @@ typedef enum { false, true } bool; # define FA_DIREC _A_SUBDIR # define ff_name name +# if defined(__USE_MINGW_ANSI_STDIO) && defined(__MINGW64_VERSION_MAJOR) +# define HAVE_ASPRINTF 1 +# endif + #endif #endif diff --git a/main/options.c b/main/options.c index 47d82de004..28c4a7ee11 100644 --- a/main/options.c +++ b/main/options.c @@ -597,7 +597,7 @@ static vString* getHome (void) } } -#if defined(_WIN32) && !(defined(__USE_MINGW_ANSI_STDIO) && defined(__MINGW64_VERSION_MAJOR)) +#ifndef HAVE_ASPRINTF /* Some versions of MinGW are missing _vscprintf's declaration, although they * still provide the symbol in the import library.