The doc's lines without their comment marks. */
| 111 | |
| 112 | /* The doc's lines without their comment marks. */ |
| 113 | static int c_doc_lines(CBMArena *a, const char *doc, uint32_t doc_line, c_line_t **out) { |
| 114 | int cap = SKIP_ONE; |
| 115 | for (const char *p = doc; *p; p++) { |
| 116 | cap += *p == '\n'; |
| 117 | } |
| 118 | c_line_t *lines = (c_line_t *)cbm_arena_alloc(a, (size_t)cap * sizeof(c_line_t)); |
| 119 | if (!lines) { |
| 120 | return 0; |
| 121 | } |
| 122 | int n = 0; |
| 123 | bool block = false; |
| 124 | for (const char *p = doc; n < cap;) { |
| 125 | const char *le = strchr(p, '\n'); |
| 126 | if (!le) { |
| 127 | le = p + strlen(p); |
| 128 | } |
| 129 | lines[n] = c_strip_line(p, le, n == 0, &block, doc_line + (uint32_t)n); |
| 130 | n++; |
| 131 | if (!*le) { |
| 132 | break; |
| 133 | } |
| 134 | p = le + SKIP_ONE; |
| 135 | } |
| 136 | *out = lines; |
| 137 | return n; |
| 138 | } |
| 139 | |
| 140 | /* ── Tokens ──────────────────────────────────────────────────────── */ |
| 141 |
no test coverage detected