changeset 9489:6541fcc3bf54 HEAD

fts-squat: Fixed searching multi-byte characters.
author Timo Sirainen <tss@iki.fi>
date Mon, 23 Nov 2009 12:51:07 -0500
parents e47eb506eebd
children fd84592e817b
files src/plugins/fts-squat/squat-trie.c
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/fts-squat/squat-trie.c	Mon Nov 23 12:19:24 2009 -0500
+++ b/src/plugins/fts-squat/squat-trie.c	Mon Nov 23 12:51:07 2009 -0500
@@ -1906,7 +1906,8 @@
 	unsigned int char_idx, max_chars, i, j, bytelen;
 	int ret;
 
-	max_chars = uni_utf8_strlen_n(data, size);
+	for (i = 0, max_chars = 0; i < size; max_chars++)
+		i += char_lengths[i];
 	i_assert(max_chars > 0);
 
 	i = 0; char_idx = 0;
@@ -2001,7 +2002,7 @@
 		   search it in parts. */
 		if (i != start) {
 			ret = squat_trie_lookup_partial(&ctx, data + start,
-							char_lengths,
+							char_lengths + start,
 							i - start);
 			searched = TRUE;
 		}
@@ -2027,7 +2028,7 @@
 			array_clear(maybe_uids);
 		} else {
 			ret = squat_trie_lookup_partial(&ctx, data + start,
-							char_lengths,
+							char_lengths + start,
 							i - start);
 		}
 	} else if (str_bytelen > 0) {
@@ -2035,7 +2036,7 @@
 		array_clear(definite_uids);
 		if (i != start && ret >= 0) {
 			ret = squat_trie_lookup_partial(&ctx, data + start,
-							char_lengths,
+							char_lengths + start,
 							i - start);
 		} else if (!searched) {
 			/* string has only nonindexed chars,