Quote a settings value on save when reading it back would change it.

cfg_load trims blanks around a value and takes one pair of quotes off it, so a mods_order list whose first mod's
folder name starts with a space, or a value that is itself quoted, came back different at the next start and the mod
lost its place and switch. Such values are now written in quotes; others are written as before. --probe-cfg checks it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-08 08:48:14 -05:00
parent 7f9ace35fb
commit b142b7a71a
2 changed files with 26 additions and 2 deletions

View File

@@ -129,6 +129,19 @@ int probe_cfg(void) {
got = plat_file_read(path, &got_n);
CHECK(got && !strcmp((const char *)got, "[audio]\nvolume = 90\n"), "new file: the section and the key");
free(got);
// values cfg_load would trim or unquote: mod folder names in the order list start with a space or are quoted
cfg_set("NX2NAVI_MODS_ORDER", " Lead|Tail ");
cfg_set("NX2NAVI_MODS_DISABLED", "\"Q\"");
CHECK(cfg_save_to(path) == 1 && cfg_load(path) == 1 && EQ(cfg_get("NX2NAVI_MODS_ORDER"), " Lead|Tail ") &&
EQ(cfg_get("NX2NAVI_MODS_DISABLED"), "\"Q\""), "blanks at the ends and quotes survive a save");
cfg_set("NX2NAVI_MODS_ORDER", "A|B");
CHECK(cfg_save_to(path) == 1 && cfg_load(path) == 1 && EQ(cfg_get("NX2NAVI_MODS_ORDER"), "A|B"),
"a plain value replacing a quoted one");
got = plat_file_read(path, &got_n);
CHECK(got && strstr((const char *)got, "mods_order = A|B\n") &&
strstr((const char *)got, "mods_disabled = \"\"Q\"\"\n"),
"only the values that need it are quoted");
free(got);
// Defaults table: the menu's "default" marks and Reset
const CfgMeta *m = cfg_meta("FPS60");