| 188 | } |
| 189 | |
| 190 | char *cbm_str_strip_ext(CBMArena *a, const char *path) { |
| 191 | if (!path) { |
| 192 | return NULL; |
| 193 | } |
| 194 | const char *dot = NULL; |
| 195 | const char *slash = NULL; |
| 196 | for (const char *p = path; *p; p++) { |
| 197 | if (*p == '.') { |
| 198 | dot = p; |
| 199 | } |
| 200 | if (*p == '/') { |
| 201 | slash = p; |
| 202 | } |
| 203 | } |
| 204 | if (!dot || (slash && dot < slash)) { |
| 205 | return cbm_arena_strdup(a, path); |
| 206 | } |
| 207 | return cbm_arena_strndup(a, path, (size_t)(dot - path)); |
| 208 | } |
| 209 | |
| 210 | char **cbm_str_split(CBMArena *a, const char *s, char delim, int *out_count) { |
| 211 | if (!s || !out_count) { |
no test coverage detected