| 1462 | } |
| 1463 | |
| 1464 | char *cbm_fqn_module_source_lang(CBMArena *a, const char *project, const char *rel_path, |
| 1465 | CBMLanguage lang) { |
| 1466 | if (!cbm_lang_module_is_dir(lang)) { |
| 1467 | // All other languages keep the legacy filename-stem module QN. |
| 1468 | return cbm_fqn_module(a, project, rel_path); |
| 1469 | } |
| 1470 | if (!rel_path) { |
| 1471 | rel_path = ""; |
| 1472 | } |
| 1473 | // Module is the CONTAINING DIRECTORY: strip the basename (last '/' segment). |
| 1474 | const char *last_slash = strrchr(rel_path, '/'); |
| 1475 | if (!last_slash) { |
| 1476 | // Root file: dir is empty → module is just the project. |
| 1477 | return cbm_fqn_folder(a, project, ""); |
| 1478 | } |
| 1479 | size_t dir_len = (size_t)(last_slash - rel_path); |
| 1480 | char *dir = (char *)cbm_arena_alloc(a, dir_len + SKIP_ONE); |
| 1481 | if (!dir) { |
| 1482 | return NULL; |
| 1483 | } |
| 1484 | memcpy(dir, rel_path, dir_len); |
| 1485 | dir[dir_len] = '\0'; |
| 1486 | return cbm_fqn_folder(a, project, dir); |
| 1487 | } |
| 1488 | |
| 1489 | char *cbm_fqn_compute_source_lang(CBMArena *a, const char *project, const char *rel_path, |
| 1490 | const char *name, CBMLanguage lang) { |
no test coverage detected