1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-30 03:26:23 -04:00

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.
(cherry picked from commit 6bd961246a)
This commit is contained in:
Kalle Olavi Niemitalo 2008-02-03 19:00:48 +02:00 committed by Kalle Olavi Niemitalo
parent b2c11e21c9
commit 841153b625
3 changed files with 16 additions and 4 deletions

View File

@ -980,6 +980,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);

View File

@ -742,6 +742,19 @@ unmark_options_tree(struct list_head *tree)
}
}
void
untouch_options(struct list_head *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(struct list_head *options)
{
@ -844,10 +857,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;
}
}

View File

@ -151,6 +151,7 @@ extern void register_change_hooks(struct change_hook_info *change_hooks);
extern struct list_head *init_options_tree(void);
extern void unmark_options_tree(struct list_head *);
extern void untouch_options(struct list_head *);
extern void smart_config_string(struct string *, int, int, struct list_head *, unsigned char *, int,
void (*)(struct string *, struct option *, unsigned char *, int, int, int, int));