| 605 | } |
| 606 | |
| 607 | static cbm_userconfig_snapshot_status_t snapshot_entry(CBMArena *arena, cbm_userconfig_t *cfg, |
| 608 | yyjson_val *key, yyjson_val *value) { |
| 609 | if (!snapshot_string(key) || !snapshot_string(value) || yyjson_get_str(key)[0] != '.') |
| 610 | return CBM_USERCONFIG_SNAPSHOT_INVALID; |
| 611 | const char *ext = yyjson_get_str(key); |
| 612 | for (int i = 0; i < cfg->count; i++) { |
| 613 | if (strcmp(cfg->entries[i].ext, ext) == 0) |
| 614 | return CBM_USERCONFIG_SNAPSHOT_INVALID; |
| 615 | } |
| 616 | CBMLanguage language = snapshot_language(value); |
| 617 | if (language == CBM_LANG_COUNT) |
| 618 | return CBM_USERCONFIG_SNAPSHOT_UNSUPPORTED; |
| 619 | char *copy = cbm_arena_strndup(arena, ext, yyjson_get_len(key)); |
| 620 | if (!copy) |
| 621 | return CBM_USERCONFIG_SNAPSHOT_OOM; |
| 622 | cfg->entries[cfg->count++] = (cbm_userext_t){.ext = copy, .lang = language}; |
| 623 | return CBM_USERCONFIG_SNAPSHOT_OK; |
| 624 | } |
| 625 | |
| 626 | static cbm_userconfig_snapshot_status_t snapshot_parse(CBMArena *arena, cbm_userconfig_t *cfg) { |
| 627 | cbm_userconfig_source_t *source = cfg->project_source; |
no test coverage detected