mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 11:26:16 +01:00
gunicollate: work around FreeBSD wchar_t not matching our gunichar type
In !863 I assumed that a 4 byte wchar_t would be equal to gunichar on all platforms, but this is not the case for FreeBSD. It previously was using the non wchar_t based API because it doesn't define __STDC_ISO_10646__. Add back the __STDC_ISO_10646__ check again and introduce a more meaningful macro for guarding the code paths that are mixing gunichar and wchar_t. Fixes #1798
This commit is contained in:
parent
41f68f8b19
commit
b49e767e2e
@ -37,6 +37,9 @@
|
|||||||
#include "gcharset.h"
|
#include "gcharset.h"
|
||||||
#include "gconvert.h"
|
#include "gconvert.h"
|
||||||
|
|
||||||
|
#if SIZEOF_WCHAR_T == 4 && defined(__STDC_ISO_10646__)
|
||||||
|
#define GUNICHAR_EQUALS_WCHAR_T 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
/* Workaround for bug in MSVCR80.DLL */
|
/* Workaround for bug in MSVCR80.DLL */
|
||||||
@ -99,7 +102,7 @@ g_utf8_collate (const gchar *str1,
|
|||||||
g_free (str2_utf16);
|
g_free (str2_utf16);
|
||||||
g_free (str1_utf16);
|
g_free (str1_utf16);
|
||||||
|
|
||||||
#elif defined(HAVE_WCHAR_H) && SIZEOF_WCHAR_T == 4
|
#elif defined(HAVE_WCHAR_H) && defined(GUNICHAR_EQUALS_WCHAR_T)
|
||||||
|
|
||||||
gunichar *str1_norm;
|
gunichar *str1_norm;
|
||||||
gunichar *str2_norm;
|
gunichar *str2_norm;
|
||||||
@ -157,7 +160,7 @@ g_utf8_collate (const gchar *str1,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_WCHAR_H) && SIZEOF_WCHAR_T == 4
|
#if defined(HAVE_WCHAR_H) && defined(GUNICHAR_EQUALS_WCHAR_T)
|
||||||
/* We need UTF-8 encoding of numbers to encode the weights if
|
/* We need UTF-8 encoding of numbers to encode the weights if
|
||||||
* we are using wcsxfrm. However, we aren't encoding Unicode
|
* we are using wcsxfrm. However, we aren't encoding Unicode
|
||||||
* characters, so we can't simply use g_unichar_to_utf8.
|
* characters, so we can't simply use g_unichar_to_utf8.
|
||||||
@ -380,7 +383,7 @@ g_utf8_collate_key (const gchar *str,
|
|||||||
g_return_val_if_fail (str != NULL, NULL);
|
g_return_val_if_fail (str != NULL, NULL);
|
||||||
result = carbon_collate_key (str, len);
|
result = carbon_collate_key (str, len);
|
||||||
|
|
||||||
#elif defined(HAVE_WCHAR_H) && SIZEOF_WCHAR_T == 4
|
#elif defined(HAVE_WCHAR_H) && defined(GUNICHAR_EQUALS_WCHAR_T)
|
||||||
|
|
||||||
gsize xfrm_len;
|
gsize xfrm_len;
|
||||||
gunichar *str_norm;
|
gunichar *str_norm;
|
||||||
|
Loading…
Reference in New Issue
Block a user