| 1647 | } |
| 1648 | |
| 1649 | static const cbm_gbuf_node_t *resolve_header_include(const cbm_pipeline_ctx_t *ctx, |
| 1650 | const char *source_rel, |
| 1651 | const char *source_file_qn, |
| 1652 | const char *module_path) { |
| 1653 | if (!is_c_family_source(source_rel) || !is_header_include(module_path)) { |
| 1654 | return NULL; |
| 1655 | } |
| 1656 | |
| 1657 | const char *base = module_path; |
| 1658 | if (base[0] == '.' && base[1] == '/') { |
| 1659 | base += 2; |
| 1660 | } |
| 1661 | |
| 1662 | const cbm_gbuf_node_t *exact = resolve_exact_file_node(ctx, base, source_file_qn); |
| 1663 | if (exact) { |
| 1664 | return exact; |
| 1665 | } |
| 1666 | |
| 1667 | if (source_rel && source_rel[0]) { |
| 1668 | char *dir = path_dirname(source_rel); |
| 1669 | if (dir) { |
| 1670 | char candidate[PKGMAP_PATH_BUF]; |
| 1671 | if (dir[0]) { |
| 1672 | snprintf(candidate, sizeof(candidate), "%s/%s", dir, base); |
| 1673 | } else { |
| 1674 | snprintf(candidate, sizeof(candidate), "%s", base); |
| 1675 | } |
| 1676 | free(dir); |
| 1677 | exact = resolve_exact_file_node(ctx, candidate, source_file_qn); |
| 1678 | if (exact) { |
| 1679 | return exact; |
| 1680 | } |
| 1681 | } |
| 1682 | } |
| 1683 | |
| 1684 | return NULL; |
| 1685 | } |
| 1686 | |
| 1687 | /* Resolve a sibling-file import: a bare path/name (no leading "./") that names |
| 1688 | * a file relative to the importer's directory. This covers build/markup |
no test coverage detected