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

Function rs_put_node

internal/cbm/doclink_rs.c:2411–2433  ·  view source on GitHub ↗

Write an item's node field: '!' when definition `def` does not exist, does * not own its node, or has a qualified name the blob cannot carry; else the * label code and the qualified name's part after the file's item prefix. */

Source from the content-addressed store, hash-verified

2409 * not own its node, or has a qualified name the blob cannot carry; else the
2410 * label code and the qualified name's part after the file's item prefix. */
2411static void rs_put_node(rs_scan_t *s, int def, const char *name) {
2412 if (def < 0) {
2413 rs_sb_putc(&s->sb, '!');
2414 return;
2415 }
2416 const CBMDefinition *d = &s->ctx->result->defs.items[def];
2417 char code = rs_label_code(d->label);
2418 const char *qn = d->qualified_name;
2419 bool ok = code && qn && s->owner[def] && strlen(qn) > s->item_prefix_len &&
2420 memcmp(qn, s->item_prefix, s->item_prefix_len) == 0;
2421 const char *suffix = ok ? qn + s->item_prefix_len : "";
2422 if (!ok || strpbrk(suffix, "\t\n\r")) {
2423 rs_sb_putc(&s->sb, '!');
2424 return;
2425 }
2426 rs_sb_putc(&s->sb, code);
2427 if (strcmp(suffix, name) == 0) {
2428 rs_sb_putc(&s->sb, '=');
2429 } else {
2430 rs_sb_putc(&s->sb, ':');
2431 rs_sb_puts(&s->sb, suffix);
2432 }
2433}
2434
2435/* The qualified name the extractor gives the type `owner` of this file: the
2436 * parent_class of its members' definitions. */

Callers 2

rs_rec_memberFunction · 0.85
rs_item_namedFunction · 0.85

Calls 3

rs_sb_putcFunction · 0.85
rs_label_codeFunction · 0.85
rs_sb_putsFunction · 0.85

Tested by

no test coverage detected