[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Tracker] [PATCH] fix to prevent tracker from indexing "" as a word



I noticed tracker indexing the word "" for every file --- or at least
the logs showed them.

It disturbed me and I went hunting for this one, took pretty long,
maybe it's just my code blind eyes :).

The problem is that tracker_parse_text_to_string has to insert spaces
- but tracker_parse_text_fast splits on spaces - so, spaces at the end
and the beginning make up 2 empty strings and one or more useful ones.

Here's the fix, though I am pretty sure that one of you guys has a
better (i.e. the real) fix ;)

Kind regards, Marcus
diff --git a/src/trackerd/tracker-parser.c b/src/trackerd/tracker-parser.c
index e1efe6a..193d554 100644
--- a/src/trackerd/tracker-parser.c
+++ b/src/trackerd/tracker-parser.c
@@ -484,8 +484,10 @@ tracker_parse_text_fast (GHashTable *word_table, const char *txt, int weight)
 	array =  g_strsplit (txt, " ", -1);
 
 	for (tmp = array; *tmp; tmp++) {
-		count = GPOINTER_TO_INT (g_hash_table_lookup (word_table, *tmp));
-		g_hash_table_insert (word_table, g_strdup (*tmp), GINT_TO_POINTER (count + weight));	
+		if (**tmp) {
+			count = GPOINTER_TO_INT (g_hash_table_lookup (word_table, *tmp));
+			g_hash_table_insert (word_table, g_strdup (*tmp), GINT_TO_POINTER (count + weight));	
+		}
 	}
 
 	g_strfreev (array);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]