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

Function rs_push_token

internal/cbm/doclink_rs.c:1634–1664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1632}
1633
1634static void rs_push_token(rs_sink_t *k, const char *raw, size_t n, int syntax, uint32_t line) {
1635 static const char cut[] = "...";
1636 char buf[CBM_DOCLINK_RS_RAW_CAP];
1637 if (n >= sizeof(buf) - sizeof(cut)) {
1638 /* oversized: a prefix that can never parse as a path */
1639 n = sizeof(buf) - sizeof(cut) - SKIP_ONE;
1640 memcpy(buf, raw, n);
1641 memcpy(buf + n, cut, sizeof(cut));
1642 n += sizeof(cut) - SKIP_ONE;
1643 } else {
1644 memcpy(buf, raw, n);
1645 buf[n] = '\0';
1646 }
1647 for (size_t i = 0; i < n; i++) {
1648 if (buf[i] == '\n' || buf[i] == '\t' || buf[i] == '\r' || buf[i] == '\0') {
1649 buf[i] = ' ';
1650 }
1651 }
1652 const char *copy = cbm_arena_strndup(k->ctx->arena, buf, n);
1653 if (!copy) {
1654 return;
1655 }
1656 CBMDocLink link = {
1657 .source_qn = k->source_qn,
1658 .raw = copy,
1659 .line = line,
1660 .def_line = k->def_line,
1661 .syntax = (uint16_t)syntax,
1662 };
1663 cbm_doclinks_push(&k->ctx->result->doc_links, k->ctx->arena, link);
1664}
1665
1666/* A found link: decide whether rustdoc treats its destination as an intra-doc
1667 * link, and push the token. `defined`: the destination was written (inline)

Callers 1

rs_emit_linkFunction · 0.85

Calls 2

cbm_doclinks_pushFunction · 0.85
cbm_arena_strndupFunction · 0.70

Tested by

no test coverage detected