void ci_bounce_message (HEADER *h, int *redraw)
{
char prompt[SHORT_STRING];
+ char scratch[SHORT_STRING];
char buf[HUGE_STRING] = { 0 };
ADDRESS *adr = NULL;
char *err = NULL;
rfc822_write_address (buf, sizeof (buf), adr, 1);
#define extra_space (15 + 7 + 2)
- snprintf (prompt, sizeof (prompt),
+ snprintf (scratch, sizeof (scratch),
(h ? _("Bounce message to %s") : _("Bounce messages to %s")), buf);
if (mutt_strwidth (prompt) > COLS - extra_space)
{
mutt_format_string (prompt, sizeof (prompt),
0, COLS-extra_space, 0, 0,
- prompt, sizeof (prompt), 0);
+ scratch, sizeof (scratch), 0);
safe_strcat (prompt, sizeof (prompt), "...?");
}
else
- safe_strcat (prompt, sizeof (prompt), "?");
+ snprintf (prompt, sizeof (prompt), "%s?", scratch);
if (query_quadoption (OPT_BOUNCE, prompt) != M_YES)
{
void mutt_curses_error (const char *fmt, ...)
{
va_list ap;
+ char scratch[LONG_STRING];
va_start (ap, fmt);
- vsnprintf (Errorbuf, sizeof (Errorbuf), fmt, ap);
+ vsnprintf (scratch, sizeof (scratch), fmt, ap);
va_end (ap);
- dprint (1, (debugfile, "%s\n", Errorbuf));
+ dprint (1, (debugfile, "%s\n", scratch));
mutt_format_string (Errorbuf, sizeof (Errorbuf),
- 0, COLS-2, 0, 0, Errorbuf, sizeof (Errorbuf), 0);
+ 0, COLS-2, 0, 0, scratch, sizeof (scratch), 0);
if (!option (OPTKEEPQUIET))
{
void mutt_curses_message (const char *fmt, ...)
{
va_list ap;
+ char scratch[LONG_STRING];
va_start (ap, fmt);
- vsnprintf (Errorbuf, sizeof (Errorbuf), fmt, ap);
+ vsnprintf (scratch, sizeof (scratch), fmt, ap);
va_end (ap);
mutt_format_string (Errorbuf, sizeof (Errorbuf),
- 0, COLS-2, 0, 0, Errorbuf, sizeof (Errorbuf), 0);
+ 0, COLS-2, 0, 0, scratch, sizeof (scratch), 0);
if (!option (OPTKEEPQUIET))
{
{
if (k == (size_t)(-1) || k == (size_t)(-2))
{
+ if (k == (size_t)(-1) && errno == EILSEQ)
+ memset (&mbstate1, 0, sizeof (mbstate1));
+
k = (k == (size_t)(-1)) ? 1 : n;
wc = replacement_char ();
}
{
if (k == (size_t)(-1) || k == (size_t)(-2))
{
+ if (k == (size_t) (-1))
+ memset (&mbstate, 0, sizeof (mbstate));
k = (k == (size_t)(-1)) ? 1 : len;
wc = replacement_char ();
}
size_t wbuflen;
wbuf = *pwbuf, wbuflen = *pwbuflen;
- memset (&st, 0, sizeof (st));
- for (; (k = mbrtowc (&wc, buf, MB_LEN_MAX, &st)) &&
- k != (size_t)(-1) && k != (size_t)(-2); buf += k)
+
+ while (*buf)
{
- if (i >= wbuflen)
+ memset (&st, 0, sizeof (st));
+ for (; (k = mbrtowc (&wc, buf, MB_LEN_MAX, &st)) &&
+ k != (size_t)(-1) && k != (size_t)(-2); buf += k)
+ {
+ if (i >= wbuflen)
+ {
+ wbuflen = i + 20;
+ safe_realloc (&wbuf, wbuflen * sizeof (*wbuf));
+ }
+ wbuf[i++] = wc;
+ }
+ if (*buf && (k == (size_t) -1 || k == (size_t) -2))
{
- wbuflen = i + 20;
- safe_realloc (&wbuf, wbuflen * sizeof (*wbuf));
+ if (i >= wbuflen)
+ {
+ wbuflen = i + 20;
+ safe_realloc (&wbuf, wbuflen * sizeof (*wbuf));
+ }
+ wbuf[i++] = replacement_char();
+ buf++;
}
- wbuf[i++] = wc;
}
*pwbuf = wbuf, *pwbuflen = wbuflen;
return i;
void menu_pad_string (char *s, size_t n)
{
+ char *scratch = safe_strdup (s);
int shift = option (OPTARROWCURSOR) ? 3 : 0;
int cols = COLS - shift;
- mutt_format_string (s, n, cols, cols, 0, ' ', s, strlen (s), 1);
+ mutt_format_string (s, n, cols, cols, 0, ' ', scratch, strlen (scratch), 1);
s[n - 1] = 0;
+ safe_free (&scratch);
}
void menu_redraw_full (MUTTMENU *menu)