From: Edmund GRIMLEY EVANS Date: Tue, 29 Jul 2003 10:11:05 +0000 (+0000) Subject: It seems that Solaris has an incorrect implementation of mbrtowc: when X-Git-Tag: pre-type-punning-patch~35 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4286da311cc3f34797ac2a688eecdfcc2ddcca2b;p=mutt It seems that Solaris has an incorrect implementation of mbrtowc: when 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. --- diff --git a/pager.c b/pager.c index a9255719..731ea101 100644 --- 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) {