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

Function resolve_backslash_prefix

src/pipeline/pass_pkgmap.c:1085–1115  ·  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

1083/* Try backslash-based prefix matching (PHP PSR-4: App\\Controllers\\Foo).
1084 * Returns heap QN or NULL. */
1085static char *resolve_backslash_prefix(CBMHashTable *map, const char *module_path,
1086 const char *project_name) {
1087 char *buf = strdup(module_path);
1088 if (!buf) {
1089 return NULL;
1090 }
1091 for (char *bs = buf + strlen(buf) - SKIP_ONE; bs > buf; bs--) {
1092 if (*bs != '\\') {
1093 continue;
1094 }
1095 *bs = '\0';
1096 char prefix[PKGMAP_PATH_BUF];
1097 snprintf(prefix, sizeof(prefix), "%s\\", buf);
1098 const char *base_dir = (const char *)cbm_ht_get(map, prefix);
1099 if (!base_dir) {
1100 continue;
1101 }
1102 const char *subpath = module_path + (size_t)(bs - buf) + SKIP_ONE;
1103 char path_result[PKGMAP_PATH_BUF];
1104 snprintf(path_result, sizeof(path_result), "%s/%s", base_dir, subpath);
1105 for (char *c = path_result; *c; c++) {
1106 if (*c == '\\') {
1107 *c = '/';
1108 }
1109 }
1110 free(buf);
1111 return cbm_pipeline_fqn_module(project_name, path_result);
1112 }
1113 free(buf);
1114 return NULL;
1115}
1116
1117char *cbm_pipeline_resolve_module(const cbm_pipeline_ctx_t *ctx, const char *source_rel,
1118 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