Fix MinGW cros build on Linux

This commit is contained in:
Tim Rühsen 2018-04-21 11:30:22 +02:00
parent 8595ebb0ce
commit b220ffb0b9
2 changed files with 15 additions and 25 deletions

View File

@ -319,6 +319,9 @@ elif test -n "$NEEDS_SOCKET" ; then
LIBS="$LIBS -lsocket"
elif test -n "$NEEDS_NSL" ; then
LIBS="$LIBS -lnsl"
else
# Needed for MinGW / Windows
AC_SEARCH_LIBS(inet_pton, ws2_32)
fi
# Check for clock_gettime() used for performance measurement
@ -365,7 +368,7 @@ AC_SUBST(PSL_TESTFILE)
# check for alloca / alloca.h
AC_FUNC_ALLOCA
AC_CHECK_FUNCS([strndup clock_gettime fmemopen])
AC_CHECK_FUNCS([strndup clock_gettime fmemopen nl_langinfo])
# Override the template file name of the generated .pc file, so that there
# is no need to rename the template file when the API version changes.

View File

@ -102,30 +102,12 @@
# include <unistr.h>
#endif
#include <libpsl.h>
#ifndef HAVE_STRNDUP
/* I found no strndup on my old SUSE 7.3 test system (gcc 2.95) */
static char *strndup(const char *s, size_t n)
{
char *dst;
size_t s_len = strlen(s);
if (s_len > n)
n = s_len;
dst = malloc(n + 1);
if (dst) {
memcpy(dst, s, n);
dst[n] = 0;
}
return dst;
}
#ifndef WINICONV_CONST
# define WINICONV_CONST
#endif
#include <libpsl.h>
/**
* SECTION:libpsl
* @short_description: Public Suffix List library functions
@ -1812,8 +1794,13 @@ out:
do {
/* find out local charset encoding */
if (!encoding) {
#ifdef HAVE_NL_LANGINFO
encoding = nl_langinfo(CODESET);
#elif defined _WIN32
static char buf[16];
snprintf(buf, sizeof(buf), "CP%u", GetACP());
encoding = buf;
#endif
if (!encoding || !*encoding)
encoding = "ASCII";
}
@ -1831,7 +1818,7 @@ out:
if (!dst) {
ret = PSL_ERR_NO_MEM;
}
else if (iconv(cd, &tmp, &tmp_len, &dst_tmp, &dst_len_tmp) != (size_t)-1
else if (iconv(cd, (WINICONV_CONST char **)&tmp, &tmp_len, &dst_tmp, &dst_len_tmp) != (size_t)-1
&& iconv(cd, NULL, NULL, &dst_tmp, &dst_len_tmp) != (size_t)-1)
{
/* start size for u8_tolower internal memory allocation.