| 1968 | } |
| 1969 | |
| 1970 | static const cbm_gbuf_node_t *resolve_header_include(const cbm_pipeline_ctx_t *ctx, |
| 1971 | const char *source_rel, |
| 1972 | const char *source_file_qn, |
| 1973 | const char *module_path) { |
| 1974 | if (!is_c_family_source(source_rel) || !is_header_include(module_path)) { |
| 1975 | return NULL; |
| 1976 | } |
| 1977 | |
| 1978 | const char *base = module_path; |
| 1979 | if (base[0] == '.' && base[1] == '/') { |
| 1980 | base += 2; |
| 1981 | } |
| 1982 | |
| 1983 | const cbm_gbuf_node_t *exact = resolve_exact_file_node(ctx, base, source_file_qn); |
| 1984 | if (exact) { |
| 1985 | return exact; |
| 1986 | } |
| 1987 | |
| 1988 | if (source_rel && source_rel[0]) { |
| 1989 | char *dir = path_dirname(source_rel); |
| 1990 | if (dir) { |
| 1991 | char candidate[PKGMAP_PATH_BUF]; |
| 1992 | if (dir[0]) { |
| 1993 | snprintf(candidate, sizeof(candidate), "%s/%s", dir, base); |
| 1994 | } else { |
| 1995 | snprintf(candidate, sizeof(candidate), "%s", base); |
| 1996 | } |
| 1997 | free(dir); |
| 1998 | exact = resolve_exact_file_node(ctx, candidate, source_file_qn); |
| 1999 | if (exact) { |
| 2000 | return exact; |
| 2001 | } |
| 2002 | } |
| 2003 | } |
| 2004 | |
| 2005 | return NULL; |
| 2006 | } |
| 2007 | |
| 2008 | /* Resolve a sibling-file import: a bare path/name (no leading "./") that names |
| 2009 | * a file relative to the importer's directory. This covers build/markup |
no test coverage detected