提交 6485c2c0 编写于 作者: D Daniel P. Berrangé

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: NPavel Hrdina <phrdina@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 540cf039
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <config.h> #include <config.h>
#include <locale.h> #include <locale.h>
#include <wchar.h>
#include <wctype.h> #include <wctype.h>
#include "internal.h" #include "internal.h"
......
...@@ -261,7 +261,7 @@ vshTableSafeEncode(const char *s, size_t *width) ...@@ -261,7 +261,7 @@ vshTableSafeEncode(const char *s, size_t *width)
} else { } else {
memcpy(buf, p, len); memcpy(buf, p, len);
buf += len; buf += len;
*width += wcwidth(wc); *width += g_unichar_iszerowidth(wc) ? 0 : (g_unichar_iswide(wc) ? 2 : 1);
} }
p += len; p += len;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册