gtkhtml r8789 - trunk/gtkhtml
- From: fujiwarat svn gnome org
- To: svn-commits-list gnome org
- Subject: gtkhtml r8789 - trunk/gtkhtml
- Date: Tue, 25 Mar 2008 10:40:40 +0000 (GMT)
Author: fujiwarat
Date: Tue Mar 25 10:40:39 2008
New Revision: 8789
URL: http://svn.gnome.org/viewvc/gtkhtml?rev=8789&view=rev
Log:
2008-03-25 Takao Fujiwara <takao fujiwara sun com>
reviewed by: Milan Crha <mcrha redhat com>
** Fixes bug #512046
* htmlclueflow.c: (search_text):
* htmlengine-search.c: (html_engine_search_next_int),
(html_engine_search_next), (html_engine_search_incremental):
* htmlsearch.c: (html_search_new):
Revised the algorithm in search_text() so that the email
composed widow does not go to the infinite loop with multibyte chars.
Modified:
trunk/gtkhtml/ChangeLog
trunk/gtkhtml/htmlclueflow.c
trunk/gtkhtml/htmlengine-search.c
trunk/gtkhtml/htmlsearch.c
Modified: trunk/gtkhtml/htmlclueflow.c
==============================================================================
--- trunk/gtkhtml/htmlclueflow.c (original)
+++ trunk/gtkhtml/htmlclueflow.c Tue Mar 25 10:40:39 2008
@@ -2277,21 +2277,21 @@
eq_bytes = 0;
if (info->found) {
if (info->start_pos > 0)
- index = ((guchar *)g_utf8_offset_to_pointer ((gchar *) par, info->start_pos + ((info->forward) ? 1 : -1))) - par;
+ index = ((guchar *)g_utf8_offset_to_pointer ((gchar *) par, info->start_pos + ((info->forward) ? 0 : -1))) - par;
else
- index = ((guchar *)g_utf8_offset_to_pointer ((gchar *) par, info->start_pos + ((info->forward) ? 1 : 0))) - par;
+ index = info->forward ? ((guchar *)g_utf8_offset_to_pointer ((gchar *) par, info->start_pos) - par) : -1;
} else {
- index = (info->forward) ? 0 : text_bytes - 1;
+ index = (info->forward) ? 0 : text_bytes;
}
- /* FIXME make shorter text instead */
- if (!info->forward) {
- guchar* tmp = (guchar *)g_utf8_next_char (par + index);
+ /* make shorter text instead */
+ if (!info->forward && index + info->text_bytes < text_bytes) {
+ guchar* tmp = (guchar *)(par + index + info->text_bytes);
*tmp = '\0';
}
if ((info->forward && index < text_bytes)
- || (!info->forward && index > 0)) {
+ || (!info->forward && index >= 0)) {
if (info->reb) {
/* regex search */
gint rv;
@@ -2343,12 +2343,11 @@
} else {
/* substring search - simple one - could be improved
go thru par and look for info->text */
- while (par [index]) {
+ while ((info->forward && par[index])
+ || (!info->forward && index >= 0)) {
gunichar unicode_info, unicode_par;
- unicode_info = g_utf8_get_char (((info->forward)
- ? (info->text + eq_bytes)
- : g_utf8_prev_char (info->text + info->text_bytes - eq_bytes)));
+ unicode_info = g_utf8_get_char (info->text + eq_bytes);
unicode_par = g_utf8_get_char ((gchar *) par + index);
if (!info->case_sensitive) {
unicode_info = g_unichar_toupper (unicode_info);
@@ -2360,19 +2359,20 @@
if (eq_bytes == info->text_bytes) {
/* The above par + index is always at the beginning of the last character matched */
- if (info->forward)
- index = (guchar *) g_utf8_next_char ((gchar *) par + index) - par - eq_bytes;
+ index = (guchar *) g_utf8_next_char ((gchar *) par + index) - par - eq_bytes;
search_set_info (head, info, par, index, info->text_bytes);
retval=TRUE;
break;
}
} else {
- index += (info->forward) ? -eq_bytes : eq_bytes;
+ index -= eq_bytes;
eq_bytes = 0;
}
- index += (info->forward)
+ index += (info->forward || unicode_info == unicode_par)
? (((guchar *) g_utf8_next_char (par + index)) - par - index)
- : (((guchar *) g_utf8_prev_char ((gchar *) par + index)) - par - index);
+ : (index
+ ? (((guchar *) g_utf8_prev_char ((gchar *) par + index)) - par - index)
+ : -1);
}
}
}
Modified: trunk/gtkhtml/htmlengine-search.c
==============================================================================
--- trunk/gtkhtml/htmlengine-search.c (original)
+++ trunk/gtkhtml/htmlengine-search.c Tue Mar 25 10:40:39 2008
@@ -164,8 +164,8 @@
html_search_set_forward (e->search_info, forward);
}
-gboolean
-html_engine_search_next (HTMLEngine *e)
+static gboolean
+html_engine_search_next_int (HTMLEngine *e)
{
HTMLSearch *info = e->search_info;
gboolean retval = FALSE;
@@ -197,6 +197,20 @@
}
gboolean
+html_engine_search_next (HTMLEngine *e)
+{
+ HTMLSearch *info = e->search_info;
+
+ if (!info)
+ return FALSE;
+ if (!info->text)
+ return FALSE;
+
+ info->start_pos += ((info->forward) ? 1 : 0);
+ return html_engine_search_next_int (e);
+}
+
+gboolean
html_engine_search_incremental (HTMLEngine *e, const gchar *text, gboolean forward)
{
HTMLSearch *info = e->search_info;
@@ -206,7 +220,7 @@
html_search_set_text (info, text);
if (info->found)
info->start_pos += ((info->forward) ? -1 : g_utf8_strlen (text, -1));
- return html_engine_search_next (e);
+ return html_engine_search_next_int (e);
} else
return html_engine_search (e, text, FALSE, forward, FALSE);
}
Modified: trunk/gtkhtml/htmlsearch.c
==============================================================================
--- trunk/gtkhtml/htmlsearch.c (original)
+++ trunk/gtkhtml/htmlsearch.c Tue Mar 25 10:40:39 2008
@@ -60,7 +60,7 @@
if (e->mark)
ns->start_pos = forward
? e->mark->offset + 1
- : e->cursor->offset - 1;
+ : e->mark->offset;
else
ns->start_pos = e->cursor->offset;
for (o = e->cursor->object; o; o = o->parent)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]