Fix the build issue with gperf 3.1

To support the one of changes in gperf 3.1:
* The 'len' parameter of the hash function and of the lookup function is now
  of type 'size_t' instead of 'unsigned int'. This makes it safe to call these
  functions with strings of length > 4 GB, on 64-bit machines.
This commit is contained in:
Akira TAGOH 2017-02-23 21:39:10 +09:00
parent 1ab5258f7c
commit 9878b306f6
2 changed files with 22 additions and 2 deletions

View File

@ -193,6 +193,26 @@ fi
AC_CHECK_MEMBERS([struct dirent.d_type],,, AC_CHECK_MEMBERS([struct dirent.d_type],,,
[#include <dirent.h>]) [#include <dirent.h>])
# Check the argument type of the gperf hash/lookup function
AC_MSG_CHECKING([The type of len parameter of gperf hash/lookup function])
fc_gperf_test="$(echo 'foo' | gperf -L ANSI-C)"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <string.h>
const char *in_word_set(register const char *, register size_t);
$fc_gperf_test
]])], [FC_GPERF_SIZE_T=size_t],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <string.h>
const char *in_word_set(register const char *, register unsigned int);
$fc_gperf_test
]])], [FC_GPERF_SIZE_T="unsigned int"],
[AC_MSG_ERROR([Unable to determine the type of the len parameter of the gperf hash/lookup function])]
)])
AC_DEFINE_UNQUOTED(FC_GPERF_SIZE_T, $FC_GPERF_SIZE_T, [The type of len parameter of the gperf hash/lookup function])
AC_MSG_RESULT($FC_GPERF_SIZE_T)
# #
# Checks for iconv # Checks for iconv
# #

View File

@ -25,10 +25,10 @@
#include "fcint.h" #include "fcint.h"
static unsigned int static unsigned int
FcObjectTypeHash (register const char *str, register unsigned int len); FcObjectTypeHash (register const char *str, register FC_GPERF_SIZE_T len);
static const struct FcObjectTypeInfo * static const struct FcObjectTypeInfo *
FcObjectTypeLookup (register const char *str, register unsigned int len); FcObjectTypeLookup (register const char *str, register FC_GPERF_SIZE_T len);
#include "fcobjshash.h" #include "fcobjshash.h"