aboutsummaryrefslogtreecommitdiff
path: root/devel/glib20
diff options
context:
space:
mode:
authorJean-Yves Lefort <jylefort@FreeBSD.org>2006-10-19 18:19:29 +0000
committerJean-Yves Lefort <jylefort@FreeBSD.org>2006-10-19 18:19:29 +0000
commitf45d9fedbd2390a952fd6db9d853644f31f3b840 (patch)
tree1a8ad076180626a725834c3b58ba3165f042d2ac /devel/glib20
parent42355cd1819cc23dfa01247bbeed8e33d94520c1 (diff)
Notes
Diffstat (limited to 'devel/glib20')
-rw-r--r--devel/glib20/Makefile8
-rw-r--r--devel/glib20/files/extra-patch-glib_Makefile.in11
-rw-r--r--devel/glib20/files/extra-patch-glib_gunicollate.c116
3 files changed, 135 insertions, 0 deletions
diff --git a/devel/glib20/Makefile b/devel/glib20/Makefile
index 83fdd84a816f..3eeae953292e 100644
--- a/devel/glib20/Makefile
+++ b/devel/glib20/Makefile
@@ -42,12 +42,20 @@ CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \
PTHREAD_CFLAGS="${PTHREAD_CFLAGS}" \
PTHREAD_LIBS="${PTHREAD_LIBS}"
+OPTIONS= COLLATION_FIX "fix string collation" off
+
.include <bsd.port.pre.mk>
.if ( ( ${OSVERSION} < 504101 ) || ( ${OSVERSION} >= 600000 && ${OSVERSION} < 600012 ) )
EXTRA_PATCHES+= ${FILESDIR}/extra-patch-gthread_gthread-posix.c
.endif
+.if defined(WITH_COLLATION_FIX)
+LIB_DEPENDS+= icui18n:${PORTSDIR}/devel/icu
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-glib_Makefile.in \
+ ${FILESDIR}/extra-patch-glib_gunicollate.c
+.endif
+
post-patch:
@${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g ; \
s|%%X11BASE%%|${X11BASE}|g' \
diff --git a/devel/glib20/files/extra-patch-glib_Makefile.in b/devel/glib20/files/extra-patch-glib_Makefile.in
new file mode 100644
index 000000000000..3c5676d2eb1e
--- /dev/null
+++ b/devel/glib20/files/extra-patch-glib_Makefile.in
@@ -0,0 +1,11 @@
+--- glib/Makefile.in.orig Wed Jul 19 01:08:13 2006
++++ glib/Makefile.in Wed Jul 19 01:09:10 2006
+@@ -130,7 +130,7 @@
+ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+ INSTOBJEXT = @INSTOBJEXT@
+ INTLLIBS = @INTLLIBS@
+-LDFLAGS = @LDFLAGS@
++LDFLAGS = @LDFLAGS@ -licui18n
+ LIBOBJS = @LIBOBJS@
+ LIBS = @LIBS@
+ LIBTOOL = @LIBTOOL@
diff --git a/devel/glib20/files/extra-patch-glib_gunicollate.c b/devel/glib20/files/extra-patch-glib_gunicollate.c
new file mode 100644
index 000000000000..dfcb99209ea8
--- /dev/null
+++ b/devel/glib20/files/extra-patch-glib_gunicollate.c
@@ -0,0 +1,116 @@
+--- glib/gunicollate.c.orig Thu Jun 8 17:24:10 2006
++++ glib/gunicollate.c Thu Oct 19 20:12:50 2006
+@@ -26,10 +26,57 @@
+ #include <wchar.h>
+ #endif
+
++#include <unicode/umachine.h>
++#include <unicode/ustring.h>
++#include <unicode/ucol.h>
++
+ #include "glib.h"
+ #include "gunicodeprivate.h"
+ #include "galias.h"
+
++static gboolean icu_collator_initialized = FALSE;
++static UCollator *icu_collator = NULL;
++G_LOCK_DEFINE_STATIC(icu_collator);
++
++static void
++init_icu_collator (void)
++{
++ G_LOCK(icu_collator);
++ if (! icu_collator_initialized)
++ {
++ UErrorCode error = U_ZERO_ERROR;
++
++ icu_collator = ucol_open(NULL, &error);
++ if (icu_collator == NULL)
++ g_warning("unable to initialize the ICU collator (%s), FreeBSD collation routines will be used", u_errorName(error));
++
++ icu_collator_initialized = TRUE;
++ }
++ G_UNLOCK(icu_collator);
++}
++
++static UChar *
++utf8_to_uchar (const char *str, int32_t len, int32_t *result_len)
++{
++ UErrorCode error = U_ZERO_ERROR;
++ UChar *result = NULL;
++
++ u_strFromUTF8(NULL, 0, result_len, str, len, &error);
++ if (error <= U_ZERO_ERROR || error == U_BUFFER_OVERFLOW_ERROR)
++ {
++ error = U_ZERO_ERROR;
++ result = g_new(UChar, *result_len);
++ u_strFromUTF8(result, *result_len, NULL, str, len, &error);
++ if (error > U_ZERO_ERROR)
++ {
++ g_free(result);
++ result = NULL;
++ }
++ }
++
++ return result;
++}
++
+ #ifdef _MSC_VER
+ /* Workaround for bug in MSVCR80.DLL */
+ static size_t
+@@ -94,6 +141,28 @@
+ g_return_val_if_fail (str1 != NULL, 0);
+ g_return_val_if_fail (str2 != NULL, 0);
+
++ init_icu_collator();
++ if (icu_collator != NULL)
++ {
++ int32_t wstr1_len;
++ UChar *wstr1 = utf8_to_uchar(str1, -1, &wstr1_len);
++ if (wstr1 != NULL)
++ {
++ int32_t wstr2_len;
++ UChar *wstr2 = utf8_to_uchar(str2, -1, &wstr2_len);
++ if (wstr2 != NULL)
++ {
++ result = ucol_strcoll(icu_collator, wstr1, wstr1_len, wstr2, wstr2_len);
++
++ g_free(wstr1);
++ g_free(wstr2);
++
++ return result;
++ }
++ g_free(wstr1);
++ }
++ }
++
+ str1_norm = g_utf8_normalize (str1, -1, G_NORMALIZE_ALL_COMPOSE);
+ str2_norm = g_utf8_normalize (str2, -1, G_NORMALIZE_ALL_COMPOSE);
+
+@@ -235,6 +304,26 @@
+ gchar *str_norm;
+
+ g_return_val_if_fail (str != NULL, NULL);
++
++ init_icu_collator();
++ if (icu_collator != NULL)
++ {
++ int32_t wstr_len;
++ UChar *wstr = utf8_to_uchar(str, len, &wstr_len);
++ if (wstr != NULL)
++ {
++ int32_t result_len;
++
++ /* get size of result */
++ result_len = ucol_getSortKey(icu_collator, wstr, wstr_len, NULL, 0);
++
++ result = g_new(char, result_len);
++ ucol_getSortKey(icu_collator, wstr, wstr_len, result, result_len);
++ g_free(wstr);
++
++ return result;
++ }
++ }
+
+ str_norm = g_utf8_normalize (str, len, G_NORMALIZE_ALL_COMPOSE);
+