Helper: get last path component as local name. Recognizes every separator used across the supported import syntaxes: '/' (Go / TS / JS paths), '.' (Java / Kotlin / C# / Python dotted names), '::' (Rust / C++ scope), '\\' (PHP namespaces). The last separator of any kind wins, so "std::collections::HashMap" → "HashMap" and "App\\Http\\Controller" → "Controller".
| 92 | // kind wins, so "std::collections::HashMap" → "HashMap" and |
| 93 | // "App\\Http\\Controller" → "Controller". |
| 94 | static const char *path_last(CBMArena *a, const char *path) { |
| 95 | if (!path) { |
| 96 | return NULL; |
| 97 | } |
| 98 | const char *last_sep = NULL; |
| 99 | for (const char *p = path; *p; p++) { |
| 100 | if (*p == '/' || *p == '.' || *p == ':' || *p == '\\') { |
| 101 | last_sep = p; |
| 102 | } |
| 103 | } |
| 104 | if (last_sep) { |
| 105 | return cbm_arena_strdup(a, last_sep + SKIP_ONE); |
| 106 | } |
| 107 | return path; |
| 108 | } |
| 109 | |
| 110 | /* An unaliased dotted Python import binds its first component, not its last: |
| 111 | * `import xml.etree` introduces `xml`. Keep module_path intact for dependency |
no test coverage detected