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

Function adr_reported

internal/cbm/doc_adr.c:1112–1153  ·  view source on GitHub ↗

Another record is the phrase's subject (`ADR 0239 supersedes ADR 0203`, a * table cell `0259 (supersedes ADR 0114's ...)`, a link to a record before * it): this record reports that record's relation and states none of its * own. Its own number as the subject is its own statement. */

Source from the content-addressed store, hash-verified

1110 * it): this record reports that record's relation and states none of its
1111 * own. Its own number as the subject is its own statement. */
1112static bool adr_reported(const adr_doc_t *d, const adr_line_t *l, int i) {
1113 int k = i;
1114 while (k > 0 &&
1115 (adr_blank(l->s[k - SKIP_ONE]) || l->s[k - SKIP_ONE] == '(' ||
1116 l->s[k - SKIP_ONE] == '*' || l->s[k - SKIP_ONE] == '_' || l->s[k - SKIP_ONE] == '`')) {
1117 k--;
1118 }
1119 if (k >= PAIR_LEN && l->s[k - SKIP_ONE] == ')') {
1120 for (int o = k - PAIR_LEN; o > 0; o--) { /* `[text](destination)` */
1121 if (l->s[o] == '(') {
1122 return l->s[o - SKIP_ONE] == ']';
1123 }
1124 if (l->s[o] == ')' || adr_blank(l->s[o])) {
1125 break;
1126 }
1127 }
1128 return false;
1129 }
1130 int e = k;
1131 while (k > 0 && adr_digit(l->s[k - SKIP_ONE])) {
1132 k--;
1133 }
1134 if (e == k || (k > 0 && adr_alpha(l->s[k - SKIP_ONE]))) {
1135 return false;
1136 }
1137 size_t used = 0;
1138 unsigned v = 0;
1139 if (!adr_number_at(l->s + k, (size_t)(e - k), &used, &v)) {
1140 return false;
1141 }
1142 unsigned ref = 0;
1143 size_t len = 0;
1144 bool id = k >= PAIR_LEN * PAIR_LEN &&
1145 adr_id_ref(l->s + k - PAIR_LEN * PAIR_LEN, (size_t)(e - k) + PAIR_LEN * PAIR_LEN,
1146 &ref, &len) &&
1147 len == (size_t)(e - k) + PAIR_LEN * PAIR_LEN;
1148 /* a bare number is a record's only when padded like one (`0259`) */
1149 if (!id && e - k < ADR_PADDED_DIGITS) {
1150 return false;
1151 }
1152 return !(d->numbered && v == d->number);
1153}
1154
1155/* A record reference right after the phrase (past a colon, a table bar and
1156 * emphasis): a link or an ADR id, `Supersedes: [ADR-3](0003-x.md)`,

Callers 1

adr_relationsFunction · 0.85

Calls 5

adr_blankFunction · 0.85
adr_digitFunction · 0.85
adr_alphaFunction · 0.85
adr_number_atFunction · 0.85
adr_id_refFunction · 0.85

Tested by

no test coverage detected