Fix MinGW cros build on Linux
This commit is contained in:
parent
8595ebb0ce
commit
b220ffb0b9
|
@ -319,6 +319,9 @@ elif test -n "$NEEDS_SOCKET" ; then
|
||||||
LIBS="$LIBS -lsocket"
|
LIBS="$LIBS -lsocket"
|
||||||
elif test -n "$NEEDS_NSL" ; then
|
elif test -n "$NEEDS_NSL" ; then
|
||||||
LIBS="$LIBS -lnsl"
|
LIBS="$LIBS -lnsl"
|
||||||
|
else
|
||||||
|
# Needed for MinGW / Windows
|
||||||
|
AC_SEARCH_LIBS(inet_pton, ws2_32)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for clock_gettime() used for performance measurement
|
# Check for clock_gettime() used for performance measurement
|
||||||
|
@ -365,7 +368,7 @@ AC_SUBST(PSL_TESTFILE)
|
||||||
|
|
||||||
# check for alloca / alloca.h
|
# check for alloca / alloca.h
|
||||||
AC_FUNC_ALLOCA
|
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
|
# 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.
|
# is no need to rename the template file when the API version changes.
|
||||||
|
|
35
src/psl.c
35
src/psl.c
|
@ -102,30 +102,12 @@
|
||||||
# include <unistr.h>
|
# include <unistr.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <libpsl.h>
|
#ifndef WINICONV_CONST
|
||||||
|
# define WINICONV_CONST
|
||||||
#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;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <libpsl.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:libpsl
|
* SECTION:libpsl
|
||||||
* @short_description: Public Suffix List library functions
|
* @short_description: Public Suffix List library functions
|
||||||
|
@ -1812,8 +1794,13 @@ out:
|
||||||
do {
|
do {
|
||||||
/* find out local charset encoding */
|
/* find out local charset encoding */
|
||||||
if (!encoding) {
|
if (!encoding) {
|
||||||
|
#ifdef HAVE_NL_LANGINFO
|
||||||
encoding = nl_langinfo(CODESET);
|
encoding = nl_langinfo(CODESET);
|
||||||
|
#elif defined _WIN32
|
||||||
|
static char buf[16];
|
||||||
|
snprintf(buf, sizeof(buf), "CP%u", GetACP());
|
||||||
|
encoding = buf;
|
||||||
|
#endif
|
||||||
if (!encoding || !*encoding)
|
if (!encoding || !*encoding)
|
||||||
encoding = "ASCII";
|
encoding = "ASCII";
|
||||||
}
|
}
|
||||||
|
@ -1831,7 +1818,7 @@ out:
|
||||||
if (!dst) {
|
if (!dst) {
|
||||||
ret = PSL_ERR_NO_MEM;
|
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)
|
&& iconv(cd, NULL, NULL, &dst_tmp, &dst_len_tmp) != (size_t)-1)
|
||||||
{
|
{
|
||||||
/* start size for u8_tolower internal memory allocation.
|
/* start size for u8_tolower internal memory allocation.
|
||||||
|
|
Loading…
Reference in New Issue