]> git.sur5r.net Git - kconfig-frontends/commitdiff
libs/parser: support gperf v3.1+
authorYann E. MORIN <yann.morin.1998@free.fr>
Sat, 8 Apr 2017 10:03:04 +0000 (12:03 +0200)
committerYann E. MORIN <yann.morin.1998@free.fr>
Sat, 8 Apr 2017 10:10:48 +0000 (12:10 +0200)
As Freddie wrote:

    New version of gperf (3.1, released in January 2017) breaks the
    build of kconfig-frontends both for the last package you uploaded
    (3.12.0.0) and for the HEAD from the repository.

    The problem is that gperf 3.1 now uses "size_t" as the length
    argument for the functions, while earlier versions use "unsigned
    int".

As suggested by Freddie, add a configure check to detect the type used
in gperf declarations. Unlike the patch from Freddie, we use as much
autoconf code as possible, rather than canned shell commands. This makes
the code about twice bigger, but it is full autoconf stuff, so
presumably more portable.

Also add a patch to be applied by scripts/ksync.sh, so that the change
persists with future update from upstream (as so we catch it when
upstream fixes it by themselves).

Reported-by: Freddie Chopin <freddie.chopin@gmail.com>
Inspired-by: https://gist.github.com/FreddieChopin/b2ec415ee4eacbd4b92499bbf4e934be
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Makefile.am
configure.ac
libs/parser/hconf.gperf
libs/parser/hconf.gperf.patch [new file with mode: 0644]

index 926bf1153ebc13128482da6bf21db292e745cd55..65126c0abd676c22a6a46ad63e51a8ddaac890af 100644 (file)
@@ -43,6 +43,7 @@ dist_EXTRA_libs_parser_libkconfig_parser_la_SOURCES = \
 libs_parser_libkconfig_parser_la_CPPFLAGS = \
        -DROOTMENU="\"$(root_menu)\"" \
        -DCONFIG_=\"$(config_prefix)\" \
+       -DGPERF_LEN_TYPE="$(GPERF_LEN_TYPE)" \
        $(intl_CPPFLAGS) \
        -I$(top_srcdir)/libs/parser
 libs_parser_libkconfig_parser_la_CFLAGS = \
index bfaf058ac2c7e43386704b1277026bea9d991015..150bc500cdaff67032544bfcbcbe5b4bf2b7d9af 100644 (file)
@@ -203,12 +203,6 @@ AM_PROG_CC_C_O
 AC_PROG_CXX
 AC_C_INLINE
 AC_PROG_MAKE_SET
-AC_CHECK_PROGS(
-    [GPERF],
-    [gperf])
-AS_IF(
-    [test -z "$GPERF"],
-    [AC_MSG_ERROR([can not find gperf])])
 AS_IF(
     [test "$need_pkgconfig" = "yes"],
     [PKG_PROG_PKG_CONFIG()])
@@ -230,6 +224,46 @@ AS_IF(
         [AC_MSG_ERROR([can not find a parser generator (such as yacc or bison)])]))
 AC_SUBST([AM_YFLAGS], ["-t -l -p zconf"])
 
+#----------------------------------------
+# Special section to check for gperf.
+AC_CHECK_PROGS(
+    [GPERF],
+    [gperf])
+AS_IF(
+    [test -z "$GPERF"],
+    [AC_MSG_ERROR([can not find gperf])])
+
+# gperf 3.1 generates functions with 'size_t' instead of 'unsigned int'
+AC_MSG_CHECKING([for the type used in gperf declarations])
+GPERF_LEN_TYPE=
+AS_VAR_SET(
+    [GPERF_PROLOG],
+    [`echo foo,bar | ${GPERF} -L ANSI-C`])
+AC_COMPILE_IFELSE(
+    [AC_LANG_PROGRAM(
+        [[
+        #include <string.h>
+        ${GPERF_PROLOG}
+        const char * in_word_set(const char *, size_t);
+        ]])
+    ],
+    [GPERF_LEN_TYPE='size_t'],
+    [
+    AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM(
+            [[
+            #include <string.h>
+            ${GPERF_PROLOG}
+            const char * in_word_set(const char *, unsigned int);
+            ]])
+        ],
+        [GPERF_LEN_TYPE='unsigned int'],
+        [AC_MSG_RESULT([not size_t, not unsigned int. What else?])
+         AC_MSG_FAILURE([unable to detect the type used in gperf declarations])
+        ])])
+AC_MSG_RESULT([${GPERF_LEN_TYPE}])
+AC_SUBST([GPERF_LEN_TYPE])
+
 #----------------------------------------
 # Check for gettext, for the kconfig frontends
 [has_gettext="$enable_L10n"]
index ead02edec93614618822bc61d8fcc25197853df5..e5f0af795b7536993995069e3916528e4141bcd6 100644 (file)
@@ -9,7 +9,7 @@
 
 struct kconf_id;
 
-static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
+static const struct kconf_id *kconf_id_lookup(register const char *str, register GPERF_LEN_TYPE len);
 
 %%
 mainmenu,      T_MAINMENU,     TF_COMMAND
diff --git a/libs/parser/hconf.gperf.patch b/libs/parser/hconf.gperf.patch
new file mode 100644 (file)
index 0000000..af92eca
--- /dev/null
@@ -0,0 +1,13 @@
+diff --git a/libs/parser/hconf.gperf b/libs/parser/hconf.gperf
+index ead02ed..e5f0af7 100644
+--- a/libs/parser/hconf.gperf
++++ b/libs/parser/hconf.gperf
+@@ -9,7 +9,7 @@
+ struct kconf_id;
+-static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
++static const struct kconf_id *kconf_id_lookup(register const char *str, register GPERF_LEN_TYPE len);
+ %%
+ mainmenu,     T_MAINMENU,     TF_COMMAND