Skip to content

Commit

Permalink
buildsys: add check for asprintf to enable alt implementation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
grobian committed Sep 29, 2017
1 parent fbffd78 commit 5bf18b5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions main/e_msoft.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion main/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ static vString* getHome (void)
}
}

#if defined(_WIN32) && !(defined(__USE_MINGW_ANSI_STDIO) && defined(__MINGW64_VERSION_MAJOR))
#if defined(_WIN32) || !defined(HAVE_ASPRINTF)

/* Some versions of MinGW are missing _vscprintf's declaration, although they
* still provide the symbol in the import library.
Expand Down

0 comments on commit 5bf18b5

Please sign in to comment.