Discussion:
gperf 3.1 breaks module unicase
(too old to reply)
Darshit Shah
2017-02-13 15:24:24 UTC
Permalink
Raw Message
Gperf 3.1 was recently released and it changes the `len` parameter of
the hash function to type `size_t` instead of the old `unsigned int`.
This breaks the unicase module which defines the prototype of the hash
function as:
gl_unicase_special_lookup (const char *str, unsigned int len);

whereas gperf produces the file `unicase/special-casing-table.h` with
the function:
gl_unicase_special_lookup (register const char *str, register size_t len);


This causes GCC to error out when compiling the module due to a type mismatch.
I am not sure how this issue should be resolved, since simply changing the
prototype will cause builds to fail with older versions of gperf.
--
Thanking You,
Darshit Shah
PGP Fingerprint: 7845 120B 07CB D8D6 ECE5 FF2B 2A17 43ED A91A 35B6
Paul Eggert
2017-02-13 15:50:02 UTC
Permalink
Raw Message
simply changing the prototype will cause builds to fail with older
versions of gperf.
Simplest would be to change it to size_t, as we can assume developers
using gnulib have recent developer tools. Could you prepare a patch
along those lines?
Darshit Shah
2017-02-13 16:15:45 UTC
Permalink
Raw Message
Sure, if making such a change is okay, I can prepare the patch quickly.

I will also go through all the other gperf files in the repository and
update their respective prototypes as well.
Post by Paul Eggert
simply changing the prototype will cause builds to fail with older
versions of gperf.
Simplest would be to change it to size_t, as we can assume developers
using gnulib have recent developer tools. Could you prepare a patch
along those lines?
--
Thanking You,
Darshit Shah
PGP Fingerprint: 7845 120B 07CB D8D6 ECE5 FF2B 2A17 43ED A91A 35B6
Eric Blake
2017-02-13 17:34:06 UTC
Permalink
Raw Message
Post by Paul Eggert
simply changing the prototype will cause builds to fail with older
versions of gperf.
Simplest would be to change it to size_t, as we can assume developers
using gnulib have recent developer tools. Could you prepare a patch
along those lines?
It's also possible to go more complicated for supporting multiple gperf
versions, by doing a configure-time test for what type to use, #define a
macro (to either int or size_t), and use that macro in the signature.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Darshit Shah
2017-02-13 17:45:47 UTC
Permalink
Raw Message
I've attached a simple patch that fixes the build on my end. This simply
assumes the latest version of Gperf is used to generate the files.
Post by Paul Eggert
simply changing the prototype will cause builds to fail with older
versions of gperf.
Simplest would be to change it to size_t, as we can assume developers
using gnulib have recent developer tools. Could you prepare a patch
along those lines?
--
Thanking You,
Darshit Shah
PGP Fingerprint: 7845 120B 07CB D8D6 ECE5 FF2B 2A17 43ED A91A 35B6
Bruno Haible
2017-02-13 19:41:25 UTC
Permalink
Raw Message
Hi Darshit,
Post by Darshit Shah
I've attached a simple patch that fixes the build on my end. This simply
assumes the latest version of Gperf is used to generate the files.
Thanks. I've applied your patch (with an added space between
'#include' and the file name - to follow common coding conventions).

If you have some more time to play with it, how about mechanically copying
the declaration from the generated file into lib/unicase/special-casing.h ?
I mean, to modify the module description with a command such as

grep '^gl_unicase_special_lookup' $(srcdir)/unicase/special-casing-table.h | sed -e 's/register //' -e 's/^/ /' -e 's/$/;/'

Bruno
Bruno Haible
2017-05-18 10:58:37 UTC
Permalink
Raw Message
Post by Bruno Haible
If you have some more time to play with it, how about mechanically copying
the declaration from the generated file into lib/unicase/special-casing.h ?
I mean, to modify the module description with a command such as
grep '^gl_unicase_special_lookup' $(srcdir)/unicase/special-casing-table.h | sed -e 's/register //' -e 's/^/ /' -e 's/$/;/'
Since the gperf 3.0.x incompatiblity issue is coming up again, let me fix it:


2017-05-18 Bruno Haible <***@clisp.org>

