summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-10-27 11:10:26 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-10-27 11:15:07 -0400
commitcaeff0108d59d36a3c3fc62fd5ed788eaaf4f0a5 (patch)
tree8799ef9a18ea6e304140b0ff9dc5009235972415 /src
parent14ef89a442f7a027f52fd688b438c5fa627b6af7 (diff)
downloadbfs-caeff0108d59d36a3c3fc62fd5ed788eaaf4f0a5.tar.xz
eval: TTY-escape paths in the status bar
Diffstat (limited to 'src')
-rw-r--r--src/eval.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/eval.c b/src/eval.c
index 6230353..05be5bb 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1137,6 +1137,12 @@ static void eval_status(struct bfs_eval *state, struct bfs_bar *bar, struct time
pathlen = strlen(path);
}
+ // Escape weird filename characters
+ if (dstrnescat(&status, path, pathlen, WESC_TTY) != 0) {
+ goto out;
+ }
+ pathlen = dstrlen(status);
+
// Try to make sure even wide characters fit in the status bar
size_t pathmax = width - rhslen - 3;
size_t pathwidth = 0;
@@ -1144,7 +1150,7 @@ static void eval_status(struct bfs_eval *state, struct bfs_bar *bar, struct time
mbstate_t mb;
memset(&mb, 0, sizeof(mb));
for (size_t i = lhslen; lhslen < pathlen; lhslen = i) {
- wint_t wc = xmbrtowc(path, &i, pathlen, &mb);
+ wint_t wc = xmbrtowc(status, &i, pathlen, &mb);
int cwidth;
if (wc == WEOF) {
// Invalid byte sequence, assume a single-width '?'
@@ -1161,10 +1167,8 @@ static void eval_status(struct bfs_eval *state, struct bfs_bar *bar, struct time
}
pathwidth += cwidth;
}
+ dstresize(&status, lhslen);
- if (dstrncat(&status, path, lhslen) != 0) {
- goto out;
- }
if (dstrcat(&status, "...") != 0) {
goto out;
}