summaryrefslogtreecommitdiffstats
path: root/help.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>2000-10-07 18:06:24 +0000
committerThomas Roessler <roessler@does-not-exist.org>2000-10-07 18:06:24 +0000
commita080fd35226893ed18194ffb77d2190d17ee38e4 (patch)
treecd23c840bc1cdcc7fb7046689db690bc274cd719 /help.c
parentfe7d2cb2e0f9817ce1b03a6f860b48cbc967aa43 (diff)
Display fixes from EGE.
Diffstat (limited to 'help.c')
-rw-r--r--help.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/help.c b/help.c
index 324eba39..57f6a48b 100644
--- a/help.c
+++ b/help.c
@@ -95,11 +95,15 @@ static int print_macro (FILE *f, int maxwidth, const char **macro)
memset (&mbstate1, 0, sizeof (mbstate1));
memset (&mbstate2, 0, sizeof (mbstate2));
- for (; (k = mbrtowc (&wc, *macro, len, &mbstate1)); *macro += k, len -= k)
+ for (; len && (k = mbrtowc (&wc, *macro, len, &mbstate1)); *macro += k, len -= k)
{
if (k == (size_t)(-1) || k == (size_t)(-2))
- break;
- if ((w = wcwidth (wc)) >= 0)
+ {
+ k = (k == (size_t)(-1)) ? 1 : len;
+ wc = replacement_char ();
+ }
+ /* glibc-2.1.3's wcwidth() returns 1 for unprintable chars! */
+ if (IsWPrint (wc) && (w = wcwidth (wc)) >= 0)
{
if (w > n)
break;