MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / mk_split_lines

Function mk_split_lines

src/pipeline/pass_shell.c:3125–3161  ·  view source on GitHub ↗

Variables and recipe lines of a makefile; `cond`: under a conditional. */ The recipe lines in the bytes of a recipe_line node, split as make splits * them: tree-sitter-make can let one node run over several lines (a quote in * `"Don't ..."` does it). */

Source from the content-addressed store, hash-verified

3123 * them: tree-sitter-make can let one node run over several lines (a quote in
3124 * `"Don't ..."` does it). */
3125static void mk_split_lines(mk_t *m, TSNode node) {
3126 const char *src = m->src;
3127 uint32_t p = ts_node_start_byte(node);
3128 uint32_t end = ts_node_end_byte(node);
3129 uint32_t row = ts_node_start_point(node).row;
3130 while (p < end) {
3131 uint32_t b = p;
3132 uint32_t brow = row;
3133 uint32_t q = p;
3134 for (;;) {
3135 while (q < end && src[q] != '\n') {
3136 q++;
3137 }
3138 uint32_t k = (q > p && src[q - SKIP_ONE] == '\r') ? q - SKIP_ONE : q;
3139 bool cont = k > p && src[k - SKIP_ONE] == '\\';
3140 if (!cont || q >= end) {
3141 break;
3142 }
3143 q++;
3144 row++;
3145 p = q;
3146 }
3147 uint32_t e = q;
3148 p = q < end ? q + SKIP_ONE : q;
3149 row++;
3150 while (e > b && src[e - SKIP_ONE] == '\r') {
3151 e--;
3152 }
3153 while (b < e && src[b] && strchr(" \t@-+", src[b])) {
3154 b++;
3155 }
3156 if (b < e && src[b] != '#' &&
3157 sh_grow((void **)&m->lines, &m->cap_lines, m->nlines, sizeof(*m->lines))) {
3158 m->lines[m->nlines++] = (mk_line_t){b, e, brow};
3159 }
3160 }
3161}
3162
3163static int mk_cmp_line(const void *a, const void *b) {
3164 uint32_t x = ((const mk_line_t *)a)->b;

Callers 1

mk_collect_oneFunction · 0.85

Calls 1

sh_growFunction · 0.85

Tested by

no test coverage detected