X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=muttlib.c;h=22d4c76a89b661917ab94277be811b223533efaf;hp=c3ec12b7fbf857fb3065740a02901d06fd76b487;hb=16ff93bd19515d67ea15468b4adb35395970a559;hpb=3d937534e7b1ee723f86594b5e4c64c95158a933 diff --git a/muttlib.c b/muttlib.c index c3ec12b..22d4c76 100644 --- a/muttlib.c +++ b/muttlib.c @@ -17,6 +17,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include "mutt.h" #include "mutt_curses.h" #include "mime.h" @@ -935,11 +939,12 @@ void mutt_FormatString (char *dest, /* output buffer */ { char prefix[SHORT_STRING], buf[LONG_STRING], *cp, *wptr = dest, ch; char ifstring[SHORT_STRING], elsestring[SHORT_STRING]; - size_t wlen, count, len; + size_t wlen, count, len, col, wid; prefix[0] = '\0'; destlen--; /* save room for the terminal \0 */ wlen = (flags & M_FORMAT_ARROWCURSOR && option (OPTARROWCURSOR)) ? 3 : 0; + col = wlen; while (*src && wlen < destlen) { @@ -949,6 +954,7 @@ void mutt_FormatString (char *dest, /* output buffer */ { *wptr++ = '%'; wlen++; + col++; src++; continue; } @@ -1024,23 +1030,24 @@ void mutt_FormatString (char *dest, /* output buffer */ count = (COLS < destlen ? COLS : destlen); else count = ((COLS-SidebarWidth) < destlen ? COLS - SidebarWidth : destlen); - if (count > wlen) + if (count > col) { - count -= wlen; /* how many chars left on this line */ + count -= col; /* how many columns left on this line */ mutt_FormatString (buf, sizeof (buf), src, callback, data, flags); - len = mutt_strlen (buf); - if (count > len) + wid = mutt_strlen (buf); + if (count > wid) { - count -= len; /* how many chars to pad */ + count -= wid; /* how many chars to pad */ memset (wptr, ch, count); wptr += count; - wlen += count; + col += count; } if (len + wlen > destlen) len = destlen - wlen; memcpy (wptr, buf, len); wptr += len; wlen += len; + col += mutt_strwidth (buf); } break; /* skip rest of input */ } @@ -1092,6 +1099,7 @@ void mutt_FormatString (char *dest, /* output buffer */ memcpy (wptr, buf, len); wptr += len; wlen += len; + col += mutt_strwidth (buf); } } else if (*src == '\\') @@ -1122,11 +1130,13 @@ void mutt_FormatString (char *dest, /* output buffer */ src++; wptr++; wlen++; + col++; } else { *wptr++ = *src++; wlen++; + col++; } } *wptr = 0; @@ -1459,7 +1469,7 @@ time_t mutt_decrease_mtime (const char *f, struct stat *st) const char *mutt_make_version (void) { static char vstring[STRING]; - snprintf (vstring, sizeof (vstring), "Mutt %s (%s)", + snprintf (vstring, sizeof (vstring), "Mutt-ng %s (%s)", MUTT_VERSION, ReleaseDate); return vstring; }