From 31010a2cc6f2d0596dac640b190df3472e0089dd Mon Sep 17 00:00:00 2001 From: Akira TAGOH Date: Thu, 23 Feb 2017 21:39:10 +0900 Subject: [PATCH] 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. --- config.h.in | 3 +++ configure | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 20 ++++++++++++++++++++ src/fcobjs.c | 4 ++-- 4 files changed, 81 insertions(+), 2 deletions(-) diff --git a/config.h.in b/config.h.in index ffff4cd..d5c14a1 100644 --- a/config.h.in +++ b/config.h.in @@ -21,6 +21,9 @@ /* System font directory */ #undef FC_DEFAULT_FONTS +/* The type of len parameter of the gperf hash/lookup function */ +#undef FC_GPERF_SIZE_T + /* Define to nothing if C supports flexible array members, and to 1 if it does not. That way, with a declaration like `struct s { int n; double d[FLEXIBLE_ARRAY_MEMBER]; };', the struct hack can be used with pre-C99 diff --git a/configure b/configure index eed481c..9eddc2b 100755 --- a/configure +++ b/configure @@ -14946,6 +14946,62 @@ _ACEOF fi +# Check the argument type of the gperf hash/lookup function +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking The type of len parameter of gperf hash/lookup function" >&5 +$as_echo_n "checking The type of len parameter of gperf hash/lookup function... " >&6; } +fc_gperf_test="$(echo 'foo' | gperf -L ANSI-C)" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + + const char *in_word_set(register const char *, register size_t); + $fc_gperf_test + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + FC_GPERF_SIZE_T=size_t +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + + const char *in_word_set(register const char *, register unsigned int); + $fc_gperf_test + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + FC_GPERF_SIZE_T="unsigned int" +else + as_fn_error $? "Unable to determine the type of the len parameter of the gperf hash/lookup function" "$LINENO" 5 + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +cat >>confdefs.h <<_ACEOF +#define FC_GPERF_SIZE_T $FC_GPERF_SIZE_T +_ACEOF + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $FC_GPERF_SIZE_T" >&5 +$as_echo "$FC_GPERF_SIZE_T" >&6; } + # # Checks for iconv # diff --git a/src/fcobjs.c b/src/fcobjs.c index 16ff31c..33bba8d 100644 --- a/src/fcobjs.c +++ b/src/fcobjs.c @@ -25,10 +25,10 @@ #include "fcint.h" 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 * -FcObjectTypeLookup (register const char *str, register unsigned int len); +FcObjectTypeLookup (register const char *str, register FC_GPERF_SIZE_T len); #include "fcobjshash.h" -- 2.12.0