| 376 | /* ── Persisted scope ─────────────────────────────────────────────── */ |
| 377 | |
| 378 | char *cbm_doclink_portable_scope(const char *scope) { |
| 379 | if (!scope) { |
| 380 | return NULL; |
| 381 | } |
| 382 | for (size_t i = 0; i < sizeof(DOCLINK_LANGS) / sizeof(DOCLINK_LANGS[0]); i++) { |
| 383 | const doclink_lang_t *L = &DOCLINK_LANGS[i]; |
| 384 | if (!L->scope_tag || !L->portable_scope) { |
| 385 | continue; |
| 386 | } |
| 387 | size_t tl = strlen(L->scope_tag); |
| 388 | if (strncmp(scope, L->scope_tag, tl) == 0 && (scope[tl] == '\n' || scope[tl] == '\0')) { |
| 389 | return L->portable_scope(scope); |
| 390 | } |
| 391 | } |
| 392 | return cbm_mem_strdup(CBM_MEM_CLASS_OTHER, scope); |
| 393 | } |
| 394 | |
| 395 | /* ── Driver ──────────────────────────────────────────────────────── */ |
| 396 | |