X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fconf-input.c;h=fffc6d57e5cd5d8088755bb9c0730768c63cc421;hb=bfca2c42bc0e749f8611339568be502f22ac5e9c;hp=09d21c839c341a1af58ed0317943b7ee6159aac7;hpb=05c8c4e718cbadd9b72eff863f1e32213cfecf64;p=libucw.git diff --git a/ucw/conf-input.c b/ucw/conf-input.c index 09d21c83..fffc6d57 100644 --- a/ucw/conf-input.c +++ b/ucw/conf-input.c @@ -223,7 +223,7 @@ parse_fastbuf(const char *name_fb, struct fastbuf *fb, uns depth) else if (depth > 8) err = "Too many nested files"; else if (*line && *line != '#') // because the contents of line_buf is not re-entrant and will be cleared - err = "The input command must be the last one on a line"; + err = "The include command must be the last one on a line"; if (err) goto error; struct fastbuf *new_fb = bopen_try(pars[0], O_RDONLY, 1<<14); @@ -285,6 +285,7 @@ error: #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 @@ -408,7 +409,7 @@ cf_load(const char *file) 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; @@ -432,6 +433,8 @@ cf_set(const char *string) static void load_default(void) { + if (cf_def_loaded++) + return; if (cf_def_file) { char *env; @@ -445,8 +448,11 @@ load_default(void) } 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); } } @@ -493,9 +499,10 @@ cf_getopt(int argc, char * const argv[], const char *short_opts, const struct op #endif } else { /* unhandled option or end of options */ - if (res != ':' && res != '?') + if (res != ':' && res != '?') { load_default(); - final_commit(); + final_commit(); + } other_options++; return res; }