mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
Bug 673047 - gunicollate is broken on OS X
Apply slightly modified patch from Camillo Lugaresi which fixes gunicollate for OSX >= 10.6. It was totally hilariously broken for anyone on 10.6 and later, I dont know if it's now broken on 10.5, but better fix it for the vast majority of users.
This commit is contained in:
parent
11e306a759
commit
ef8510be09
@ -217,29 +217,28 @@ collate_key_to_string (UCCollationValue *key,
|
|||||||
gsize key_len)
|
gsize key_len)
|
||||||
{
|
{
|
||||||
gchar *result;
|
gchar *result;
|
||||||
gsize result_len;
|
gsize result_len = 0;
|
||||||
|
const gsize start = 2 * sizeof (void *) / sizeof (UCCollationValue);
|
||||||
gsize i;
|
gsize i;
|
||||||
|
|
||||||
/* Pretty smart algorithm here: ignore first eight bytes of the
|
/* The first codes should be skipped: the same string on the same
|
||||||
* collation key. It doesn't produce results equivalent to
|
* system can get different values at runtime in those positions,
|
||||||
* UCCompareCollationKeys's, but the difference seems to be only
|
* and they do not sort correctly. The exact size of the prefix
|
||||||
* that UCCompareCollationKeys in some cases produces 0 where our
|
* depends on whether we are building 64 or 32 bit.
|
||||||
* comparison gets -1 or 1. */
|
*/
|
||||||
|
if (key_len <= start)
|
||||||
if (key_len * sizeof (UCCollationValue) <= 8)
|
|
||||||
return g_strdup ("");
|
return g_strdup ("");
|
||||||
|
|
||||||
result_len = 0;
|
for (i = start; i < key_len; i++)
|
||||||
for (i = 8; i < key_len * sizeof (UCCollationValue); i++)
|
result_len += utf8_encode (NULL, g_htonl (key[i] + 1));
|
||||||
/* there may be nul bytes, encode byteval+1 */
|
|
||||||
result_len += utf8_encode (NULL, *((guchar*)key + i) + 1);
|
|
||||||
|
|
||||||
result = g_malloc (result_len + 1);
|
result = g_malloc (result_len + 1);
|
||||||
result_len = 0;
|
result_len = 0;
|
||||||
for (i = 8; i < key_len * sizeof (UCCollationValue); i++)
|
for (i = start; i < key_len; i++)
|
||||||
result_len += utf8_encode (result + result_len, *((guchar*)key + i) + 1);
|
result_len += utf8_encode (result + result_len, g_htonl (key[i] + 1));
|
||||||
|
|
||||||
|
result[result_len] = '\0';
|
||||||
|
|
||||||
result[result_len] = 0;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user