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

Function ad_push

internal/cbm/doc_adoc.c:491–520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

489/* ── Tokens ──────────────────────────────────────────────────────── */
490
491static void ad_push(ad_doc_t *d, int line, int syntax, const char *raw) {
492 if (!raw) {
493 d->failed = true;
494 return;
495 }
496 CBMExtractCtx *ctx = d->ctx;
497 int lo = 0;
498 int hi = d->nheads;
499 while (lo < hi) {
500 int mid = lo + ((hi - lo) / 2);
501 if (d->heads[mid].line <= line) {
502 lo = mid + 1;
503 } else {
504 hi = mid;
505 }
506 }
507 const ad_head_t *sec = lo > 0 ? &d->heads[lo - 1] : NULL;
508 if (sec && sec->shared_qn) {
509 sec = NULL;
510 }
511 CBMDocLink link = {
512 .source_qn = sec ? sec->qn : (ctx->module_qn ? ctx->module_qn : ""),
513 .raw = raw,
514 .line = (uint32_t)line + 1,
515 .def_line = sec ? (uint32_t)sec->line + 1 : 1,
516 .syntax = (uint16_t)syntax,
517 .flags = sec ? 0 : CBM_DOCLINK_FLAG_FILE,
518 };
519 cbm_doclinks_push(&ctx->result->doc_links, ctx->arena, link);
520}
521
522/* A value of the include's attribute list (`tag=x`, `tags="a;b"`, `lines=1..5`). */
523static void ad_attrlist_value(const char *al, int n, const char *key, char *out, size_t cap) {

Callers 3

ad_includeFunction · 0.85
ad_attr_refsFunction · 0.85
ad_spansFunction · 0.85

Calls 1

cbm_doclinks_pushFunction · 0.85

Tested by

no test coverage detected