MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / resolve_backslash_prefix

Function resolve_backslash_prefix

src/pipeline/pass_pkgmap.c:1386–1417  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

1384 * The map value of a PSR-4 prefix is its repo-relative directory (see
1385 * cbm_pkgmap_build). Returns heap QN or NULL. */
1386static 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
1419char *cbm_pipeline_resolve_module(const cbm_pipeline_ctx_t *ctx, const char *source_rel,
1420 const char *module_path) {

Callers 1

Calls 2

cbm_ht_getFunction · 0.85
cbm_pipeline_fqn_moduleFunction · 0.85

Tested by

no test coverage detected