| 156 | } |
| 157 | |
| 158 | static bool cv_ids(cbm_coverage_map_t *map, cbm_coverage_test_t *row, const char *text, |
| 159 | bool *seen) { |
| 160 | if (!*text) { |
| 161 | return true; |
| 162 | } |
| 163 | int count = 1; |
| 164 | for (const char *p = text; *p; p++) { |
| 165 | if (*p == ' ') { |
| 166 | if (count == INT_MAX) { |
| 167 | return false; |
| 168 | } |
| 169 | count++; |
| 170 | } |
| 171 | } |
| 172 | /* A row cannot contain more unique IDs than there are function records. |
| 173 | * Allocate from actual input tokens, never from a claimed numeric ID. */ |
| 174 | if (count > map->function_count) { |
| 175 | return false; |
| 176 | } |
| 177 | int *ids = cv_array(map, count, sizeof(*ids)); |
| 178 | if (!ids) { |
| 179 | return false; |
| 180 | } |
| 181 | for (int i = 0; i < count; i++) { |
| 182 | const char *end; |
| 183 | if (!cv_decimal(text, &ids[i], &end) || ids[i] >= map->function_count || |
| 184 | (i > 0 && ids[i] <= ids[i - 1])) { |
| 185 | return false; |
| 186 | } |
| 187 | seen[ids[i]] = true; |
| 188 | if (i + 1 < count) { |
| 189 | if (*end != ' ') { |
| 190 | return false; |
| 191 | } |
| 192 | text = end + 1; |
| 193 | } else if (*end) { |
| 194 | return false; |
| 195 | } |
| 196 | } |
| 197 | row->function_ids = ids; |
| 198 | row->function_count = count; |
| 199 | return true; |
| 200 | } |
| 201 | |
| 202 | static bool cv_tests(cbm_coverage_map_t *map, char *text, bool *seen) { |
| 203 | for (int i = 0; i < map->test_count; i++) { |
no test coverage detected