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
| 2803 | * macro rules run after collection and remove ranges the cap never saw. That |
| 2804 | * still reports honestly: the cap bound, so what was lost is unknown. */ |
| 2805 | static const char *cbm_error_ranges_str(CBMArena *a, const cbm_error_regions_t *regs) { |
| 2806 | if (regs->count <= 0 && regs->dropped <= 0) { |
| 2807 | return NULL; |
| 2808 | } |
| 2809 | enum { RANGE_MAX = 24 }; /* "4294967295-4294967295," */ |
| 2810 | char *buf = (char *)cbm_arena_alloc(a, (size_t)(regs->count + 1) * RANGE_MAX); |
| 2811 | if (!buf) { |
| 2812 | return NULL; |
| 2813 | } |
| 2814 | size_t off = 0; |
| 2815 | for (int i = 0; i < regs->count; i++) { |
| 2816 | off += (size_t)snprintf(buf + off, RANGE_MAX, "%s%u-%u", i ? "," : "", regs->starts[i], |
| 2817 | regs->ends[i]); |
| 2818 | } |
| 2819 | if (regs->dropped > 0) { |
| 2820 | snprintf(buf + off, RANGE_MAX, "%s+%d", off ? "," : "", regs->dropped); |
| 2821 | } |
| 2822 | return buf; |
| 2823 | } |
| 2824 | |
| 2825 | /* ── Same-file duplicate definitions: the `variants` property ────────────── |
| 2826 | * |
no test coverage detected