diff options
-rw-r--r-- | parse.c | 15 | ||||
-rw-r--r-- | printf.c | 9 | ||||
-rw-r--r-- | printf.h | 2 |
3 files changed, 14 insertions, 12 deletions
@@ -1057,9 +1057,13 @@ fail: * Parse -fstype TYPE. */ static struct expr *parse_fstype(struct parser_state *state, int arg1, int arg2) { - if (!state->cmdline->mtab) { - cfprintf(state->cmdline->cerr, "%{er}error: %s: Couldn't parse the mount table.%{rs}\n", state->argv[0]); - return NULL; + struct cmdline *cmdline = state->cmdline; + if (!cmdline->mtab) { + cmdline->mtab = parse_bfs_mtab(); + if (!cmdline->mtab) { + cfprintf(cmdline->cerr, "%{er}error: Couldn't parse the mount table: %s.%{rs}\n\n", strerror(errno)); + return NULL; + } } return parse_unary_test(state, eval_fstype); @@ -2840,11 +2844,6 @@ struct cmdline *parse_cmdline(int argc, char *argv[]) { goto fail; } - cmdline->mtab = parse_bfs_mtab(); - if (!cmdline->mtab) { - cfprintf(cmdline->cerr, "%{wr}warning: Couldn't parse the mount table: %s.%{rs}\n\n", strerror(errno)); - } - struct parser_state state = { .cmdline = cmdline, .argv = argv + 1, @@ -443,7 +443,7 @@ static int append_literal(struct bfs_printf_directive ***tail, struct bfs_printf return 0; } -struct bfs_printf *parse_bfs_printf(const char *format, const struct cmdline *cmdline) { +struct bfs_printf *parse_bfs_printf(const char *format, struct cmdline *cmdline) { CFILE *cerr = cmdline->cerr; struct bfs_printf *command = malloc(sizeof(*command)); @@ -598,8 +598,11 @@ struct bfs_printf *parse_bfs_printf(const char *format, const struct cmdline *cm break; case 'F': if (!cmdline->mtab) { - cfprintf(cerr, "%{er}error: '%s': Couldn't parse the mount table.%{rs}\n", format); - goto directive_error; + cmdline->mtab = parse_bfs_mtab(); + if (!cmdline->mtab) { + cfprintf(cmdline->cerr, "%{er}error: Couldn't parse the mount table: %s.%{rs}\n\n", strerror(errno)); + goto directive_error; + } } directive->fn = bfs_printf_F; directive->mtab = cmdline->mtab; @@ -39,7 +39,7 @@ struct bfs_printf { * The command line. * @return The parsed printf command, or NULL on failure. */ -struct bfs_printf *parse_bfs_printf(const char *format, const struct cmdline *cmdline); +struct bfs_printf *parse_bfs_printf(const char *format, struct cmdline *cmdline); /** * Evaluate a parsed format string. |