]> granicus.if.org Git - mutt/commitdiff
It seems that Solaris has an incorrect implementation of mbrtowc: when
authorEdmund GRIMLEY EVANS <edmundo@rano.org>
Tue, 29 Jul 2003 10:11:05 +0000 (10:11 +0000)
committerEdmund GRIMLEY EVANS <edmundo@rano.org>
Tue, 29 Jul 2003 10:11:05 +0000 (10:11 +0000)
there is an encoding error and mbrtowc returns (size_t)(-1) no value
should be stored in *pwc (the first argument), as I understand it, but
here mbrtowc is storing 8 when presented with the bytes "\xc8\x4d".

However, relying on mbrtowc not to store anything in *pwc when there
is an error is a bit silly; it makes sense to look at the return
value. So, the following patch should be applied if Pawel can confirm
that it fixes the problem. I've tested it and it worked for me with
glibc's mbrtowc.

pager.c

diff --git a/pager.c b/pager.c
index a92557199f92e82a92f8176ada185f51c5d1dc08..731ea10131054c5dab5b8e37303131951e34e7e6 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -1085,10 +1085,10 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
 
       while ((wc1 = 0, mbstate1 = mbstate,
              k1 = k + mbrtowc (&wc1, (char *)buf+ch+k, cnt-ch-k, &mbstate1),
-             wc1 == '\b') &&
+             k1 - k > 0 && wc1 == '\b') &&
             (wc1 = 0,
              k2 = mbrtowc (&wc1, (char *)buf+ch+k1, cnt-ch-k1, &mbstate1),
-             IsWPrint (wc1)))
+             k2 > 0 && IsWPrint (wc1)))
       {
        if (wc == wc1)
        {