From: Daniel P. Berrangé Date: Fri, 17 Jan 2020 13:40:54 +0000 (+0000) Subject: tools: replace wcwidth() with g_unichar_* APIs X-Git-Tag: v6.1.0-rc1~346 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6485c2c0ae65225e52bb011f091df83ff3cdb1f5;p=thirdparty%2Flibvirt.git tools: replace wcwidth() with g_unichar_* APIs 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é --- 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; }