| 43 | } |
| 44 | |
| 45 | int cbm_split_camel_case(const char *s, char **out, int max_out) { |
| 46 | if (!s || !out || max_out <= 0) { |
| 47 | return 0; |
| 48 | } |
| 49 | size_t len = strlen(s); |
| 50 | if (len == 0) { |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | int count = 0; |
| 55 | size_t start = 0; |
| 56 | |
| 57 | for (size_t i = SKIP_ONE; i < len; i++) { |
| 58 | if (s[i] >= 'A' && s[i] <= 'Z' && s[i - SKIP_ONE] >= 'a' && s[i - SKIP_ONE] <= 'z') { |
| 59 | if (count < max_out) { |
| 60 | out[count] = cbm_strndup(s + start, i - start); |
| 61 | count++; |
| 62 | } |
| 63 | start = i; |
| 64 | } |
| 65 | } |
| 66 | /* Emit remaining */ |
| 67 | if (count < max_out) { |
| 68 | out[count] = cbm_strndup(s + start, len - start); |
| 69 | count++; |
| 70 | } |
| 71 | return count; |
| 72 | } |
| 73 | |
| 74 | /* Strip decorator syntax: leading @, #[...], and arguments (...). |
| 75 | * Operates in-place on buf. Returns pointer to the cleaned token start. */ |
no test coverage detected