Try backslash-based prefix matching (PHP PSR-4: App\\Controllers\\Foo). * Returns heap QN or NULL. */
| 1357 | /* Try backslash-based prefix matching (PHP PSR-4: App\\Controllers\\Foo). |
| 1358 | * Returns heap QN or NULL. */ |
| 1359 | static char *resolve_backslash_prefix(CBMHashTable *map, const char *module_path, |
| 1360 | const char *project_name) { |
| 1361 | char *buf = strdup(module_path); |
| 1362 | if (!buf) { |
| 1363 | return NULL; |
| 1364 | } |
| 1365 | for (char *bs = buf + strlen(buf) - SKIP_ONE; bs > buf; bs--) { |
| 1366 | if (*bs != '\\') { |
| 1367 | continue; |
| 1368 | } |
| 1369 | *bs = '\0'; |
| 1370 | char prefix[PKGMAP_PATH_BUF]; |
| 1371 | snprintf(prefix, sizeof(prefix), "%s\\", buf); |
| 1372 | const char *base_dir = (const char *)cbm_ht_get(map, prefix); |
| 1373 | if (!base_dir) { |
| 1374 | continue; |
| 1375 | } |
| 1376 | const char *subpath = module_path + (size_t)(bs - buf) + SKIP_ONE; |
| 1377 | char path_result[PKGMAP_PATH_BUF]; |
| 1378 | snprintf(path_result, sizeof(path_result), "%s/%s", base_dir, subpath); |
| 1379 | for (char *c = path_result; *c; c++) { |
| 1380 | if (*c == '\\') { |
| 1381 | *c = '/'; |
| 1382 | } |
| 1383 | } |
| 1384 | free(buf); |
| 1385 | return cbm_pipeline_fqn_module(project_name, path_result); |
| 1386 | } |
| 1387 | free(buf); |
| 1388 | return NULL; |
| 1389 | } |
| 1390 | |
| 1391 | char *cbm_pipeline_resolve_module(const cbm_pipeline_ctx_t *ctx, const char *source_rel, |
| 1392 | const char *module_path) { |
no test coverage detected