From 0cd93eca491d9d5d402802bbf6d2fe6c529317ad Mon Sep 17 00:00:00 2001 From: arf20 Date: Mon, 8 Dec 2025 01:26:18 +0100 Subject: fixes --- index.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'index.c') diff --git a/index.c b/index.c index 096fe6e..3840549 100644 --- a/index.c +++ b/index.c @@ -262,6 +262,8 @@ index_recurse(size_t size, const char *dir, int examine, size_t rootlen) map_insert(map, de->d_name, data, child); } + closedir(dirp); + return map; } @@ -291,13 +293,33 @@ void index_lookup_substr_caseinsensitive(map_t *index, const char *query, results_t *results) { + for (size_t i = 0; i < index->size; i++) { + if (!index->map[i].data) + continue; + for (struct node_s *node = &index->map[i]; node; node = node->next) { + if (strcasestr(node->data->name, query)) + results_insert(results, node->data); + if (node->child) + index_lookup_substr(node->child, query, results); + } + } } void index_lookup_exact(map_t *index, const char *query, results_t *results) { + for (size_t i = 0; i < index->size; i++) { + if (!index->map[i].data) + continue; + for (struct node_s *node = &index->map[i]; node; node = node->next) { + if (strcmp(node->data->name, query) == 0) + results_insert(results, node->data); + if (node->child) + index_lookup_substr(node->child, query, results); + } + } } void -- cgit v1.2.3