| 1535 | } |
| 1536 | |
| 1537 | static void rst_inline(rst_doc_t *d) { |
| 1538 | int i = 0; |
| 1539 | while (i < d->n && !d->failed) { |
| 1540 | if (!rst_inline_kind(d->K[i])) { |
| 1541 | i++; |
| 1542 | continue; |
| 1543 | } |
| 1544 | int j = i; |
| 1545 | int len = 0; |
| 1546 | while (j < d->n && rst_inline_kind(d->K[j])) { |
| 1547 | len += d->L[j].len + 1; |
| 1548 | j++; |
| 1549 | } |
| 1550 | rst_run_t r = {.a = i, .nlines = j - i}; |
| 1551 | r.text = (char *)cbm_arena_alloc(d->scratch, (size_t)len + 1); |
| 1552 | r.mask = (char *)cbm_arena_alloc(d->scratch, (size_t)len + 1); |
| 1553 | r.offs = (int *)cbm_arena_alloc(d->scratch, (size_t)(j - i) * sizeof(int)); |
| 1554 | if (!r.text || !r.mask || !r.offs) { |
| 1555 | d->failed = true; |
| 1556 | return; |
| 1557 | } |
| 1558 | int pos = 0; |
| 1559 | for (int k = i; k < j; k++) { |
| 1560 | r.offs[k - i] = pos; |
| 1561 | memcpy(r.text + pos, d->L[k].s, (size_t)d->L[k].len); |
| 1562 | pos += d->L[k].len; |
| 1563 | if (k + 1 < j) { |
| 1564 | r.text[pos++] = '\n'; |
| 1565 | } |
| 1566 | } |
| 1567 | r.text[pos] = '\0'; |
| 1568 | r.len = pos; |
| 1569 | memcpy(r.mask, r.text, (size_t)pos + 1); |
| 1570 | rst_literals(d, &r); |
| 1571 | rst_roles(d, &r); |
| 1572 | i = j; |
| 1573 | } |
| 1574 | } |
| 1575 | |
| 1576 | /* ── Sections ────────────────────────────────────────────────────── */ |
| 1577 |
no test coverage detected