添付ファイル | gtksourceview-0.7.0_no-glib-normalizer.patch [^] (3,856 バイト) 2007-04-24 10:47 [表示] [非表示]--- gtksourceview-0.7.0.orig/gtksourceview/gtksourceiter.c 2003-09-25 12:20:06.000000000 +0900
+++ gtksourceview-0.7.0/gtksourceview/gtksourceiter.c 2007-04-23 18:30:44.000000000 +0900
@@ -27,6 +27,8 @@
#include <config.h>
#endif
+#include <ctype.h>
+#undef USE_GLIB_UNICODE_NORMALIZER
#include <string.h>
#include "gtksourceiter.h"
@@ -39,16 +41,22 @@
gsize haystack_len;
gchar *ret = NULL;
gchar *p;
+#ifdef USE_GLIB_UNICODE_NORMALIZER
gchar *casefold;
+#endif
gchar *caseless_haystack;
gint i;
g_return_val_if_fail (haystack != NULL, NULL);
g_return_val_if_fail (needle != NULL, NULL);
+#ifdef USE_GLIB_UNICODE_NORMALIZER
casefold = g_utf8_casefold (haystack, -1);
- caseless_haystack = g_utf8_normalize (casefold, -1, G_NORMALIZE_ALL);
+ caseless_haystack = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD);
g_free (casefold);
+#else
+ caseless_haystack = g_utf8_casefold (haystack, -1);
+#endif
needle_len = g_utf8_strlen (needle, -1);
haystack_len = g_utf8_strlen (caseless_haystack, -1);
@@ -94,16 +102,22 @@
gsize haystack_len;
gchar *ret = NULL;
gchar *p;
+#ifdef USE_GLIB_UNICODE_NORMALIZER
gchar *casefold;
+#endif
gchar *caseless_haystack;
gint i;
g_return_val_if_fail (haystack != NULL, NULL);
g_return_val_if_fail (needle != NULL, NULL);
+#ifdef USE_GLIB_UNICODE_NORMALIZER
casefold = g_utf8_casefold (haystack, -1);
- caseless_haystack = g_utf8_normalize (casefold, -1, G_NORMALIZE_ALL);
+ caseless_haystack = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD);
g_free (casefold);
+#else
+ caseless_haystack = g_utf8_casefold (haystack, -1);
+#endif
needle_len = g_utf8_strlen (needle, -1);
haystack_len = g_utf8_strlen (caseless_haystack, -1);
@@ -147,7 +161,11 @@
g_utf8_caselessnmatch (const char *s1, const char *s2,
gssize n1, gssize n2)
{
+#ifdef USE_GLIB_UNICODE_NORMALZIER
gchar *casefold;
+#else
+ guint i;
+#endif
gchar *normalized_s1;
gchar *normalized_s2;
gint len_s1;
@@ -159,13 +177,26 @@
g_return_val_if_fail (n1 > 0, FALSE);
g_return_val_if_fail (n2 > 0, FALSE);
+#ifdef USE_GLIB_UNICODE_NORMALZIER
casefold = g_utf8_casefold (s1, n1);
- normalized_s1 = g_utf8_normalize (casefold, -1, G_NORMALIZE_ALL);
+ normalized_s1 = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD);
g_free (casefold);
casefold = g_utf8_casefold (s2, n2);
- normalized_s2 = g_utf8_normalize (casefold, -1, G_NORMALIZE_ALL);
+ normalized_s2 = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD);
g_free (casefold);
+#else
+ normalized_s1 = g_malloc( n1 );
+ normalized_s2 = g_malloc( n2 );
+ if ( NULL == normalized_s1 || NULL == normalized_s2 )
+ return FALSE;
+
+ for ( i = 0 ; i < n1 ; i ++ )
+ normalized_s1[i] = toupper( s1[i] );
+
+ for ( i = 0 ; i < n2 ; i ++ )
+ normalized_s2[i] = toupper( s2[i] );
+#endif
len_s1 = strlen (normalized_s1);
len_s2 = strlen (normalized_s2);
@@ -442,9 +473,13 @@
new_string[len] = 0;
casefold = g_utf8_casefold (new_string, -1);
g_free (new_string);
- new_string = g_utf8_normalize (casefold, -1, G_NORMALIZE_ALL);
+#ifdef USE_GLIB_UNICODE_NORMALIZER
+ new_string = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD);
g_free (casefold);
string_list = g_slist_prepend (string_list, new_string);
+#else
+ string_list = g_slist_prepend (string_list, casefold);
+#endif
n++;
string = s + delimiter_len;
s = strstr (string, delimiter);
@@ -455,9 +490,13 @@
{
n++;
casefold = g_utf8_casefold (string, -1);
- new_string = g_utf8_normalize (casefold, -1, G_NORMALIZE_ALL);
+#ifdef USE_GLIB_UNICODE_NORMALIZER
+ new_string = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD);
g_free (casefold);
string_list = g_slist_prepend (string_list, new_string);
+#else
+ string_list = g_slist_prepend (string_list, casefold);
+#endif
}
str_array = g_new (gchar*, n);
|