summaryrefslogtreecommitdiffstats
path: root/exec.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2018-12-25 18:00:14 -0500
committerTavian Barnes <tavianator@tavianator.com>2019-01-02 16:33:02 -0500
commit7fc7e98df2ea9c34dd1e0cb188554bed933a16df (patch)
tree6318a0afd2da2b2343a361e8abbc3896cd10a5a4 /exec.c
parentebcef71ef803940bff9ceb2c8d3ac5a1018bc084 (diff)
downloadbfs-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.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/exec.c b/exec.c
index 35bf061..3a35063 100644
--- a/exec.c
+++ b/exec.c
@@ -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;