From 5a1df02f01d406884c7d05a3c296b3ae086d05cc Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 14 Jan 2021 15:55:46 -0500 Subject: [PATCH] Use runtime wcwidth() to check libc We've been using #ifdefs and such to check for libc Unicode 13 support at compile time. Instead, execute a wcwidth() using a sextant. If it comes back -1, the libc lacks support; disable sextants. Otherwise, let it go. This ought allow us to support sextants on BSD as soon as it has support; it furthermore allows us to properly disable them on Linuxes lacking such support. Closes #1289. --- src/lib/terminfo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/terminfo.c b/src/lib/terminfo.c index 0286272af..2b5ea6548 100644 --- a/src/lib/terminfo.c +++ b/src/lib/terminfo.c @@ -59,10 +59,10 @@ apply_term_heuristics(tinfo* ti, const char* termname){ }else if(strstr(termname, "vte") || strstr(termname, "gnome")){ ti->sextants = true; // VTE has long enjoyed good sextant support } -// as of freebsd 12.1 / dragonfly 5.9, there's no libc support for sextants -#if defined(__FreeBSD__) || defined(__DragonFly__) - ti->sextants = false; -#endif + // run a wcwidth() to guarantee libc Unicode 13 support + if(wcwidth(L'🬸') < 0){ + ti->sextants = false; + } return 0; }