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



commit ba3bfb1d9c4fcb23ac1d0862b9f5843bc5ca52ff
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 9a4ec81..95ee2d3 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.c
+++ b/src/libtracker-db/tracker-db-interface-sqlite.c
@@ -255,17 +255,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]