patches/gtkhtml-01-backward-finding.diff
author dcarbery
Fri, 24 Nov 2006 16:37:59 +0000
branch217update
changeset 19096 d542fc2c823e
parent 8542 f9a892d12770
child 9260 42f72558a1aa
permissions -rw-r--r--
Merged trunk changes r9797:9829 into 217update branch.

--- gtkhtml-3.12.1/src/htmlclueflow.c	Mon Jun 12 20:05:02 2006
+++ gtkhtml-3.12.1-new/src/htmlclueflow.c	Mon Nov 13 15:58:49 2006
@@ -2276,10 +2276,7 @@
 		/* set eq_bytes and pos counters */
 		eq_bytes = 0;
 		if (info->found) {
-                	if (info->start_pos > 0)
-	                        index = ((guchar *)g_utf8_offset_to_pointer (par, info->start_pos + ((info->forward) ? 1 : -1))) - par;
-			else
-				index = ((guchar *)g_utf8_offset_to_pointer (par, info->start_pos + ((info->forward) ? 1 : 0))) - par;
+			index = ((guchar *)g_utf8_offset_to_pointer (par, info->start_pos + ((info->forward) ? 1 : 0))) - par;
 		} else {
 			index = (info->forward) ? 0 : text_bytes - 1;
 		}
@@ -2342,10 +2339,29 @@
 				/* substring search - simple one - could be improved
 				   go thru par and look for info->text */
 				while (par [index]) {
-					if (info->trans [(guchar) info->text
-							[(info->forward) ? eq_bytes : info->text_bytes - eq_bytes - 1]]
-					    == info->trans [par [index]]) {
-						eq_bytes ++;
+					gunichar unicode_info, unicode_par;
+
+               				if (!info->case_sensitive) {
+						gchar * casefold_info, * casefold_par;			
+						casefold_info = g_utf8_casefold (((info->forward) 
+										? (info->text + eq_bytes) 
+										: g_utf8_prev_char (info->text + info->text_bytes - eq_bytes))
+										, -1);
+						casefold_par = g_utf8_casefold ((gchar *)par + index, -1);
+						unicode_info = g_utf8_get_char (casefold_info);
+       						unicode_par = g_utf8_get_char (casefold_par);
+						g_free (casefold_info);
+						g_free (casefold_par);
+					} else { 
+						unicode_info = g_utf8_get_char (((info->forward)
+										? (info->text + eq_bytes)
+										: g_utf8_prev_char (info->text + info->text_bytes - eq_bytes)));
+						unicode_par = g_utf8_get_char (par + index);
+					}
+
+               				if (unicode_info == unicode_par) {
+						eq_bytes += (guchar *)g_utf8_next_char (par + index) - par - index;
+
 						if (eq_bytes == info->text_bytes) {
 							search_set_info (head, info, par,
 									 index - (info->forward