stop the call duplication inside config_assign()

svn:r5045
This commit is contained in:
Roger Dingledine 2005-09-14 02:35:06 +00:00
parent 6aa8850d90
commit 93be26a74a

View File

@ -873,7 +873,7 @@ config_assign_value(config_format_t *fmt, or_options_t *options,
*/
static int
config_assign_line(config_format_t *fmt, or_options_t *options,
config_line_t *c, int use_defaults)
config_line_t *c, int use_defaults, int clear_first)
{
config_var_t *var;
@ -891,7 +891,8 @@ config_assign_line(config_format_t *fmt, or_options_t *options,
}
if (!strlen(c->value)) { /* reset or clear it, then return */
option_reset(fmt, options, var, use_defaults);
if (!clear_first) /* not already cleared */
option_reset(fmt, options, var, use_defaults);
return 0;
}
@ -1077,7 +1078,7 @@ There are three call cases for config_assign() currently.
Case one: Torrc entry
options_init_from_torrc() calls config_assign(0, 0)
calls config_assign_line(0).
calls config_assign_line(0, 0).
if value is empty, calls option_reset(0) and returns.
calls config_assign_value(), appends.
@ -1086,8 +1087,8 @@ options_trial_assign() calls config_assign(0, 1)
calls config_reset_line(0)
calls option_reset(0)
calls option_clear().
calls config_assign_line(0).
if value is empty, calls option_reset(0) and returns.
calls config_assign_line(0, 1).
if value is empty, returns.
calls config_assign_value(), appends.
Case three: resetconf
@ -1096,8 +1097,8 @@ options_trial_assign() calls config_assign(1, 1)
calls option_reset(1)
calls option_clear().
calls config_assign_value(default)
calls config_assign_line(1).
calls option_reset(1) and returns.
calls config_assign_line(1, 1).
returns.
*/
static int
config_assign(config_format_t *fmt, void *options,
@ -1126,7 +1127,7 @@ config_assign(config_format_t *fmt, void *options,
/* pass 3: assign. */
while (list) {
int r;
if ((r=config_assign_line(fmt, options, list, use_defaults)))
if ((r=config_assign_line(fmt, options, list, use_defaults, clear_first)))
return r;
list = list->next;
}