From 7fc7e98df2ea9c34dd1e0cb188554bed933a16df Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 25 Dec 2018 18:00:14 -0500 Subject: 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. --- exec.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'exec.c') 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; -- cgit v1.2.3