summaryrefslogtreecommitdiffstats
path: root/charset.c
diff options
context:
space:
mode:
authorEdmund GRIMLEY EVANS <edmundo@rano.org>2004-02-08 11:41:31 +0000
committerEdmund GRIMLEY EVANS <edmundo@rano.org>2004-02-08 11:41:31 +0000
commit9f56520f503565f07487dc3c9c9d3027e0a8c4b3 (patch)
tree963b602e53d57ea9db88fda22d0334aee85f660c /charset.c
parent90cfbe8191b253a246d97f908533a6d66866bb43 (diff)
Fix a CP1255/8-related problem that's caused by a glibc/iconv bug.
Diffstat (limited to 'charset.c')
-rw-r--r--charset.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/charset.c b/charset.c
index 19c3a2b5..18e9cdc5 100644
--- a/charset.c
+++ b/charset.c
@@ -379,18 +379,24 @@ size_t mutt_iconv (iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft,
if (*t)
continue;
}
- if (outrepl)
+ /* Replace the output */
+ if (!outrepl)
+ outrepl = "?";
+ iconv (cd, 0, 0, &ob, &obl);
+ if (obl)
{
- /* Try replacing the output */
int n = strlen (outrepl);
- if (n <= obl)
+ if (n > obl)
{
- memcpy (ob, outrepl, n);
- ++ib, --ibl;
- ob += n, obl -= n;
- ++ret;
- continue;
+ outrepl = "?";
+ n = 1;
}
+ memcpy (ob, outrepl, n);
+ ++ib, --ibl;
+ ob += n, obl -= n;
+ ++ret;
+ iconv (cd, 0, 0, 0, 0); /* for good measure */
+ continue;
}
}
*inbuf = ib, *inbytesleft = ibl;