| 374 | }; |
| 375 | |
| 376 | inline int FuzzySearch(const char* needle, void* data) |
| 377 | { |
| 378 | const auto& items = *static_cast<std::vector<std::string>*>(data); |
| 379 | for (int i = 0; i < static_cast<int>(items.size()); i++) |
| 380 | { |
| 381 | const auto haystack = items[i].c_str(); |
| 382 | // empty |
| 383 | if (!needle[0]) |
| 384 | { |
| 385 | if (!haystack[0]) |
| 386 | return i; |
| 387 | continue; |
| 388 | } |
| 389 | // exact match |
| 390 | if (strstr(haystack, needle)) |
| 391 | return i; |
| 392 | // fuzzy match |
| 393 | if (ISTRSTR(haystack, needle)) |
| 394 | return i; |
| 395 | } |
| 396 | return -1; |
| 397 | } |
| 398 | |
| 399 | static bool itemsGetter(void* data, const int n, const char** out_str) |
| 400 | { |
no test coverage detected