Otherwise we end up uninitialized clists and other nasty stuff. (The problems
were rarely visible, but the recent changes to conf-input.c have caused some
extra commits, which crashed when no configuration was loaded.)
This is a departure from the behavior of LibUCW 3.12, but I think we should
guarantee that after cf_getopt(), the configuration is always in a consistent
state, meaning that it has been initialized and committed. This should not
depend on whether the default config file was loaded or not.
On the other hand, program which avoid cf_getopt() and call cf_load() are on
their own, there is no implicit commit for them yet. Maybe this should be
fixed, too.
#define DEFAULT_CONFIG NULL
#endif
char *cf_def_file = DEFAULT_CONFIG;
+static int cf_def_loaded;
#ifndef ENV_VAR_CONFIG
#define ENV_VAR_CONFIG NULL
if (!err) {
cf_journal_commit_transaction(1, oldj);
cf_remember_entry(CE_FILE, file);
- cf_def_file = NULL;
+ cf_def_loaded = 1;
} else
cf_journal_rollback_transaction(1, oldj);
return err;
static void
load_default(void)
{
+ if (cf_def_loaded++)
+ return;
if (cf_def_file)
{
char *env;
}
else
{
- // We need to create an empty pool
- cf_journal_commit_transaction(1, cf_journal_new_transaction(1));
+ // We need to create an empty pool and initialize all configuration items
+ struct cf_journal_item *oldj = cf_journal_new_transaction(1);
+ cf_init_stack();
+ done_stack();
+ cf_journal_commit_transaction(1, oldj);
}
}