From a080fd35226893ed18194ffb77d2190d17ee38e4 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Sat, 7 Oct 2000 18:06:24 +0000 Subject: Display fixes from EGE. --- help.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'help.c') 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; -- cgit v1.2.3