summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9e7ef91)
raw | patch | inline | side by side (parent: 9e7ef91)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 17 Apr 2020 08:20:20 +0000 (12:20 +0400) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 17 Apr 2020 08:20:20 +0000 (12:20 +0400) |
src/config.c | patch | blob | history | |
src/config.h | patch | blob | history | |
src/sdl/main.c | patch | blob | history | |
src/sdl2/main.c | patch | blob | history |
diff --git a/src/config.c b/src/config.c
index 885a0e4b8aeee0b998c6d0e270c114b38939235a..ed611c3b47772c3525f4ebaa2daf7588501c72fa 100644 (file)
--- a/src/config.c
+++ b/src/config.c
return entry->t == 0 ? 0 : 1;
}
-int CFG_update_config (const char *old, const char *new, const cfg_t *cfg, const char *msg) {
+int CFG_update_config (const char *old, const char *new, int n, const cfg_t **cfg, const char *msg) {
assert(old != NULL);
assert(new != NULL);
+ assert(n >= 0);
assert(cfg != NULL);
+ int i, j;
char key[64];
char value[64];
FILE *nf = fopen(new, "wb");
@@ -224,15 +226,21 @@ int CFG_update_config (const char *old, const char *new, const cfg_t *cfg, const
}
if (CFG_open_iterator(old)) {
while (CFG_scan_iterator(key, 64, value, 64)) {
- if (CFG_find_entry(key, cfg) == NULL) {
+ i = 0;
+ while (i < n && CFG_find_entry(key, cfg[i]) == NULL) {
+ i++;
+ }
+ if (i >= n) {
CFG_write_key_value(nf, key, value);
}
}
CFG_close_iterator();
}
- int i = 0;
- while (CFG_write_entry(nf, &cfg[i])) {
- i++;
+ for (j = 0; j < n; j++) {
+ i = 0;
+ while (CFG_write_entry(nf, &cfg[j][i])) {
+ i++;
+ }
}
fclose(nf);
}
diff --git a/src/config.h b/src/config.h
index 29d17d71497f1e93ed3f7f9d71732c7daed4a732..c666722c9c2d61029394593981bb28faacf311ff 100644 (file)
--- a/src/config.h
+++ b/src/config.h
void CFG_close_iterator (void);
int CFG_read_config (const char *name, const cfg_t *cfg);
-int CFG_update_config (const char *old, const char *new, const cfg_t *cfg, const char *msg);
+int CFG_update_config (const char *old, const char *new, int n, const cfg_t **cfg, const char *msg);
#endif /* CONFIG_H_INCLUDED */
diff --git a/src/sdl/main.c b/src/sdl/main.c
index 2df46b3fb96cdc76a92b6e799f72878b45493c2f..a440844bc274744a8556da2b370e14e3f59fec15 100644 (file)
--- a/src/sdl/main.c
+++ b/src/sdl/main.c
}
static void CFG_save (void) {
- CFG_update_config("doom2d.cfg", "doom2d.cfg", cfg, "generated by doom2d, do not modify");
+ const cfg_t *list[] = { &cfg, NULL };
+ CFG_update_config("doom2d.cfg", "doom2d.cfg", 1, list, "generated by doom2d, do not modify");
//CFG_update_config("doom2d.cfg", "doom2d.tmp", cfg, "temporary file");
//CFG_update_config("doom2d.tmp", "doom2d.cfg", cfg, "generated by doom2d, do not modify");
//remove("doom2d.tmp");
diff --git a/src/sdl2/main.c b/src/sdl2/main.c
index ae80fe9d6dd8c62f8993994620a0204fe846943d..37b4c26334bfdd97514161b68610c5152d2fb18b 100644 (file)
--- a/src/sdl2/main.c
+++ b/src/sdl2/main.c
}
static void CFG_save (void) {
- CFG_update_config("doom2d.cfg", "doom2d.cfg", cfg, "generated by doom2d, do not modify");
+ const cfg_t *list[] = { &cfg, NULL };
+ CFG_update_config("doom2d.cfg", "doom2d.cfg", 1, list, "generated by doom2d, do not modify");
//CFG_update_config("doom2d.cfg", "doom2d.tmp", cfg, "temporary file");
//CFG_update_config("doom2d.tmp", "doom2d.cfg", cfg, "generated by doom2d, do not modify");
//remove("doom2d.tmp");