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

Function sh_concat

src/pipeline/pass_shell.c:649–676  ·  view source on GitHub ↗

Concatenate the children of `n` in [from, to), source gaps included. */

Source from the content-addressed store, hash-verified

647
648/* Concatenate the children of `n` in [from, to), source gaps included. */
649static void sh_concat(sh_t *s, sh_str_t *b, TSNode n, uint32_t from, uint32_t to, bool in_dq) {
650 uint32_t pos = from;
651 for (uint32_t i = 0; i < ts_node_child_count(n) && !b->bad; i++) {
652 TSNode c = ts_node_child(n, i);
653 uint32_t cb = ts_node_start_byte(c);
654 uint32_t ce = ts_node_end_byte(c);
655 if (cb < from || ce > to) {
656 continue;
657 }
658 if (cb > pos) {
659 sh_add_unescaped(s->a, b, s->src + pos, cb - pos, in_dq);
660 }
661 if (!ts_node_is_named(c)) {
662 if (!(in_dq && strcmp(ts_node_type(c), "\"") == 0)) {
663 sh_str_add(s->a, b, s->src + cb, ce - cb);
664 }
665 } else if (sh_type(c, "string_content")) {
666 sh_add_unescaped(s->a, b, s->src + cb, ce - cb, in_dq);
667 } else {
668 const char *v = sh_eval(s, c);
669 sh_str_add(s->a, b, v, v ? strlen(v) : 0);
670 }
671 pos = ce;
672 }
673 if (pos < to && !b->bad) {
674 sh_add_unescaped(s->a, b, s->src + pos, to - pos, in_dq);
675 }
676}
677
678/* ${...}: a plain variable, an element 0, or a default (:- - := =). */
679static const char *sh_eval_expansion(sh_t *s, TSNode n) {

Callers 3

sh_eval_expansionFunction · 0.85
sh_evalFunction · 0.85
sh_image_repoFunction · 0.85

Calls 4

sh_add_unescapedFunction · 0.85
sh_str_addFunction · 0.85
sh_typeFunction · 0.85
sh_evalFunction · 0.85

Tested by

no test coverage detected