return src;
}
-static void alias_entry (char *s, ssize_t slen, MUTTMENU *m, int num)
+static void alias_entry(char *s, ssize_t slen, MUTTMENU *m, int num)
{
- m_strformat(s, slen, AliasFmt, alias_format_str, ((alias_t **)m->data)[num],
- option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0);
+ m_strformat(s, slen, COLS - SW, AliasFmt, alias_format_str,
+ ((alias_t **)m->data)[num],
+ option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0);
}
static int alias_tag (MUTTMENU * menu, int n, int m)
return 0;
}
-static const char *folder_format_str (char *dest, ssize_t destlen, char op,
- const char *src, const char *fmt,
- const char *ifstr,
- const char *elstr,
- anytype data, format_flag flags)
+static const char *
+folder_format_str(char *dest, ssize_t destlen, char op,
+ const char *src, const char *fmt,
+ const char *ifstr, const char *elstr,
+ anytype data, format_flag flags)
{
char fn[STRING], tmp[STRING], permission[11], date[16];
const char *t_fmt;
if (flags & M_FORMAT_OPTIONAL)
- m_strformat(dest, destlen, optional ? ifstr : elstr, folder_format_str,
- data, 0);
+ m_strformat(dest, destlen, 0, optional ? ifstr : elstr,
+ folder_format_str, data, 0);
return src;
}
#ifdef USE_NNTP
-static const char *newsgroup_format_str (char *dest, ssize_t destlen, char op,
- const char *src, const char *fmt,
- const char *ifstr,
- const char *elstr,
- anytype data, format_flag flags)
+static const char *
+newsgroup_format_str(char *dest, ssize_t destlen, char op,
+ const char *src, const char *fmt,
+ const char *ifstr, const char *elstr,
+ anytype data, format_flag flags)
{
char fn[STRING], tmp[STRING];
FOLDER *folder = data.ptr;
case 's':
if (flags & M_FORMAT_OPTIONAL) {
if (folder->ff->nd->unread != 0)
- m_strformat (dest, destlen, ifstr, newsgroup_format_str,
- data, flags);
+ m_strformat(dest, destlen, 0, ifstr, newsgroup_format_str,
+ data, flags);
else
- m_strformat (dest, destlen, elstr, newsgroup_format_str,
- data, flags);
+ m_strformat (dest, destlen, 0, elstr, newsgroup_format_str,
+ data, flags);
}
else if (Context && Context->data == folder->ff->nd) {
snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
#ifdef USE_NNTP
if (option (OPTNEWS))
- m_strformat(s, slen, GroupFormat, newsgroup_format_str, &folder,
+ m_strformat(s, slen, COLS - SW, GroupFormat, newsgroup_format_str, &folder,
option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0);
else
#endif
- m_strformat(s, slen, FolderFormat, folder_format_str, &folder,
+ m_strformat(s, slen, COLS - SW, FolderFormat, folder_format_str, &folder,
option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0);
}
# warn about multiple declarations
CFLAGS += -Wredundant-decls
# warn if the format string is not a string literal
-CFLAGS += -Wformat-nonliteral
+#CFLAGS += -Wformat-nonliteral
# missing prototypes
CFLAGS += -Wmissing-prototypes
static void snd_entry (char *b, ssize_t blen, MUTTMENU * menu, int num) {
- int w = MIN(COLS-SW, blen);
-
- m_strformat(b, w, AttachFormat, mutt_attach_fmt,
+ m_strformat(b, blen, COLS - SW, AttachFormat, mutt_attach_fmt,
((ATTACHPTR **)menu->data)[num],
M_FORMAT_STAT_FILE | (option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0));
}
break;
}
- if (optional)
- compose_status_line (buf, buflen, menu, ifstr);
- else if (flags & M_FORMAT_OPTIONAL)
- compose_status_line (buf, buflen, menu, elstr);
+ if (flags & M_FORMAT_OPTIONAL)
+ compose_status_line(buf, buflen, menu, optional ? ifstr : elstr);
return (src);
}
static void compose_status_line (char *buf, ssize_t buflen, MUTTMENU * menu,
const char *p)
{
- int w = MIN(COLS - SW, buflen);
- m_strformat(buf, w, p, compose_format_str, menu, 0);
+ m_strformat(buf, buflen, COLS - SW, p, compose_format_str, menu, 0);
}
/* return values:
}
if (flags & M_FORMAT_OPTIONAL)
- m_strformat(dest, destlen, optional ? ifstr: elstr,
+ m_strformat(dest, destlen, 0, optional ? ifstr: elstr,
mutt_attach_fmt, data, 0);
return src;
}
entry.key = key_table[num];
entry.num = num + 1;
- m_strformat(s, l, PgpEntryFormat, crypt_entry_fmt, &entry,
+ m_strformat(s, l, COLS - SW, PgpEntryFormat, crypt_entry_fmt, &entry,
option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0);
}
}
if (flags & M_FORMAT_OPTIONAL)
- m_strformat(dest, destlen, optional ? ifstr : elstr,
+ m_strformat(dest, destlen, 0, optional ? ifstr : elstr,
_mutt_fmt_pgp_command, data, 0);
return src;
mutt_pgp_command(char *d, ssize_t dlen, struct pgp_command_context *cctx,
const char *fmt)
{
- m_strformat(d, dlen, fmt, _mutt_fmt_pgp_command, cctx, 0);
+ m_strformat(d, dlen, 0, fmt, _mutt_fmt_pgp_command, cctx, 0);
}
/*
}
if (flags & M_FORMAT_OPTIONAL)
- m_strformat(dest, destlen, optional ? ifstr : elstr,
+ m_strformat(dest, destlen, 0, optional ? ifstr : elstr,
mutt_attach_fmt, data, 0);
return src;
}
entry.uid = KeyTable[num];
entry.num = num + 1;
- m_strformat(s, l, PgpEntryFormat, pgp_entry_fmt, &entry,
+ m_strformat(s, l, COLS - SW, PgpEntryFormat, pgp_entry_fmt, &entry,
option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0);
}
/* This is almost identical to ppgp's invoking interface. */
static const char *
-_mutt_fmt_smime_command (char *dest, ssize_t destlen, char op,
- const char *src, const char *prefix,
+_mutt_fmt_smime_command (char *dest, ssize_t destlen,
+ char op, const char *src, const char *prefix,
const char *ifstr, const char *elstr,
anytype data, format_flag flags)
{
}
if (flags & M_FORMAT_OPTIONAL)
- m_strformat(dest, destlen, optional ? ifstr : elstr,
+ m_strformat(dest, destlen, 0, optional ? ifstr : elstr,
_mutt_fmt_smime_command, data, 0);
return src;
struct smime_command_context *cctx,
const char *fmt)
{
- m_strformat(d, dlen, fmt, _mutt_fmt_smime_command, cctx, 0);
+ m_strformat(d, dlen, 0, fmt, _mutt_fmt_smime_command, cctx, 0);
}
static pid_t smime_invoke (FILE ** smimein, FILE ** smimeout,
return (sb.st_size);
}
-static const char *compresshook_format_str (char *dest, ssize_t destlen,
- char op, const char *src,
- const char *fmt,
- const char *ifstr __attribute__ ((unused)),
- const char *elstr __attribute__ ((unused)),
- anytype data,
- format_flag flags __attribute__ ((unused)))
+static const char *
+compresshook_format_str(char *dest, ssize_t destlen,
+ char op, const char *src, const char *fmt,
+ const char *ifstr __attribute__ ((unused)),
+ const char *elstr __attribute__ ((unused)),
+ anytype data,
+ format_flag flags __attribute__ ((unused)))
{
char tmp[STRING];
return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
}
-static char *get_compression_cmd(const char *cmd, const CONTEXT * ctx)
+static char *get_compression_cmd(const char *cmd, const CONTEXT *ctx)
{
char buf[_POSIX_PATH_MAX];
- m_strformat(buf, sizeof(buf), cmd, compresshook_format_str, ctx, 0);
+ m_strformat(buf, sizeof(buf), 0, cmd, compresshook_format_str, (void*)ctx, 0);
return m_strdup(buf);
}
#define MAYBE_REDRAW(x) if (option (OPTNEEDREDRAW)) { unset_option (OPTNEEDREDRAW); x = REDRAW_FULL; }
+#define SW (option(OPTMBOXPANE)?SidebarWidth:0)
+
#endif /* !_MUTT_CURSES_H */
HEADER *hdr;
};
-static const char *hdr_format_str (char *dest,
- ssize_t destlen,
- char op,
- const char *src,
- const char *prefix,
- const char *ifstr,
- const char *elstr,
- anytype data, format_flag flags)
+static const char *
+hdr_format_str(char *dest, ssize_t destlen,
+ char op, const char *src, const char *prefix,
+ const char *ifstr, const char *elstr,
+ anytype data, format_flag flags)
{
struct hdr_format_info *hfi = data.ptr;
HEADER *hdr, *htmp;
}
if (flags & M_FORMAT_OPTIONAL)
- m_strformat(dest, destlen, optional ? ifstr: elstr,
+ m_strformat(dest, destlen, 0, optional ? ifstr: elstr,
hdr_format_str, data, flags);
return src;
hfi.hdr = hdr;
hfi.ctx = ctx;
- m_strformat(dest, destlen, s, hdr_format_str, &hfi, flags);
+ m_strformat(dest, destlen, COLS - SW, s, hdr_format_str, &hfi, flags);
}
return m_strdup(hbox);
}
-static const char* sidebar_number_format (char* dest, ssize_t destlen, char op,
- const char* src, const char* fmt,
- const char* ifstr, const char* elstr,
- anytype data, format_flag flags) {
+static const char *
+sidebar_number_format(char* dest, ssize_t destlen,
+ char op, const char* src, const char* fmt,
+ const char* ifstr, const char* elstr,
+ anytype data, format_flag flags)
+{
char tmp[STRING];
BUFFY* b = Incoming.arr[data.i];
int opt = flags & M_FORMAT_OPTIONAL;
}
if (flags & M_FORMAT_OPTIONAL)
- m_strformat(dest, destlen, opt ? ifstr : elstr, sidebar_number_format,
- data, flags);
+ m_strformat(dest, destlen, 0, opt ? ifstr : elstr,
+ sidebar_number_format, data, flags);
return src;
}
* (i.e. always display the currently opened) */
return 0;
- m_strformat(no, len, SidebarNumberFormat, sidebar_number_format, idx, 0);
+ m_strformat(no, len, SidebarWidth, SidebarNumberFormat, sidebar_number_format, idx, 0);
lencnt = m_strlen(no);
if (l > 0 && m_strncmp(sbox, ImapHomeNamespace, l) == 0 &&
* %t = # of tagged messages [option]
* %v = Madmutt version
* %V = currently active limit pattern [option] */
-static const char *status_format_str (char *buf, ssize_t buflen, char op,
- const char *src, const char *prefix,
- const char *ifstr,
- const char *elstr,
- anytype data, format_flag flags)
+static const char *
+status_format_str(char *buf, ssize_t buflen, char op, const char *src,
+ const char *prefix, const char *ifstr, const char *elstr,
+ anytype data, format_flag flags)
{
char fmt[STRING], tmp[STRING];
const char *cp, *p;
break;
}
- if (optional)
- menu_status_line (buf, buflen, menu, ifstr);
- else if (flags & M_FORMAT_OPTIONAL)
- menu_status_line (buf, buflen, menu, elstr);
+ if (flags & M_FORMAT_OPTIONAL)
+ menu_status_line(buf, buflen, menu, optional ? ifstr : elstr);
return (src);
}
-void menu_status_line (char* buf, ssize_t len, MUTTMENU* menu, const char* p) {
- /*
- * if we have enough space for buffer, format lines to $COLS-$SidebarWidth
- * only to not wrap past end of screen
- */
- int width = MIN(COLS - SW + 1, len);
- m_strformat(buf, width, p, status_format_str, menu, 0);
+void menu_status_line(char* buf, ssize_t len, MUTTMENU* menu, const char* p)
+{
+ m_strformat(buf, len, COLS - SW, p, status_format_str, menu, 0);
}
#include <lib-crypt/crypt.h>
-#define SW (option(OPTMBOXPANE)?SidebarWidth:0)
-
/* Modified by blong to accept a "suggestion" for file name. If
* that file exists, then construct one with unique name but
* keep any extension. This might fail, I guess.
}
}
-ssize_t m_strformat(char *dst, ssize_t dlen, const char *fmt,
+ssize_t m_strformat(char *dst, ssize_t dlen, int width, const char *fmt,
format_t *callback, anytype cdata, format_flag flags)
{
ssize_t pos = flags & M_FORMAT_ARROWCURSOR ? 3 : 0;
m_strpad(dst, dlen, '\0', pos + 1);
if (!fmt)
- return;
+ return pos;
while (*fmt) {
int ch;
}
switch (ch) {
- ssize_t col;
char lower, nodots, buf[LONG_STRING];
case '>': /* right justify to EOL */
- col = mutt_strwidth(dst);
+ width -= mutt_strwidth(dst);
ch = *fmt++; /* pad char */
- if (COLS - SW > col) {
- m_strformat(buf, sizeof(buf), fmt, callback, cdata, flags);
- pos += m_strpad(dst + pos, dlen - pos, ch,
- COLS - SW - col - mutt_strwidth(buf));
+ if (width > 0) {
+ m_strformat(buf, sizeof(buf), 0, fmt, callback, cdata, flags);
+ width -= mutt_strwidth(buf);
+ pos += m_strpad(dst + pos, dlen - pos, ch, width);
pos += m_strcpy(dst + pos, dlen - pos, buf);
}
return pos; /* skip rest of input */
case '|': /* pad to EOL */
- return pos + m_strpad(dst + pos, dlen - pos, *fmt,
- COLS - SW - mutt_strwidth(dst));
+ width -= mutt_strwidth(dst);
+ return pos + m_strpad(dst + pos, dlen - pos, *fmt, width);
default:
lower = nodots = 0;
if (!conn)
return NULL;
- m_strformat(file, sizeof(file), NewsRc, nntp_format_str, NULL, 0);
+ m_strformat(file, sizeof(file), 0, NewsRc, nntp_format_str, NULL, 0);
mutt_expand_path(file, sizeof(file));
serv = (NNTP_SERVER *) conn->data;
#define MoreArgs(p) (*p->dptr && *p->dptr != ';' && *p->dptr != '#')
-typedef const char *format_t (char *, ssize_t, char, const char *,
- const char *, const char *, const char *,
- anytype, format_flag);
+typedef const char *
+format_t(char *, ssize_t, char, const char *,
+ const char *, const char *, const char *, anytype, format_flag);
-ssize_t m_strformat(char *, ssize_t, const char *, format_t *,
- anytype, format_flag);
+ssize_t m_strformat(char *, ssize_t, int, const char *,
+ format_t *, anytype, format_flag);
void set_quadoption (int, int);
int query_quadoption (int, const char *);
* %s = size
* %u = unlink
*/
-const char *mutt_attach_fmt (char *dest, ssize_t destlen,
- char op,
- const char *src,
- const char *prefix,
- const char *ifstr,
- const char *elstr,
- anytype data, format_flag flags)
+const char *
+mutt_attach_fmt(char *dest, ssize_t destlen, char op, const char *src,
+ const char *prefix, const char *ifstr, const char *elstr,
+ anytype data, format_flag flags)
{
char fmt[16];
char tmp[STRING];
}
if (flags & M_FORMAT_OPTIONAL)
- m_strformat(dest, destlen, optional ? ifstr : elstr,
+ m_strformat(dest, destlen, 0, optional ? ifstr : elstr,
mutt_attach_fmt, data, 0);
return src;
}
static void attach_entry(char *b, ssize_t blen, MUTTMENU * menu, int num)
{
- int w = MIN(COLS - SW, blen);
-
- m_strformat(b, w, AttachFormat, mutt_attach_fmt,
+ m_strformat(b, blen, COLS - SW, AttachFormat, mutt_attach_fmt,
((ATTACHPTR **) menu->data)[num],
option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0);
}
}
if (flags & M_FORMAT_OPTIONAL)
- m_strformat (dest, destlen, optional ? ifstr : elstr,
- mutt_attach_fmt, data, 0);
+ m_strformat(dest, destlen, 0, optional ? ifstr : elstr,
+ mutt_attach_fmt, data, 0);
return (src);
}
{
remailer_t **type2_list = (remailer_t **) menu->data;
- int w = MIN(COLS - SW, blen);
- m_strformat(b, w, MixEntryFormat, mix_entry_fmt, type2_list[num],
+ m_strformat(b, blen, COLS - SW, MixEntryFormat, mix_entry_fmt,
+ type2_list[num],
option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0);
}
if (option (OPTNEWSSEND)) {
char cmd[LONG_STRING];
- m_strformat(cmd, sizeof(cmd), Inews, nntp_format_str, 0, 0);
+ m_strformat(cmd, sizeof(cmd), 0, Inews, nntp_format_str, 0, 0);
if (m_strisempty(cmd)) {
i = nntp_post (msg);
unlink (msg);