unicase/special-casing: Fix incompatibility with gperf-3.0.4
(regression from 2017-02-13).
* lib/unicase/special-casing.in.h: Renamed from
lib/unicase/special-casing.h.
* modules/unicase/special-casing (Files): Add
lib/unicase/special-casing.in.h. Remove lib/unicase/special-casing.h.
(Makefile.am): Add rule for generating unicase/special-casing.h.
Update BUILT_SOURCES and MOSTLYCLEANFILES accordingly.
* lib/unicase/special-casing.c: Include "unicase/special-casing.h",
not "special-casing.h".
* lib/unicase/u*.c: Likewise.

diff --git a/modules/unicase/special-casing b/modules/unicase/special-casing
index 0f863a3..a4a7fcf 100644
--- a/modules/unicase/special-casing
+++ b/modules/unicase/special-casing
@@ -2,7 +2,7 @@ Description:
Special casing table.

Files:
-lib/unicase/special-casing.h
+lib/unicase/special-casing.in.h
lib/unicase/special-casing.c
lib/unicase/special-casing-table.gperf

@@ -22,6 +22,17 @@ MOSTLYCLEANFILES += unicase/special-casing-table.h-t
MAINTAINERCLEANFILES += unicase/special-casing-table.h
EXTRA_DIST += unicase/special-casing-table.h

+# Generate special-casing.h with a declaration that depends on the gperf version.
+unicase/special-casing.h: unicase/special-casing.in.h unicase/special-casing-table.h
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ declaration=`grep '^gl_unicase_special_lookup' $(srcdir)/unicase/special-casing-table.h | sed -e 's/register //g'` && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e "/gl_unicase_special_lookup/s/gl_unicase_special_lookup.*/$${declaration};/" $(srcdir)/unicase/special-casing.in.h; \
+ } > $@-t && \
+ mv -f $@-t $@
+BUILT_SOURCES += unicase/special-casing.h
+MOSTLYCLEANFILES += unicase/special-casing.h unicase/special-casing.h-t
+
Include:
"unicase/special-casing.h"

diff --git a/lib/unicase/special-casing.c b/lib/unicase/special-casing.c
index 029c578..384bb71 100644
--- a/lib/unicase/special-casing.c
+++ b/lib/unicase/special-casing.c
@@ -18,7 +18,7 @@
#include <config.h>

/* Specification. */
-#include "special-casing.h"
+#include "unicase/special-casing.h"

#include <string.h>

diff --git a/lib/unicase/u16-casemap.c b/lib/unicase/u16-casemap.c
index aec4dd6..3ab5388 100644
--- a/lib/unicase/u16-casemap.c
+++ b/lib/unicase/u16-casemap.c
@@ -29,7 +29,7 @@
#include "uninorm.h"
#include "caseprop.h"
#include "context.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

#define FUNC u16_casemap
#define UNIT uint16_t
diff --git a/lib/unicase/u16-ct-casefold.c b/lib/unicase/u16-ct-casefold.c
index 1e01d75..71cbf55 100644
--- a/lib/unicase/u16-ct-casefold.c
+++ b/lib/unicase/u16-ct-casefold.c
@@ -25,7 +25,7 @@
#include <stdlib.h>

#include "unicasemap.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"
#include "casefold.h"

#define FUNC u16_ct_casefold
diff --git a/lib/unicase/u16-ct-tolower.c b/lib/unicase/u16-ct-tolower.c
index 76f4be2..9eea5e7 100644
--- a/lib/unicase/u16-ct-tolower.c
+++ b/lib/unicase/u16-ct-tolower.c
@@ -23,7 +23,7 @@
#include <stddef.h>

#include "unicasemap.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

