summaryrefslogtreecommitdiffstats
path: root/src/diag.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-12-30 14:49:46 -0500
committerTavian Barnes <tavianator@tavianator.com>2023-01-19 14:41:55 -0500
commit683552c4c9a3dfee4ce603157bb2cf18d64fbcfc (patch)
tree475130eeb136007eea7c59cb7190dc05287e2c56 /src/diag.c
parent944cd72f40a84d318453c320a84d443273956859 (diff)
downloadbfs-683552c4c9a3dfee4ce603157bb2cf18d64fbcfc.tar.xz
bfstd: New wrappers for dirname()/basename()
Diffstat (limited to 'src/diag.c')
-rw-r--r--src/diag.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/diag.c b/src/diag.c
index a0c11f2..b02473a 100644
--- a/src/diag.c
+++ b/src/diag.c
@@ -84,13 +84,18 @@ bool bfs_vdebug(const struct bfs_ctx *ctx, enum debug_flags flag, const char *fo
}
}
+/** Get the command name without any leading directories. */
+static const char *bfs_cmd(const struct bfs_ctx *ctx) {
+ return ctx->argv[0] + xbaseoff(ctx->argv[0]);
+}
+
void bfs_error_prefix(const struct bfs_ctx *ctx) {
- cfprintf(ctx->cerr, "${bld}%s:${rs} ${err}error:${rs} ", xbasename(ctx->argv[0]));
+ cfprintf(ctx->cerr, "${bld}%s:${rs} ${err}error:${rs} ", bfs_cmd(ctx));
}
bool bfs_warning_prefix(const struct bfs_ctx *ctx) {
if (ctx->warn) {
- cfprintf(ctx->cerr, "${bld}%s:${rs} ${wrn}warning:${rs} ", xbasename(ctx->argv[0]));
+ cfprintf(ctx->cerr, "${bld}%s:${rs} ${wrn}warning:${rs} ", bfs_cmd(ctx));
return true;
} else {
return false;
@@ -99,7 +104,7 @@ bool bfs_warning_prefix(const struct bfs_ctx *ctx) {
bool bfs_debug_prefix(const struct bfs_ctx *ctx, enum debug_flags flag) {
if (ctx->debug & flag) {
- cfprintf(ctx->cerr, "${bld}%s:${rs} ${cyn}-D %s${rs}: ", xbasename(ctx->argv[0]), debug_flag_name(flag));
+ cfprintf(ctx->cerr, "${bld}%s:${rs} ${cyn}-D %s${rs}: ", bfs_cmd(ctx), debug_flag_name(flag));
return true;
} else {
return false;