summaryrefslogtreecommitdiffstats
path: root/printf.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-04-29 18:08:07 -0400
committerTavian Barnes <tavianator@tavianator.com>2017-04-29 18:08:07 -0400
commitfacf34bd2ffc16eb2a5e770d9be3d8010b4add42 (patch)
treeedabd39358d60e55489c0195a461323937431cba /printf.c
parent068205d5e5186ab3fb0403d129572bc90a65bd23 (diff)
downloadbfs-facf34bd2ffc16eb2a5e770d9be3d8010b4add42.tar.xz
Don't parse the mount table until it's needed
Diffstat (limited to 'printf.c')
-rw-r--r--printf.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/printf.c b/printf.c
index 50a9dcf..33753e3 100644
--- a/printf.c
+++ b/printf.c
@@ -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;