uint16_t *
u16_ct_tolower (const uint16_t *s, size_t n,
diff --git a/lib/unicase/u16-ct-totitle.c b/lib/unicase/u16-ct-totitle.c
index e369462..158295f 100644
--- a/lib/unicase/u16-ct-totitle.c
+++ b/lib/unicase/u16-ct-totitle.c
@@ -31,7 +31,7 @@
#include "uninorm.h"
#include "caseprop.h"
#include "context.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

#define FUNC u16_ct_totitle
#define UNIT uint16_t
diff --git a/lib/unicase/u16-ct-toupper.c b/lib/unicase/u16-ct-toupper.c
index b7f188d..40441a1 100644
--- a/lib/unicase/u16-ct-toupper.c
+++ b/lib/unicase/u16-ct-toupper.c
@@ -23,7 +23,7 @@
#include <stddef.h>

#include "unicasemap.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

uint16_t *
u16_ct_toupper (const uint16_t *s, size_t n,
diff --git a/lib/unicase/u16-tolower.c b/lib/unicase/u16-tolower.c
index a59c3ed..1477c18 100644
--- a/lib/unicase/u16-tolower.c
+++ b/lib/unicase/u16-tolower.c
@@ -23,7 +23,7 @@
#include <stddef.h>

#include "unicasemap.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

uint16_t *
u16_tolower (const uint16_t *s, size_t n, const char *iso639_language,
diff --git a/lib/unicase/u16-toupper.c b/lib/unicase/u16-toupper.c
index ccc9df7..87ad89d 100644
--- a/lib/unicase/u16-toupper.c
+++ b/lib/unicase/u16-toupper.c
@@ -23,7 +23,7 @@
#include <stddef.h>

#include "unicasemap.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

uint16_t *
u16_toupper (const uint16_t *s, size_t n, const char *iso639_language,
diff --git a/lib/unicase/u32-casemap.c b/lib/unicase/u32-casemap.c
index 2a03ac3..b2411eb 100644
--- a/lib/unicase/u32-casemap.c
+++ b/lib/unicase/u32-casemap.c
@@ -29,7 +29,7 @@
#include "uninorm.h"
#include "caseprop.h"
#include "context.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

#define FUNC u32_casemap
#define UNIT uint32_t
diff --git a/lib/unicase/u32-ct-casefold.c b/lib/unicase/u32-ct-casefold.c
index 75fab2e..7d58aa5 100644
--- a/lib/unicase/u32-ct-casefold.c
+++ b/lib/unicase/u32-ct-casefold.c
@@ -25,7 +25,7 @@
#include <stdlib.h>

#include "unicasemap.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"
#include "casefold.h"

#define FUNC u32_ct_casefold
diff --git a/lib/unicase/u32-ct-tolower.c b/lib/unicase/u32-ct-tolower.c
index a89a9e6..8daf165 100644
--- a/lib/unicase/u32-ct-tolower.c
+++ b/lib/unicase/u32-ct-tolower.c
@@ -23,7 +23,7 @@
#include <stddef.h>

#include "unicasemap.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

uint32_t *
u32_ct_tolower (const uint32_t *s, size_t n,
diff --git a/lib/unicase/u32-ct-totitle.c b/lib/unicase/u32-ct-totitle.c
index 1b5fc42..a9ea73f 100644
--- a/lib/unicase/u32-ct-totitle.c
+++ b/lib/unicase/u32-ct-totitle.c
@@ -31,7 +31,7 @@
#include "uninorm.h"
#include "caseprop.h"
#include "context.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

#define FUNC u32_ct_totitle
#define UNIT uint32_t
diff --git a/lib/unicase/u32-ct-toupper.c b/lib/unicase/u32-ct-toupper.c
index ce26da9..4411dba 100644
--- a/lib/unicase/u32-ct-toupper.c
+++ b/lib/unicase/u32-ct-toupper.c
@@ -23,7 +23,7 @@
#include <stddef.h>

#include "unicasemap.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

uint32_t *
u32_ct_toupper (const uint32_t *s, size_t n,
diff --git a/lib/unicase/u32-tolower.c b/lib/unicase/u32-tolower.c
index 3a105e3..7d2aced 100644
--- a/lib/unicase/u32-tolower.c
+++ b/lib/unicase/u32-tolower.c
@@ -23,7 +23,7 @@
#include <stddef.h>

#include "unicasemap.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

uint32_t *
u32_tolower (const uint32_t *s, size_t n, const char *iso639_language,
diff --git a/lib/unicase/u32-toupper.c b/lib/unicase/u32-toupper.c
index f5832db..d93291d 100644
--- a/lib/unicase/u32-toupper.c
+++ b/lib/unicase/u32-toupper.c
@@ -23,7 +23,7 @@
#include <stddef.h>

#include "unicasemap.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

uint32_t *
u32_toupper (const uint32_t *s, size_t n, const char *iso639_language,
diff --git a/lib/unicase/u8-casemap.c b/lib/unicase/u8-casemap.c
index 7f11333..ca1b18a 100644
--- a/lib/unicase/u8-casemap.c
+++ b/lib/unicase/u8-casemap.c
@@ -29,7 +29,7 @@
#include "uninorm.h"
#include "caseprop.h"
#include "context.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

#define FUNC u8_casemap
#define UNIT uint8_t
diff --git a/lib/unicase/u8-ct-casefold.c b/lib/unicase/u8-ct-casefold.c
index b22f245..5b64cf0 100644
--- a/lib/unicase/u8-ct-casefold.c
+++ b/lib/unicase/u8-ct-casefold.c
@@ -25,7 +25,7 @@
#include <stdlib.h>

#include "unicasemap.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"
#include "casefold.h"

#define FUNC u8_ct_casefold
diff --git a/lib/unicase/u8-ct-tolower.c b/lib/unicase/u8-ct-tolower.c
index 169dc91..aff70dd 100644
--- a/lib/unicase/u8-ct-tolower.c
+++ b/lib/unicase/u8-ct-tolower.c
@@ -23,7 +23,7 @@
#include <stddef.h>

#include "unicasemap.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

uint8_t *
u8_ct_tolower (const uint8_t *s, size_t n,
diff --git a/lib/unicase/u8-ct-totitle.c b/lib/unicase/u8-ct-totitle.c
index cdee074..b74cc27 100644
--- a/lib/unicase/u8-ct-totitle.c
+++ b/lib/unicase/u8-ct-totitle.c
@@ -31,7 +31,7 @@
#include "uninorm.h"
#include "caseprop.h"
#include "context.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

#define FUNC u8_ct_totitle
#define UNIT uint8_t
diff --git a/lib/unicase/u8-ct-toupper.c b/lib/unicase/u8-ct-toupper.c
index f6d9d76..7ddb046 100644
--- a/lib/unicase/u8-ct-toupper.c
+++ b/lib/unicase/u8-ct-toupper.c
@@ -23,7 +23,7 @@
#include <stddef.h>

#include "unicasemap.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

uint8_t *
u8_ct_toupper (const uint8_t *s, size_t n,
diff --git a/lib/unicase/u8-tolower.c b/lib/unicase/u8-tolower.c
index 0e38379..9681bd5 100644
--- a/lib/unicase/u8-tolower.c
+++ b/lib/unicase/u8-tolower.c
@@ -23,7 +23,7 @@
#include <stddef.h>

#include "unicasemap.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

uint8_t *
u8_tolower (const uint8_t *s, size_t n, const char *iso639_language,
diff --git a/lib/unicase/u8-toupper.c b/lib/unicase/u8-toupper.c
index 18b899d..6ddad44 100644
--- a/lib/unicase/u8-toupper.c
+++ b/lib/unicase/u8-toupper.c
@@ -23,7 +23,7 @@
#include <stddef.h>

#include "unicasemap.h"
-#include "special-casing.h"
+#include "unicase/special-casing.h"

uint8_t *
u8_toupper (const uint8_t *s, size_t n, const char *iso639_language,
Tim Ruehsen
2017-02-15 12:02:14 UTC
Permalink
Raw Message
Hi,

just want to share my solution (project Wget), in case anyone needs a quick
solution to work with gperf < 3.1 and latest gnulib (using unicode stuff).

Darshit updated gnulib for Wget yesterday and that broke my builds (Debian
unstable, gperf 3.0.4). I added the following to bootstrap.conf:

bootstrap_post_import_hook ()
{
# We need to patch unicase/special-casing-table.h for gperf < 3.1
GPERF_VER=$(gperf --version | {
IFS=' .' read x y major minor bugfix _
printf "%d%02d%02d" $major $minor $bugfix
})

if [ $GPERF_VER -lt 30100 ]; then
echo "Patching lib/unicase/special-casing-table.h for gperf < 3.1"
sed -i "s/gl_unicase_special_lookup.*/gl_unicase_special_lookup\ \(const
char \*str, size_t len\)/g" lib/unicase/special-casing-table.h
fi
}


Best Regards,

Tim Rühsen
Loading...