1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05: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.
This commit is contained in:
Kalle Olavi Niemitalo 2008-02-03 19:00:48 +02:00 committed by Kalle Olavi Niemitalo
parent ab8ef9698f
commit 6bd961246a
3 changed files with 16 additions and 4 deletions

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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,