Try dot-based prefix matching (Java: com.myorg.pkg.Foo). * Returns heap QN or NULL. */
| 1049 | /* Try dot-based prefix matching (Java: com.myorg.pkg.Foo). |
| 1050 | * Returns heap QN or NULL. */ |
| 1051 | static char *resolve_dot_prefix(CBMHashTable *map, const char *module_path, |
| 1052 | const char *project_name) { |
| 1053 | char *buf = strdup(module_path); |
| 1054 | if (!buf) { |
| 1055 | return NULL; |
| 1056 | } |
| 1057 | for (char *dot = buf + strlen(buf) - SKIP_ONE; dot > buf; dot--) { |
| 1058 | if (*dot != '.') { |
| 1059 | continue; |
| 1060 | } |
| 1061 | *dot = '\0'; |
| 1062 | const char *base_qn = (const char *)cbm_ht_get(map, buf); |
| 1063 | if (!base_qn) { |
| 1064 | continue; |
| 1065 | } |
| 1066 | const char *subpath = module_path + (size_t)(dot - buf) + SKIP_ONE; |
| 1067 | char subpath_slashed[PKGMAP_PATH_BUF]; |
| 1068 | snprintf(subpath_slashed, sizeof(subpath_slashed), "%s", subpath); |
| 1069 | for (char *c = subpath_slashed; *c; c++) { |
| 1070 | if (*c == '.') { |
| 1071 | *c = '/'; |
| 1072 | } |
| 1073 | } |
| 1074 | char result[PKGMAP_PATH_BUF]; |
| 1075 | snprintf(result, sizeof(result), "%s/%s", base_qn, subpath_slashed); |
| 1076 | free(buf); |
| 1077 | return cbm_pipeline_fqn_module(project_name, result); |
| 1078 | } |
| 1079 | free(buf); |
| 1080 | return NULL; |
| 1081 | } |
| 1082 | |
| 1083 | /* Try backslash-based prefix matching (PHP PSR-4: App\\Controllers\\Foo). |
| 1084 | * Returns heap QN or NULL. */ |
no test coverage detected