From 6485c2c0ae65225e52bb011f091df83ff3cdb1f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Fri, 17 Jan 2020 13:40:54 +0000 Subject: [PATCH] tools: replace wcwidth() with g_unichar_* APIs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The combination of g_unichar_iszerowidth and g_unichar_iswide is sufficient to replicate the logic of wcwidth() for libvirt. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrangé --- tests/vshtabletest.c | 1 + tools/vsh-table.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c index f2e0554f0a..0feda90b52 100644 --- a/tests/vshtabletest.c +++ b/tests/vshtabletest.c @@ -19,6 +19,7 @@ #include #include +#include #include #include "internal.h" diff --git a/tools/vsh-table.c b/tools/vsh-table.c index a2365b2c32..e21514e86f 100644 --- a/tools/vsh-table.c +++ b/tools/vsh-table.c @@ -261,7 +261,7 @@ vshTableSafeEncode(const char *s, size_t *width) } else { memcpy(buf, p, len); buf += len; - *width += wcwidth(wc); + *width += g_unichar_iszerowidth(wc) ? 0 : (g_unichar_iswide(wc) ? 2 : 1); } p += len; } -- 2.47.2