summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-12-16 11:54:18 -0500
committerTavian Barnes <tavianator@tavianator.com>2023-12-16 11:54:18 -0500
commitaa8344e04bfe950cc9f5e45352cd8202295e0cdf (patch)
tree7234a88dd56f8cd9406b9265693c3af9842d747f
parent023482caa20c0d3b5ab1641f26d8384829b1e43f (diff)
downloadbfs-aa8344e04bfe950cc9f5e45352cd8202295e0cdf.tar.xz
bfstd: New xwcwidth() wrapper
-rw-r--r--src/bfstd.c2
-rw-r--r--src/bfstd.h5
-rw-r--r--src/eval.c2
3 files changed, 7 insertions, 2 deletions
diff --git a/src/bfstd.c b/src/bfstd.c
index 9ffa8e6..a3e22f5 100644
--- a/src/bfstd.c
+++ b/src/bfstd.c
@@ -658,7 +658,7 @@ size_t xstrwidth(const char *str) {
// Assume a single-width '?'
++ret;
} else {
- ret += BFS_INTERCEPT(wcwidth)(wc);
+ ret += xwcwidth(wc);
}
}
diff --git a/src/bfstd.h b/src/bfstd.h
index 58e504c..0fcb892 100644
--- a/src/bfstd.h
+++ b/src/bfstd.h
@@ -390,6 +390,11 @@ wint_t xmbrtowc(const char *str, size_t *i, size_t len, mbstate_t *mb);
*/
size_t xstrwidth(const char *str);
+/**
+ * wcwidth() wrapper that works around LLVM bug #65532.
+ */
+#define xwcwidth BFS_INTERCEPT(wcwidth)
+
#include <wctype.h>
/**
diff --git a/src/eval.c b/src/eval.c
index 55b14f0..a990fd4 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1154,7 +1154,7 @@ static void eval_status(struct bfs_eval *state, struct bfs_bar *bar, struct time
// Invalid byte sequence, assume a single-width '?'
cwidth = 1;
} else {
- cwidth = wcwidth(wc);
+ cwidth = xwcwidth(wc);
if (cwidth < 0) {
cwidth = 0;
}