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);
default: op = OP_ALL;
}; break;
case 'p': op = OP_PREPEND; break;
- case 'r': op = OP_REMOVE; break;
+ case 'r': op = (c[1] && Clocase(c[2]) == 'm') ? OP_REMOVE : OP_RESET; break;
case 'e': op = OP_EDIT; break;
case 'b': op = OP_BEFORE; break;
default: op = OP_SET; break;
#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);
}
}
#endif
} else {
/* unhandled option or end of options */
- if (res != ':' && res != '?')
+ if (res != ':' && res != '?') {
load_default();
- final_commit();
+ final_commit();
+ }
other_options++;
return res;
}