[gtk+] textiter: bug fix in forward_search() and backward_search()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] textiter: bug fix in forward_search() and backward_search()
- Date: Mon, 24 Jun 2013 18:14:52 +0000 (UTC)
commit ea4e88df868640ed727aa9a0ec11552673e94ccc
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Jun 24 17:00:31 2013 +0200
textiter: bug fix in forward_search() and backward_search()
When the search is case sensitive, g_utf8_normalize() is not called, so
the skip_decomp argument of the function forward_chars_with_skipping()
must be FALSE.
To verify that, when searching "éb", the count parameter of
forward_chars_with_skipping() have a different value:
- case sensitive: count = 2
- case insensitive: count = 3 (g_utf8_normalize() has been called)
The commit adds unit tests that didn't pass before, and that now pass
(without known regression, obviously).
https://bugzilla.gnome.org/show_bug.cgi?id=702977
gtk/gtktextiter.c | 9 ++++-----
testsuite/gtk/textiter.c | 12 ++++++++++++
2 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c
index 14f1e76..474cfe5 100644
--- a/gtk/gtktextiter.c
+++ b/gtk/gtktextiter.c
@@ -4409,7 +4409,6 @@ forward_chars_with_skipping (GtkTextIter *iter,
gboolean skip_nontext,
gboolean skip_decomp)
{
-
gint i;
g_return_if_fail (count >= 0);
@@ -4421,8 +4420,8 @@ forward_chars_with_skipping (GtkTextIter *iter,
gboolean ignored = FALSE;
/* minimal workaround to avoid the infinite loop of bug #168247. */
- if (gtk_text_iter_is_end (iter))
- return;
+ if (gtk_text_iter_is_end (iter))
+ return;
if (skip_nontext &&
gtk_text_iter_get_char (iter) == GTK_TEXT_UNKNOWN_CHAR)
@@ -4749,7 +4748,7 @@ lines_match (const GtkTextIter *start,
/* Go to end of search string */
forward_chars_with_skipping (&next, g_utf8_strlen (*lines, -1),
- visible_only, !slice, TRUE);
+ visible_only, !slice, case_insensitive);
g_free (line_text);
@@ -5307,7 +5306,7 @@ gtk_text_iter_backward_search (const GtkTextIter *iter,
}
forward_chars_with_skipping (&next, offset,
- visible_only, !slice, TRUE);
+ visible_only, !slice, case_insensitive);
if (match_end)
*match_end = next;
diff --git a/testsuite/gtk/textiter.c b/testsuite/gtk/textiter.c
index 53c8eeb..5e2bd5f 100644
--- a/testsuite/gtk/textiter.c
+++ b/testsuite/gtk/textiter.c
@@ -174,6 +174,18 @@ test_search (void)
check_found_forward ("This is some foo\nfoo text", "foo\nfoo", 0, 13, 20, "foo\nfoo");
check_found_backward ("This is some foo\nfoo text", "foo\nfoo", 0, 13, 20, "foo\nfoo");
check_not_found ("This is some foo\nfoo text", "Foo\nfoo", 0);
+
+ /* check also that different composition of utf8 characters
+ (e.g. accented letters) match */
+
+ check_found_forward ("This is some \303\200 text", "\303\200", 0, 13, 14, "\303\200");
+ check_found_forward ("This is some \303\200 text", "some \303\200", 0, 8, 14, "some \303\200");
+ check_found_forward ("This is some \303\200 text", "\303\200 text", 0, 13, 19, "\303\200 text");
+ check_found_forward ("This is some \303\200 text", "some \303\200 text", 0, 8, 19, "some \303\200 text");
+ check_found_backward ("This is some \303\240 text", "\303\240", 0, 13, 14, "\303\240");
+ check_found_backward ("This is some \303\240 text", "some \303\240", 0, 8, 14, "some \303\240");
+ check_found_backward ("This is some \303\240 text", "\303\240 text", 0, 13, 19, "\303\240 text");
+ check_found_backward ("This is some \303\240 text", "some \303\240 text", 0, 8, 19, "some \303\240 text");
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]