| 1267 | } |
| 1268 | |
| 1269 | char *cbm_fqn_module_source_lang(CBMArena *a, const char *project, const char *rel_path, |
| 1270 | CBMLanguage lang) { |
| 1271 | if (!cbm_lang_module_is_dir(lang)) { |
| 1272 | // All other languages keep the legacy filename-stem module QN. |
| 1273 | return cbm_fqn_module(a, project, rel_path); |
| 1274 | } |
| 1275 | if (!rel_path) { |
| 1276 | rel_path = ""; |
| 1277 | } |
| 1278 | // Module is the CONTAINING DIRECTORY: strip the basename (last '/' segment). |
| 1279 | const char *last_slash = strrchr(rel_path, '/'); |
| 1280 | if (!last_slash) { |
| 1281 | // Root file: dir is empty → module is just the project. |
| 1282 | return cbm_fqn_folder(a, project, ""); |
| 1283 | } |
| 1284 | size_t dir_len = (size_t)(last_slash - rel_path); |
| 1285 | char *dir = (char *)cbm_arena_alloc(a, dir_len + SKIP_ONE); |
| 1286 | if (!dir) { |
| 1287 | return NULL; |
| 1288 | } |
| 1289 | memcpy(dir, rel_path, dir_len); |
| 1290 | dir[dir_len] = '\0'; |
| 1291 | return cbm_fqn_folder(a, project, dir); |
| 1292 | } |
| 1293 | |
| 1294 | char *cbm_fqn_compute_source_lang(CBMArena *a, const char *project, const char *rel_path, |
| 1295 | const char *name, CBMLanguage lang) { |
no test coverage detected