From a5dd6fcc4f46a322cc547a5fcfa1b52cbc5ec6d6 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Fri, 15 Apr 2011 09:27:38 -0400 Subject: builder: do not include on win32 Spotted by Kean Johnston . https://mail.gnome.org/archives/gtk-devel-list/2011-April/msg00010.html --- gvdb-builder.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gvdb-builder.c b/gvdb-builder.c index 4b48d80..f65ca7d 100644 --- a/gvdb-builder.c +++ b/gvdb-builder.c @@ -24,7 +24,9 @@ #include #include +#if !defined(G_OS_WIN32) || !defined(_MSC_VER) #include +#endif #include -- cgit v1.2.1 From 92652ac79177bcdced5f01122debb50eabdb3e2c Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Mon, 12 Sep 2011 08:06:13 -0400 Subject: hashing: always use signed chars Our hashing of non-ASCII strings was undefined due to the fact that 'char' is signed on some platforms, unsigned on others. Always use a signed char. Discovered by Alexander Larsson. https://bugzilla.gnome.org/show_bug.cgi?id=658806 --- gvdb-builder.c | 2 +- gvdb-reader.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gvdb-builder.c b/gvdb-builder.c index f65ca7d..91adec6 100644 --- a/gvdb-builder.c +++ b/gvdb-builder.c @@ -93,7 +93,7 @@ djb_hash (const gchar *key) guint32 hash_value = 5381; while (*key) - hash_value = hash_value * 33 + *key++; + hash_value = hash_value * 33 + *(signed char *)key++; return hash_value; } diff --git a/gvdb-reader.c b/gvdb-reader.c index 73f4f13..57816af 100644 --- a/gvdb-reader.c +++ b/gvdb-reader.c @@ -254,7 +254,7 @@ gvdb_table_lookup (GvdbTable *file, return NULL; for (key_length = 0; key[key_length]; key_length++) - hash_value = (hash_value * 33) + key[key_length]; + hash_value = (hash_value * 33) + ((signed char *) key)[key_length]; if (!gvdb_table_bloom_filter (file, hash_value)) return NULL; -- cgit v1.2.1