Try backslash-based prefix matching (PHP PSR-4: App\\Controllers\\Foo). * The map value of a PSR-4 prefix is its repo-relative directory (see * cbm_pkgmap_build). Returns heap QN or NULL. */
| 1384 | * The map value of a PSR-4 prefix is its repo-relative directory (see |
| 1385 | * cbm_pkgmap_build). Returns heap QN or NULL. */ |
| 1386 | static char *resolve_backslash_prefix(CBMHashTable *map, const char *module_path, |
| 1387 | const char *project_name) { |
| 1388 | char *buf = strdup(module_path); |
| 1389 | if (!buf) { |
| 1390 | return NULL; |
| 1391 | } |
| 1392 | for (char *bs = buf + strlen(buf) - SKIP_ONE; bs > buf; bs--) { |
| 1393 | if (*bs != '\\') { |
| 1394 | continue; |
| 1395 | } |
| 1396 | *bs = '\0'; |
| 1397 | char prefix[PKGMAP_PATH_BUF]; |
| 1398 | snprintf(prefix, sizeof(prefix), "%s\\", buf); |
| 1399 | const char *base_dir = (const char *)cbm_ht_get(map, prefix); |
| 1400 | if (!base_dir) { |
| 1401 | continue; |
| 1402 | } |
| 1403 | const char *subpath = module_path + (size_t)(bs - buf) + SKIP_ONE; |
| 1404 | char path_result[PKGMAP_PATH_BUF]; |
| 1405 | snprintf(path_result, sizeof(path_result), "%s%s%s", base_dir, base_dir[0] ? "/" : "", |
| 1406 | subpath); |
| 1407 | for (char *c = path_result; *c; c++) { |
| 1408 | if (*c == '\\') { |
| 1409 | *c = '/'; |
| 1410 | } |
| 1411 | } |
| 1412 | free(buf); |
| 1413 | return cbm_pipeline_fqn_module(project_name, path_result); |
| 1414 | } |
| 1415 | free(buf); |
| 1416 | return NULL; |
| 1417 | } |
| 1418 | |
| 1419 | char *cbm_pipeline_resolve_module(const cbm_pipeline_ctx_t *ctx, const char *source_rel, |
| 1420 | const char *module_path) { |
no test coverage detected