[tracker/tracker-0.8] TrackerDBInterfaceSqlite: Check more carefully for is_parent().



commit 64f2aac8ecfc8e0eb029881ac1708d0d97c7f6ab
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Apr 22 13:34:09 2010 +0200

    TrackerDBInterfaceSqlite: Check more carefully for is_parent().
    
    Be more intelligent about trailing slashes and don't take exact string matches as a positive.

 src/libtracker-db/tracker-db-interface-sqlite.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-interface-sqlite.c b/src/libtracker-db/tracker-db-interface-sqlite.c
index c70628f..61aafbc 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.c
+++ b/src/libtracker-db/tracker-db-interface-sqlite.c
@@ -253,17 +253,29 @@ function_sparql_uri_is_parent (sqlite3_context *context,
 	}
 
 	if (strncmp (uri, parent, parent_len) == 0 && uri[parent_len] == '/') {
+		const gchar *slash;
+
 		while (uri[parent_len] == '/') {
 			parent_len++;
 		}
 
 		remaining = &uri[parent_len];
 
-		if (strchr (remaining, '/') == NULL) {
+		if (*remaining == '\0') {
+			/* Exact match, not a child */
+			match = FALSE;
+		} else if ((slash = strchr (remaining, '/')) == NULL) {
 			/* Remaining doesn't have uri
 			 * separator, it's a direct child.
 			 */
 			match = TRUE;
+		} else {
+			/* Check it's not trailing slashes */
+			while (*slash == '/') {
+				slash++;
+			}
+
+			match = (*slash == '\0');
 		}
 	}
 



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