--- src/dotconf.c.old 2002-10-03 17:33:38.000000000 +0200 +++ src/dotconf.c 2002-10-03 17:50:50.000000000 +0200 @@ -593,7 +593,12 @@ const char *context_error; /* error message returned by contextchecker */ command_t command; /* command structure */ int mod = 0; - int next_opt_idx = 0; + int done = 0; + + const configoption_t *option; + int opt_idx = 0; + + option = 0; memset(&command, 0, sizeof(command_t)); name[0] = 0; @@ -617,57 +622,53 @@ cp2 = name; copy_word(&cp2, &cp1, MIN(eob - cp1, CFG_MAX_OPTION), 0); - while (1) { - const configoption_t *option; - int done = 0; - int opt_idx = 0; - - for (option = 0; configfile->config_options[mod] && !done; mod++) { - for (opt_idx = next_opt_idx; configfile->config_options[mod][opt_idx].name[0]; opt_idx++) { - if (!configfile->cmp_func(name, configfile->config_options[mod][opt_idx].name, CFG_MAX_OPTION)) { - /* TODO: this could be flagged: option overwriting by modules */ - option = (configoption_t *) &configfile->config_options[mod][opt_idx]; - done = 1; - break; /* found one; break out */ - } - } - } - if (!option) - option = get_argname_fallback(configfile->config_options[1]); - - if (!option || !option->callback) { - if (error) - return error; - dotconf_warning(configfile, DCLOG_INFO, ERR_UNKNOWN_OPTION, - "Unknown Config-Option: '%s'", name); - return NULL; - } + for (mod = 0; configfile->config_options[mod] && !done; mod++) { + for (opt_idx = 0; configfile->config_options[mod][opt_idx].name[0] && !done; opt_idx++) { + if (configfile->cmp_func(name, configfile->config_options[mod][opt_idx].name, CFG_MAX_OPTION)) { + /* TODO: this could be flagged: option overwriting by modules */ + continue; /* not the right one, next. */ + } + /* set up the option */ + option = (configoption_t *) &configfile->config_options[mod][opt_idx]; - /* set up the command structure (contextchecker wants this) */ - dotconf_set_command(configfile, option, cp1, &command); + /* set up the command structure (contextchecker wants this) */ + dotconf_set_command(configfile, option, cp1, &command); - if (configfile->contextchecker) - context_error = configfile->contextchecker(&command, command.option->context); + if (configfile->contextchecker) + context_error = configfile->contextchecker(&command, command.option->context); - if (!context_error) - error = dotconf_invoke_command(configfile, &command); - else { - if (!error) { - /* avoid returning another error then the first. This makes it easier to - reproduce problems. */ - error = context_error; + if (!context_error) + error = dotconf_invoke_command(configfile, &command); + else { + if (!error) { + /* avoid returning another error then the first. This makes it easier to + reproduce problems. */ + error = context_error; + } } - } - dotconf_free_command(&command); + dotconf_free_command(&command); - if (!context_error || !(configfile->flags & DUPLICATE_OPTION_NAMES)) { - /* don't try more, just quit now. */ - break; + if (!context_error || !(configfile->flags & DUPLICATE_OPTION_NAMES)) { + /* don't try more, just quit now. */ + done = 1; + } } } + if (!option) + option = get_argname_fallback(configfile->config_options[1]); + + if (!option || !option->callback) { + if (error) + return error; + dotconf_warning(configfile, DCLOG_INFO, ERR_UNKNOWN_OPTION, + "Unknown Config-Option: '%s'", name); + return NULL; + } + + return error; }