char *p;
wchar_t wc;
int w, k;
+ char scratch[MB_LEN_MAX];
--destlen;
p = dest;
w = wc < M_TREE_MAX ? 1 : wcwidth (wc); /* hack */
if (w >= 0)
{
- if (w > max_width || wctomb (0, wc) > destlen)
+ if (w > max_width || (k = wctomb (scratch, wc)) > destlen)
break;
min_width -= w;
max_width -= w;
- p += (k = wctomb (p, wc));
+ strncpy (p, scratch, k);
+ p += k;
destlen -= k;
}
}
int wctomb (char *s, wchar_t wc)
{
+ if (!s)
+ return 0;
if (Charset_is_utf8)
return mutt_wctoutf8 (s, wc);
else if (wc < 0x100)
{
- if (s) *s = wc;
+ *s = wc;
return 1;
}
else