"supersedes" and "superseded by" are ADR words wherever they stand; * "replaces" and "replaced by" are ordinary verbs of technical prose ("this * middleware replaces the recovery described in ADR-22") and state a relation * only where they open a line or list item ("Replaces ADR-3"). */
| 1225 | * middleware replaces the recovery described in ADR-22") and state a relation |
| 1226 | * only where they open a line or list item ("Replaces ADR-3"). */ |
| 1227 | static void adr_relations(adr_doc_t *d, const char *adr_qn, char *superseded_by, size_t cap) { |
| 1228 | static const struct { |
| 1229 | const char *phrase; |
| 1230 | bool forward; |
| 1231 | bool line_head; |
| 1232 | } phrases[] = {{"superseded by", false, false}, |
| 1233 | {"replaced by", false, true}, |
| 1234 | {"supersedes", true, false}, |
| 1235 | {"replaces", true, true}}; |
| 1236 | for (int k = d->L.fm_end; k < d->L.count; k++) { |
| 1237 | const adr_line_t *l = &d->L.v[k]; |
| 1238 | if (!l->text) { |
| 1239 | continue; |
| 1240 | } |
| 1241 | for (int i = 0; i < l->n; i++) { |
| 1242 | if (i > 0 && adr_alpha(l->s[i - SKIP_ONE])) { |
| 1243 | continue; |
| 1244 | } |
| 1245 | for (size_t p = 0; p < sizeof(phrases) / sizeof(phrases[0]); p++) { |
| 1246 | size_t pl = strlen(phrases[p].phrase); |
| 1247 | if (adr_starts_ci(l->s + i, (size_t)(l->n - i), phrases[p].phrase) && |
| 1248 | (i + (int)pl == l->n || !adr_alpha(l->s[i + (int)pl])) && |
| 1249 | (!phrases[p].line_head || adr_line_head(l, i)) && |
| 1250 | !adr_label_choice(l, i, i + (int)pl)) { |
| 1251 | if (!adr_none_value(l->s + i + pl, (size_t)(l->n - i - (int)pl)) && |
| 1252 | !adr_reported(d, l, i)) { |
| 1253 | /* a statement opens its line or field and names a |
| 1254 | * record directly; the same words in running prose |
| 1255 | * are their own family (held-out audits: prose 38 of |
| 1256 | * 42 correct, statements 44 of 45) */ |
| 1257 | const char *v = l->s + i + pl; |
| 1258 | size_t vn = (size_t)(l->n - i - (int)pl); |
| 1259 | bool statement = adr_line_head(l, i) && adr_direct_ref(v, vn) && |
| 1260 | (adr_field_value(v, vn) || !adr_continuation(d, k)); |
| 1261 | uint16_t syntax = statement ? (uint16_t)CBM_DOCLINK_MD_SUPERSEDES |
| 1262 | : (uint16_t)CBM_DOCLINK_MD_SUPERSEDES_PROSE; |
| 1263 | adr_targets(d, adr_qn, v, vn, (uint32_t)(k + SKIP_ONE), phrases[p].forward, |
| 1264 | syntax, superseded_by, cap); |
| 1265 | } |
| 1266 | i += (int)pl - SKIP_ONE; |
| 1267 | break; |
| 1268 | } |
| 1269 | } |
| 1270 | } |
| 1271 | } |
| 1272 | } |
| 1273 | |
| 1274 | /* A template's choice list, `{proposed | accepted}` or `[a | b]`: the field |
| 1275 | * was never filled in. A filled-in value that kept its braces (`{proposed}`) |
no test coverage detected