| 1449 | } |
| 1450 | |
| 1451 | char *cbm_fqn_module_source_lang(CBMArena *a, const char *project, const char *rel_path, |
| 1452 | CBMLanguage lang) { |
| 1453 | if (!cbm_lang_module_is_dir(lang)) { |
| 1454 | // All other languages keep the legacy filename-stem module QN. |
| 1455 | return cbm_fqn_module(a, project, rel_path); |
| 1456 | } |
| 1457 | if (!rel_path) { |
| 1458 | rel_path = ""; |
| 1459 | } |
| 1460 | // Module is the CONTAINING DIRECTORY: strip the basename (last '/' segment). |
| 1461 | const char *last_slash = strrchr(rel_path, '/'); |
| 1462 | if (!last_slash) { |
| 1463 | // Root file: dir is empty → module is just the project. |
| 1464 | return cbm_fqn_folder(a, project, ""); |
| 1465 | } |
| 1466 | size_t dir_len = (size_t)(last_slash - rel_path); |
| 1467 | char *dir = (char *)cbm_arena_alloc(a, dir_len + SKIP_ONE); |
| 1468 | if (!dir) { |
| 1469 | return NULL; |
| 1470 | } |
| 1471 | memcpy(dir, rel_path, dir_len); |
| 1472 | dir[dir_len] = '\0'; |
| 1473 | return cbm_fqn_folder(a, project, dir); |
| 1474 | } |
| 1475 | |
| 1476 | char *cbm_fqn_compute_source_lang(CBMArena *a, const char *project, const char *rel_path, |
| 1477 | const char *name, CBMLanguage lang) { |
no test coverage detected