Try backslash-based prefix matching (PHP PSR-4: App\\Controllers\\Foo). * Returns heap QN or NULL. */
| 1083 | /* Try backslash-based prefix matching (PHP PSR-4: App\\Controllers\\Foo). |
| 1084 | * Returns heap QN or NULL. */ |
| 1085 | static 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 | |
| 1117 | char *cbm_pipeline_resolve_module(const cbm_pipeline_ctx_t *ctx, const char *source_rel, |
| 1118 | const char *module_path) { |
no test coverage detected