diff options
| author | arf20 <aruizfernandez05@gmail.com> | 2025-12-08 01:26:18 +0100 |
|---|---|---|
| committer | arf20 <aruizfernandez05@gmail.com> | 2025-12-08 01:26:18 +0100 |
| commit | 0cd93eca491d9d5d402802bbf6d2fe6c529317ad (patch) | |
| tree | 6a12ddc071f8c99671accaae88b8f4071ee393d7 /index.c | |
| parent | c2977c08c4778d0dff74ca92441bc33789687947 (diff) | |
| download | arfnet2-search-0cd93eca491d9d5d402802bbf6d2fe6c529317ad.tar.gz arfnet2-search-0cd93eca491d9d5d402802bbf6d2fe6c529317ad.zip | |
fixes
Diffstat (limited to 'index.c')
| -rw-r--r-- | index.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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 |
