| 623 | } |
| 624 | |
| 625 | static bool ti_resolve_include(cbm_ti_source_t *s, CBMHashTable *suffixes, const ti_ints_t *lists, |
| 626 | int from, const char *inc, size_t inc_len) { |
| 627 | char *normal = ti_normalize_join(&s->arena, s->files[from].path, inc, inc_len); |
| 628 | if (!normal) { |
| 629 | return false; |
| 630 | } |
| 631 | int direct = cbm_ti_source_find(s, normal); |
| 632 | if (direct >= 0) { |
| 633 | return ti_add_includer(s, direct, from); |
| 634 | } |
| 635 | size_t skip = 0; |
| 636 | while (skip < inc_len && (inc[skip] == '.' || inc[skip] == '/')) { |
| 637 | skip++; |
| 638 | } |
| 639 | char *key = cbm_arena_strndup(&s->arena, inc + skip, inc_len - skip); |
| 640 | if (!key) { |
| 641 | return false; |
| 642 | } |
| 643 | intptr_t at = (intptr_t)cbm_ht_get(suffixes, key); |
| 644 | for (int i = 0; at && i < lists[at - 1].count; i++) { |
| 645 | if (!ti_add_includer(s, lists[at - 1].items[i], from)) { |
| 646 | return false; |
| 647 | } |
| 648 | } |
| 649 | return true; |
| 650 | } |
| 651 | |
| 652 | static bool ti_build_includes(cbm_ti_source_t *s) { |
| 653 | CBMHashTable *suffixes = cbm_ht_create_in(CBM_MEM_CLASS_EXTRACT, 0); |
no test coverage detected