From 6bd961246ac4c5c8eb8e2de657053dca6fc13630 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 3 Feb 2008 19:00:48 +0200 Subject: [PATCH] config: Reset OPT_TOUCHED flags after a successful save. Previously, they were reset by smart_config_string(), which was not called if the value of the option was saved by rewriting an existing command in elinks.conf. Also, it is better to reset the flags only after the file operations have actually succeeded. --- src/config/conf.c | 2 ++ src/config/options.c | 17 +++++++++++++---- src/config/options.h | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/config/conf.c b/src/config/conf.c index afe485587..2dd41b8ef 100644 --- a/src/config/conf.c +++ b/src/config/conf.c @@ -982,6 +982,8 @@ write_config_file(unsigned char *prefix, unsigned char *name, if (ssi) { secure_fputs(ssi, cfg_str); ret = secure_close(ssi); + if (!ret) + untouch_options(options->value.tree); } write_config_dialog(term, config_file, secsave_errno, ret); diff --git a/src/config/options.c b/src/config/options.c index c93552bb0..e54816f2a 100644 --- a/src/config/options.c +++ b/src/config/options.c @@ -748,6 +748,19 @@ unmark_options_tree(LIST_OF(struct option) *tree) } } +void +untouch_options(LIST_OF(struct option) *tree) +{ + struct option *option; + + foreach (option, *tree) { + option->flags &= ~OPT_TOUCHED; + + if (option->type == OPT_TREE) + untouch_options(option->value.tree); + } +} + static int check_nonempty_tree(LIST_OF(struct option) *options) { @@ -851,10 +864,6 @@ smart_config_string(struct string *str, int print_comment, int i18n, fn(str, option, path, depth, /*pc*/1, 3, i18n); } - - /* TODO: We should maybe clear the touched flag only when really - * saving the stuff...? --pasky */ - option->flags &= ~OPT_TOUCHED; } } diff --git a/src/config/options.h b/src/config/options.h index 68198d9be..c1d328964 100644 --- a/src/config/options.h +++ b/src/config/options.h @@ -162,6 +162,7 @@ extern void register_change_hooks(const struct change_hook_info *change_hooks); extern LIST_OF(struct option) *init_options_tree(void); extern void unmark_options_tree(LIST_OF(struct option) *); +extern void untouch_options(LIST_OF(struct option) *); extern void smart_config_string(struct string *, int, int, LIST_OF(struct option) *, unsigned char *, int,