mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 02:09:57 -04:00
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:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user