diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2018-12-25 18:00:14 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2019-01-02 16:33:02 -0500 |
commit | 7fc7e98df2ea9c34dd1e0cb188554bed933a16df (patch) | |
tree | 6318a0afd2da2b2343a361e8abbc3896cd10a5a4 /exec.c | |
parent | ebcef71ef803940bff9ceb2c8d3ac5a1018bc084 (diff) | |
download | bfs-7fc7e98df2ea9c34dd1e0cb188554bed933a16df.tar.xz |
diag: Unify diagnostic formatting
This adds a bfs: prefix to error/warning messages for consistency with
other command line tools, and leaves only the "error:"/"warning:" part
colored like GCC. It also uniformly adds full stops after messages.
Diffstat (limited to 'exec.c')
-rw-r--r-- | exec.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -18,6 +18,7 @@ #include "bftw.h" #include "cmdline.h" #include "color.h" +#include "diag.h" #include "dstring.h" #include "spawn.h" #include "util.h" @@ -114,8 +115,6 @@ static size_t bfs_exec_arg_max(const struct bfs_exec *execbuf) { } struct bfs_exec *parse_bfs_exec(char **argv, enum bfs_exec_flags flags, const struct cmdline *cmdline) { - CFILE *cerr = cmdline->cerr; - struct bfs_exec *execbuf = malloc(sizeof(*execbuf)); if (!execbuf) { perror("malloc()"); @@ -142,9 +141,9 @@ struct bfs_exec *parse_bfs_exec(char **argv, enum bfs_exec_flags flags, const st const char *arg = argv[i]; if (!arg) { if (execbuf->flags & BFS_EXEC_CONFIRM) { - cfprintf(cerr, "%{er}error: %s: Expected '... ;'.%{rs}\n", argv[0]); + bfs_error(cmdline, "%s: Expected '... ;'.\n", argv[0]); } else { - cfprintf(cerr, "%{er}error: %s: Expected '... ;' or '... {} +'.%{rs}\n", argv[0]); + bfs_error(cmdline, "%s: Expected '... ;' or '... {} +'.\n", argv[0]); } goto fail; } else if (strcmp(arg, ";") == 0) { @@ -161,7 +160,7 @@ struct bfs_exec *parse_bfs_exec(char **argv, enum bfs_exec_flags flags, const st execbuf->tmpl_argc = i - 1; if (execbuf->tmpl_argc == 0) { - cfprintf(cerr, "%{er}error: %s: Missing command.%{rs}\n", argv[0]); + bfs_error(cmdline, "%s: Missing command.\n", argv[0]); goto fail; } @@ -176,7 +175,7 @@ struct bfs_exec *parse_bfs_exec(char **argv, enum bfs_exec_flags flags, const st for (i = 0; i < execbuf->tmpl_argc - 1; ++i) { char *arg = execbuf->tmpl_argv[i]; if (strstr(arg, "{}")) { - cfprintf(cerr, "%{er}error: %s ... +: Only one '{}' is supported.%{rs}\n", argv[0]); + bfs_error(cmdline, "%s ... +: Only one '{}' is supported.\n", argv[0]); goto fail; } execbuf->argv[i] = arg; |