Try slash-based prefix matching (Go: github.com/foo/bar/pkg/utils). * Returns heap QN or NULL. */
| 1317 | /* Try slash-based prefix matching (Go: github.com/foo/bar/pkg/utils). |
| 1318 | * Returns heap QN or NULL. */ |
| 1319 | static char *resolve_slash_prefix(CBMHashTable *map, const char *module_path) { |
| 1320 | char *buf = strdup(module_path); |
| 1321 | if (!buf) { |
| 1322 | return NULL; |
| 1323 | } |
| 1324 | for (char *slash = buf + strlen(buf) - SKIP_ONE; slash > buf; slash--) { |
| 1325 | if (*slash != '/') { |
| 1326 | continue; |
| 1327 | } |
| 1328 | *slash = '\0'; |
| 1329 | const char *base_qn = (const char *)cbm_ht_get(map, buf); |
| 1330 | if (!base_qn) { |
| 1331 | continue; |
| 1332 | } |
| 1333 | const char *subpath = module_path + (size_t)(slash - buf) + SKIP_ONE; |
| 1334 | char result[PKGMAP_PATH_BUF]; |
| 1335 | snprintf(result, sizeof(result), "%s.%s", base_qn, subpath); |
| 1336 | /* Replace / with . in the appended part */ |
| 1337 | for (char *c = result + strlen(base_qn) + SKIP_ONE; *c; c++) { |
| 1338 | if (*c == '/') { |
| 1339 | *c = '.'; |
| 1340 | } |
| 1341 | } |
| 1342 | free(buf); |
| 1343 | return strdup(result); |
| 1344 | } |
| 1345 | free(buf); |
| 1346 | return NULL; |
| 1347 | } |
| 1348 | |
| 1349 | /* Try dot-based prefix matching (Java: com.myorg.pkg.Foo). |
| 1350 | * Returns heap QN or NULL. */ |
no test coverage detected