Serialize collected regions as "start-end,start-end,...", with a trailing * ",+ " when the cap threw N ranges away. * * The marker must stay a SUFFIX and nothing else. Every reader stops at the * first token that is not a range, so a marker in the middle of a string * silently hides everything after it. objectscript_export_append_error_ranges * strips markers before joining two parts for e
| 1590 | * macro rules run after collection and remove ranges the cap never saw. That |
| 1591 | * still reports honestly: the cap bound, so what was lost is unknown. */ |
| 1592 | static const char *cbm_error_ranges_str(CBMArena *a, const cbm_error_regions_t *regs) { |
| 1593 | if (regs->count <= 0 && regs->dropped <= 0) { |
| 1594 | return NULL; |
| 1595 | } |
| 1596 | enum { RANGE_MAX = 24 }; /* "4294967295-4294967295," */ |
| 1597 | char *buf = (char *)cbm_arena_alloc(a, (size_t)(regs->count + 1) * RANGE_MAX); |
| 1598 | if (!buf) { |
| 1599 | return NULL; |
| 1600 | } |
| 1601 | size_t off = 0; |
| 1602 | for (int i = 0; i < regs->count; i++) { |
| 1603 | off += (size_t)snprintf(buf + off, RANGE_MAX, "%s%u-%u", i ? "," : "", regs->starts[i], |
| 1604 | regs->ends[i]); |
| 1605 | } |
| 1606 | if (regs->dropped > 0) { |
| 1607 | snprintf(buf + off, RANGE_MAX, "%s+%d", off ? "," : "", regs->dropped); |
| 1608 | } |
| 1609 | return buf; |
| 1610 | } |
| 1611 | |
| 1612 | /* Public entry: run the extraction and journal completion. The DONE mark on |
| 1613 | * every ordinary return (including error/timeout results) tells the crash |
no test coverage detected