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

Function mk_closure_include

src/pipeline/pass_shell.c:3348–3377  ·  view source on GitHub ↗

An include directive: each name -- from make's directory ($(CURDIR) is * it), or the root ($(shell git rev-parse --show-toplevel)) -- is read in * turn, recursively, where the directive stands. A name not fully known is * skipped. */

Source from the content-addressed store, hash-verified

3346 * turn, recursively, where the directive stands. A name not fully known is
3347 * skipped. */
3348static void mk_closure_include(mk_t *m, const char *names) {
3349 static const char curdir[] = "${__cbm_curdir}";
3350 static const char root[] = "${__cbm_root}";
3351 mk_closure_t *cl = m->ud;
3352 const char *p = names;
3353 for (;;) {
3354 while (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n') {
3355 p++;
3356 }
3357 size_t wl = strcspn(p, " \t\r\n");
3358 if (!wl) {
3359 return;
3360 }
3361 const char *w = cbm_arena_strndup(cl->a, p, wl);
3362 p += wl;
3363 const char *base = cl->mkdir;
3364 if (w && strncmp(w, curdir, sizeof(curdir) - SKIP_ONE) == 0) {
3365 w += sizeof(curdir) - SKIP_ONE;
3366 } else if (w && strncmp(w, root, sizeof(root) - SKIP_ONE) == 0) {
3367 w += sizeof(root) - SKIP_ONE;
3368 base = "";
3369 } else if (w && w[0] == '/') {
3370 continue;
3371 }
3372 const char *path = w && !strchr(w, '$') ? sh_join(cl->a, base, w) : NULL;
3373 if (path) {
3374 mk_closure_file(cl, path);
3375 }
3376 }
3377}
3378
3379static void mk_closure_file(mk_closure_t *cl, const char *rel) {
3380 if (cbm_ht_get(cl->seen, rel) ||

Callers

nothing calls this directly

Calls 3

sh_joinFunction · 0.85
mk_closure_fileFunction · 0.85
cbm_arena_strndupFunction · 0.50

Tested by

no test coverage detected