some tiny reworks, stylish issues.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
static void alias_entry (char *s, ssize_t slen, MUTTMENU * m, int num)
{
- mutt_FormatString (s, slen, NONULL (AliasFmt), (format_t *)alias_format_str,
+ m_strformat (s, slen, NONULL (AliasFmt), (format_t *)alias_format_str,
(unsigned long)((alias_t **)m->data)[num],
M_FORMAT_ARROWCURSOR);
}
}
if (optional)
- mutt_FormatString (dest, destlen, ifstring, folder_format_str, data, 0);
+ m_strformat (dest, destlen, ifstring, folder_format_str, data, 0);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, elsestring, folder_format_str, data, 0);
+ m_strformat (dest, destlen, elsestring, folder_format_str, data, 0);
return (src);
}
case 's':
if (flags & M_FORMAT_OPTIONAL) {
if (folder->ff->nd->unread != 0)
- mutt_FormatString (dest, destlen, ifstring, newsgroup_format_str,
+ m_strformat (dest, destlen, ifstring, newsgroup_format_str,
data, flags);
else
- mutt_FormatString (dest, destlen, elsestring, newsgroup_format_str,
+ m_strformat (dest, destlen, elsestring, newsgroup_format_str,
data, flags);
}
else if (Context && Context->data == folder->ff->nd) {
#ifdef USE_NNTP
if (option (OPTNEWS))
- mutt_FormatString (s, slen, NONULL (GroupFormat), newsgroup_format_str,
+ m_strformat (s, slen, NONULL (GroupFormat), newsgroup_format_str,
(unsigned long) &folder, M_FORMAT_ARROWCURSOR);
else
#endif
- mutt_FormatString (s, slen, NONULL (FolderFormat), folder_format_str,
+ m_strformat (s, slen, NONULL (FolderFormat), folder_format_str,
(unsigned long) &folder, M_FORMAT_ARROWCURSOR);
}
static void snd_entry (char *b, ssize_t blen, MUTTMENU * menu, int num) {
int w=(COLS-SW)>blen?blen:COLS-SW;
- mutt_FormatString (b, w, NONULL (AttachFormat), mutt_attach_fmt,
+ m_strformat (b, w, NONULL (AttachFormat), mutt_attach_fmt,
(unsigned long) (((ATTACHPTR **) menu->data)[num]),
M_FORMAT_STAT_FILE | M_FORMAT_ARROWCURSOR);
}
const char *p)
{
int w=(COLS-SW)>buflen?buflen:(COLS-SW);
- mutt_FormatString (buf, w, p, compose_format_str,
+ m_strformat (buf, w, p, compose_format_str,
(unsigned long) menu, 0);
}
}
if (optional)
- mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
+ m_strformat (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
+ m_strformat (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
return (src);
}
entry.key = key_table[num];
entry.num = num + 1;
- mutt_FormatString (s, l, NONULL (PgpEntryFormat), crypt_entry_fmt,
+ m_strformat (s, l, NONULL (PgpEntryFormat), crypt_entry_fmt,
(unsigned long) &entry, M_FORMAT_ARROWCURSOR);
}
}
if (optional)
- mutt_FormatString (dest, destlen, ifstring, _mutt_fmt_pgp_command, data,
+ m_strformat (dest, destlen, ifstring, _mutt_fmt_pgp_command, data,
0);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, elsestring, _mutt_fmt_pgp_command, data,
+ m_strformat (dest, destlen, elsestring, _mutt_fmt_pgp_command, data,
0);
return (src);
mutt_pgp_command(char *d, ssize_t dlen, struct pgp_command_context *cctx,
const char *fmt)
{
- mutt_FormatString (d, dlen, NONULL (fmt), _mutt_fmt_pgp_command,
+ m_strformat (d, dlen, NONULL (fmt), _mutt_fmt_pgp_command,
(unsigned long) cctx, 0);
}
}
if (optional)
- mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
+ m_strformat (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
+ m_strformat (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
return (src);
}
entry.uid = KeyTable[num];
entry.num = num + 1;
- mutt_FormatString (s, l, NONULL (PgpEntryFormat), pgp_entry_fmt,
+ m_strformat (s, l, NONULL (PgpEntryFormat), pgp_entry_fmt,
(unsigned long) &entry, M_FORMAT_ARROWCURSOR);
}
}
if (optional)
- mutt_FormatString (dest, destlen, ifstring, _mutt_fmt_smime_command,
+ m_strformat (dest, destlen, ifstring, _mutt_fmt_smime_command,
data, 0);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, elsestring, _mutt_fmt_smime_command,
+ m_strformat (dest, destlen, elsestring, _mutt_fmt_smime_command,
data, 0);
return (src);
struct smime_command_context *cctx,
const char *fmt)
{
- mutt_FormatString (d, dlen, NONULL (fmt), _mutt_fmt_smime_command,
+ m_strformat (d, dlen, NONULL (fmt), _mutt_fmt_smime_command,
(unsigned long) cctx, 0);
}
{
char expanded[_POSIX_PATH_MAX];
- mutt_FormatString (expanded, sizeof (expanded), cmd,
+ m_strformat (expanded, sizeof (expanded), cmd,
compresshook_format_str, (unsigned long) ctx, 0);
return m_strdup(expanded);
}
}
if (optional)
- mutt_FormatString (dest, destlen, ifstring, hdr_format_str,
+ m_strformat (dest, destlen, ifstring, hdr_format_str,
(unsigned long) hfi, flags);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, elsestring, hdr_format_str,
+ m_strformat (dest, destlen, elsestring, hdr_format_str,
(unsigned long) hfi, flags);
return (src);
hfi.hdr = hdr;
hfi.ctx = ctx;
- mutt_FormatString (dest, destlen, s, hdr_format_str, (unsigned long) &hfi,
+ m_strformat (dest, destlen, s, hdr_format_str, (unsigned long) &hfi,
flags);
}
}
if (opt)
- mutt_FormatString (dest, destlen, ifstr, sidebar_number_format,
+ m_strformat (dest, destlen, ifstr, sidebar_number_format,
data, M_FORMAT_OPTIONAL);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, elstr, sidebar_number_format,
+ m_strformat (dest, destlen, elstr, sidebar_number_format,
data, M_FORMAT_OPTIONAL);
return (src);
}
* (i.e. always display the currently opened) */
return (0);
- mutt_FormatString (no, len, NONULL (SidebarNumberFormat),
+ m_strformat (no, len, NONULL (SidebarNumberFormat),
sidebar_number_format, idx, M_FORMAT_OPTIONAL);
lencnt = m_strlen(no);
memset(&entry, ' ', sizeof(entry));
* only to not wrap past end of screen
*/
int width = COLS - SW;
- mutt_FormatString (buf, (width >= len ? len : (width + 1)),
+ m_strformat (buf, (width >= len ? len : (width + 1)),
p, status_format_str,
(unsigned long) menu, 0);
}
int op; /* function op */
} event_t;
-/* flags for mutt_FormatString() */
+/* flags for m_strformat() */
typedef enum {
M_FORMAT_FORCESUBJ = (1 << 0), /* print the subject even if unchanged */
M_FORMAT_TREE = (1 << 1), /* draw the thread tree */
}
}
-ssize_t
-mutt_FormatString(char *dst, ssize_t dlen, const char *fmt,
- format_t *callback, unsigned long data, format_flag flags)
+ssize_t m_strformat(char *dst, ssize_t dlen, const char *fmt,
+ format_t *callback, unsigned long data, format_flag flags)
{
ssize_t pos = (flags & M_FORMAT_ARROWCURSOR && option (OPTARROWCURSOR)) ? 3 : 0;
while (*fmt) {
- char ifstring[STRING] = "", elsestring[STRING] = "", prefix[STRING] = "";
+ char ifstring[STRING], elsestring[STRING], prefix[STRING] = "";
int ch;
if (*fmt == '%') {
if (*++fmt == '%') {
- pos += m_strputc(dst + pos, dlen - pos, '%');
- fmt++;
+ pos += m_strputc(dst + pos, dlen - pos, *fmt++);
continue;
}
if (!*fmt++) /* move past the trailing `?' */
break; /* bad format */
+ } else {
+ *ifstring = *elsestring = '\0';
}
switch (ch) {
ch = *fmt++; /* pad char */
if (COLS - SW > col) {
- ssize_t wid;
-
- mutt_FormatString(buf, sizeof(buf), fmt, callback, data, flags);
- wid = mutt_strwidth(buf);
-
- pos += m_strpad(dst + pos, dlen - pos, ch, COLS - SW - col - wid);
+ m_strformat(buf, sizeof(buf), fmt, callback, data, flags);
+ pos += m_strpad(dst + pos, dlen - pos, ch,
+ COLS - SW - col - mutt_strwidth(buf));
pos += m_strcpy(dst + pos, dlen - pos, buf);
}
return pos; /* skip rest of input */
}
pos += m_strcpy(dst + pos, dlen - pos, buf);
- continue;
+ break;
}
+ continue;
}
if (*fmt == '\\') {
if (!*++fmt)
break;
- switch (*fmt) {
+ switch ((ch = *fmt++)) {
case 'n': pos += m_strputc(dst + pos, dlen - pos, '\n'); break;
case 't': pos += m_strputc(dst + pos, dlen - pos, '\t'); break;
case 'r': pos += m_strputc(dst + pos, dlen - pos, '\r'); break;
case 'f': pos += m_strputc(dst + pos, dlen - pos, '\f'); break;
case 'v': pos += m_strputc(dst + pos, dlen - pos, '\v'); break;
- default: pos += m_strputc(dst + pos, dlen - pos, *fmt); break;
+ default: pos += m_strputc(dst + pos, dlen - pos, ch); break;
}
- fmt++;
} else {
ssize_t len = strcspn(fmt, "%\\");
if (!conn)
return NULL;
- mutt_FormatString (file, sizeof (file), NONULL (NewsRc), nntp_format_str, 0,
+ m_strformat (file, sizeof (file), NONULL (NewsRc), nntp_format_str, 0,
0);
mutt_expand_path (file, sizeof (file));
const char *, const char *, const char *,
unsigned long, format_flag);
-ssize_t mutt_FormatString(char *, ssize_t, const char *, format_t *,
+ssize_t m_strformat(char *, ssize_t, const char *, format_t *,
unsigned long, format_flag);
void set_quadoption (int, int);
}
if (optional)
- mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
+ m_strformat (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
+ m_strformat (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
return (src);
}
static void attach_entry (char *b, ssize_t blen, MUTTMENU * menu, int num)
{
int w=(COLS-SW)>blen?blen:(COLS-SW);
- mutt_FormatString (b, w, NONULL (AttachFormat), mutt_attach_fmt,
+ m_strformat (b, w, NONULL (AttachFormat), mutt_attach_fmt,
(unsigned long) (((ATTACHPTR **) menu->data)[num]),
M_FORMAT_ARROWCURSOR);
}
}
if (optional)
- mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
+ m_strformat (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
else if (flags & M_FORMAT_OPTIONAL)
- mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
+ m_strformat (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
return (src);
}
remailer_t **type2_list = (remailer_t **) menu->data;
int w = (COLS-SW) > blen ? blen : (COLS-SW);
- mutt_FormatString (b, w, NONULL (MixEntryFormat), mix_entry_fmt,
+ m_strformat (b, w, NONULL (MixEntryFormat), mix_entry_fmt,
(unsigned long) type2_list[num], M_FORMAT_ARROWCURSOR);
}
if (option (OPTNEWSSEND)) {
char cmd[LONG_STRING];
- mutt_FormatString (cmd, sizeof (cmd), NONULL (Inews), nntp_format_str, 0,
+ m_strformat (cmd, sizeof (cmd), NONULL (Inews), nntp_format_str, 0,
0);
if (m_strisempty(cmd)) {
i = nntp_post (msg);