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

Function resolve_backslash_prefix

src/pipeline/pass_pkgmap.c:1359–1389  ·  view source on GitHub ↗

Try backslash-based prefix matching (PHP PSR-4: App\\Controllers\\Foo). * Returns heap QN or NULL. */

Source from the content-addressed store, hash-verified

1357/* Try backslash-based prefix matching (PHP PSR-4: App\\Controllers\\Foo).
1358 * Returns heap QN or NULL. */
1359static 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
1391char *cbm_pipeline_resolve_module(const cbm_pipeline_ctx_t *ctx, const char *source_rel,
1392 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