From: Pierre Habouzit Date: Sat, 2 Dec 2006 22:54:35 +0000 (+0100) Subject: the ‘kids don't do this at home’ commit. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=38dacbf03fe1a0daa9ce426caaef5582b90006b2;p=apps%2Fmadmutt.git the ‘kids don't do this at home’ commit. replace the unsigned long mutt API used to cast anything into ints pointer and so on. Add 'anytype' that is a kind of dirty union that, thanks to gcc __attribute__((transparent_union)) allows silent cast from any type into that type. eeeeeeek ! but that makes the code way easier to read ! Signed-off-by: Pierre Habouzit --- diff --git a/alias.c b/alias.c index 24b8b36..f566cec 100644 --- a/alias.c +++ b/alias.c @@ -479,14 +479,14 @@ int mutt_alias_complete (char *s, size_t buflen) return 0; } -static const format_t *alias_format_str (char *dest, size_t destlen, char op, - const format_t *src, const char *fmt, - const char *ifstring __attribute__ ((unused)), - const char *elsestring __attribute__ ((unused)), - unsigned long data, format_flag flags __attribute__ ((unused))) +static const char * +alias_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], adr[STRING]; - alias_t *alias = (alias_t *) data; + alias_t *alias = data.ptr; switch (op) { case 'f': @@ -510,14 +510,14 @@ static const format_t *alias_format_str (char *dest, size_t destlen, char op, break; } - return (src); + 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, NONULL (AliasFmt), (format_t *)alias_format_str, - (unsigned long)((alias_t **)m->data)[num], - option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0); + m_strformat(s, slen, NONULL (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) diff --git a/browser.c b/browser.c index 4af5dca..f8fbb3d 100644 --- a/browser.c +++ b/browser.c @@ -147,14 +147,14 @@ static int link_is_dir (const char *folder, const char *path) static const char *folder_format_str (char *dest, ssize_t destlen, char op, const char *src, const char *fmt, - const char *ifstring, - const char *elsestring, - unsigned long data, format_flag flags) + const char *ifstr, + const char *elstr, + anytype data, format_flag flags) { char fn[STRING], tmp[STRING], permission[11], date[16]; const char *t_fmt; time_t tnow; - FOLDER *folder = (FOLDER *) data; + FOLDER *folder = data.ptr; struct passwd *pw; struct group *gr; int optional = (flags & M_FORMAT_OPTIONAL); @@ -301,9 +301,9 @@ static const char *folder_format_str (char *dest, ssize_t destlen, char op, } if (optional) - m_strformat (dest, destlen, ifstring, folder_format_str, data, 0); + m_strformat (dest, destlen, ifstr, folder_format_str, data, 0); else if (flags & M_FORMAT_OPTIONAL) - m_strformat (dest, destlen, elsestring, folder_format_str, data, 0); + m_strformat (dest, destlen, elstr, folder_format_str, data, 0); return (src); } @@ -311,13 +311,12 @@ static const char *folder_format_str (char *dest, ssize_t destlen, char op, #ifdef USE_NNTP static const char *newsgroup_format_str (char *dest, ssize_t destlen, char op, const char *src, const char *fmt, - const char *ifstring, - const char *elsestring, - unsigned long data, - format_flag flags) + const char *ifstr, + const char *elstr, + anytype data, format_flag flags) { char fn[STRING], tmp[STRING]; - FOLDER *folder = (FOLDER *) data; + FOLDER *folder = data.ptr; switch (op) { case 'C': @@ -350,10 +349,10 @@ static const char *newsgroup_format_str (char *dest, ssize_t destlen, char op, case 's': if (flags & M_FORMAT_OPTIONAL) { if (folder->ff->nd->unread != 0) - m_strformat (dest, destlen, ifstring, newsgroup_format_str, + m_strformat (dest, destlen, ifstr, newsgroup_format_str, data, flags); else - m_strformat (dest, destlen, elsestring, newsgroup_format_str, + m_strformat (dest, destlen, elstr, newsgroup_format_str, data, flags); } else if (Context && Context->data == folder->ff->nd) { @@ -646,12 +645,12 @@ static void folder_entry (char *s, ssize_t slen, MUTTMENU * menu, int num) #ifdef USE_NNTP if (option (OPTNEWS)) m_strformat(s, slen, NONULL (GroupFormat), newsgroup_format_str, - (unsigned long)&folder, + (void*)&folder, option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0); else #endif m_strformat(s, slen, NONULL (FolderFormat), folder_format_str, - (unsigned long)&folder, + (void *)&folder, option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0); } diff --git a/compose.c b/compose.c index d1a6098..b11fc66 100644 --- a/compose.c +++ b/compose.c @@ -115,7 +115,7 @@ static struct mapping_t ComposeNewsHelp[] = { static void snd_entry (char *b, ssize_t blen, MUTTMENU * menu, int num) { int w=(COLS-SW)>blen?blen:COLS-SW; m_strformat (b, w, NONULL (AttachFormat), mutt_attach_fmt, - (unsigned long) (((ATTACHPTR **) menu->data)[num]), + ((ATTACHPTR **)menu->data)[num], M_FORMAT_STAT_FILE | (option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0)); } @@ -410,13 +410,13 @@ static void compose_status_line (char *buf, ssize_t buflen, MUTTMENU * menu, static const char *compose_format_str (char *buf, ssize_t buflen, char op, const char *src, const char *prefix, - const char *ifstring, - const char *elsestring, - unsigned long data, format_flag flags) + const char *ifstr, + const char *elstr, + anytype data, format_flag flags) { char fmt[STRING], tmp[STRING]; int optional = (flags & M_FORMAT_OPTIONAL); - MUTTMENU *menu = (MUTTMENU *) data; + MUTTMENU *menu = data.ptr; *buf = 0; switch (op) { @@ -450,9 +450,9 @@ static const char *compose_format_str (char *buf, ssize_t buflen, char op, } if (optional) - compose_status_line (buf, buflen, menu, ifstring); + compose_status_line (buf, buflen, menu, ifstr); else if (flags & M_FORMAT_OPTIONAL) - compose_status_line (buf, buflen, menu, elsestring); + compose_status_line (buf, buflen, menu, elstr); return (src); } @@ -461,7 +461,7 @@ static void compose_status_line (char *buf, ssize_t buflen, MUTTMENU * menu, const char *p) { int w=(COLS-SW)>buflen?buflen:(COLS-SW); - m_strformat(buf, w, p, compose_format_str, (unsigned long)menu, 0); + m_strformat(buf, w, p, compose_format_str, menu, 0); } /* return values: diff --git a/lib-crypt/crypt-gpgme.c b/lib-crypt/crypt-gpgme.c index 7b85ab6..1c6990b 100644 --- a/lib-crypt/crypt-gpgme.c +++ b/lib-crypt/crypt-gpgme.c @@ -2126,8 +2126,8 @@ int smime_gpgme_application_handler (BODY * a, STATE * s) static const char * crypt_entry_fmt (char *dest, ssize_t destlen, char op, const char *src, const char *prefix, - const char *ifstring, const char *elsestring, - unsigned long data, format_flag flags) + const char *ifstr, const char *elstr, + anytype data, format_flag flags) { char fmt[16]; crypt_entry_t *entry; @@ -2137,7 +2137,7 @@ crypt_entry_fmt (char *dest, ssize_t destlen, char op, const char *s = NULL; unsigned long val; - entry = (crypt_entry_t *) data; + entry = data.ptr; key = entry->key; /* if (isupper ((unsigned char) op)) */ @@ -2309,9 +2309,9 @@ crypt_entry_fmt (char *dest, ssize_t destlen, char op, } if (optional) - m_strformat (dest, destlen, ifstring, mutt_attach_fmt, data, 0); + m_strformat (dest, destlen, ifstr, mutt_attach_fmt, data, 0); else if (flags & M_FORMAT_OPTIONAL) - m_strformat (dest, destlen, elsestring, mutt_attach_fmt, data, 0); + m_strformat (dest, destlen, elstr, mutt_attach_fmt, data, 0); return (src); } @@ -2325,7 +2325,7 @@ static void crypt_entry (char *s, ssize_t l, MUTTMENU * menu, int num) entry.num = num + 1; m_strformat(s, l, NONULL (PgpEntryFormat), crypt_entry_fmt, - (unsigned long) &entry, + (void*)&entry, option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0); } diff --git a/lib-crypt/pgpinvoke.c b/lib-crypt/pgpinvoke.c index a8f0bb8..8feba18 100644 --- a/lib-crypt/pgpinvoke.c +++ b/lib-crypt/pgpinvoke.c @@ -37,11 +37,11 @@ struct pgp_command_context { static const char * _mutt_fmt_pgp_command(char *dest, ssize_t destlen, char op, const char *src, const char *prefix, - const char *ifstring, const char *elsestring, - unsigned long data, format_flag flags) + const char *ifstr, const char *elstr, + anytype data, format_flag flags) { char fmt[16]; - struct pgp_command_context *cctx = (struct pgp_command_context *) data; + struct pgp_command_context *cctx = data.ptr; int optional = (flags & M_FORMAT_OPTIONAL); switch (op) { @@ -108,9 +108,9 @@ _mutt_fmt_pgp_command(char *dest, ssize_t destlen, } if (optional) - m_strformat(dest, destlen, ifstring, _mutt_fmt_pgp_command, data, 0); + m_strformat(dest, destlen, ifstr, _mutt_fmt_pgp_command, data, 0); else if (flags & M_FORMAT_OPTIONAL) - m_strformat(dest, destlen, elsestring, _mutt_fmt_pgp_command, data, 0); + m_strformat(dest, destlen, elstr, _mutt_fmt_pgp_command, data, 0); return (src); } @@ -119,8 +119,7 @@ static void mutt_pgp_command(char *d, ssize_t dlen, struct pgp_command_context *cctx, const char *fmt) { - m_strformat (d, dlen, NONULL (fmt), _mutt_fmt_pgp_command, - (unsigned long) cctx, 0); + m_strformat(d, dlen, NONULL (fmt), _mutt_fmt_pgp_command, cctx, 0); } /* diff --git a/lib-crypt/pgpkey.c b/lib-crypt/pgpkey.c index 44facd6..b1ded7c 100644 --- a/lib-crypt/pgpkey.c +++ b/lib-crypt/pgpkey.c @@ -99,8 +99,8 @@ typedef struct pgp_entry { static const char * pgp_entry_fmt (char *dest, ssize_t destlen, char op, const char *src, const char *prefix, - const char *ifstring, const char *elsestring, - unsigned long data, format_flag flags) + const char *ifstr, const char *elstr, + anytype data, format_flag flags) { char fmt[16]; pgp_entry_t *entry; @@ -109,7 +109,7 @@ pgp_entry_fmt (char *dest, ssize_t destlen, char op, int kflags = 0; int optional = (flags & M_FORMAT_OPTIONAL); - entry = (pgp_entry_t *) data; + entry = data.ptr; uid = entry->uid; key = uid->parent; pkey = pgp_principal_key (key); @@ -236,9 +236,9 @@ pgp_entry_fmt (char *dest, ssize_t destlen, char op, } if (optional) - m_strformat (dest, destlen, ifstring, mutt_attach_fmt, data, 0); + m_strformat (dest, destlen, ifstr, mutt_attach_fmt, data, 0); else if (flags & M_FORMAT_OPTIONAL) - m_strformat (dest, destlen, elsestring, mutt_attach_fmt, data, 0); + m_strformat (dest, destlen, elstr, mutt_attach_fmt, data, 0); return (src); } @@ -251,7 +251,7 @@ static void pgp_entry (char *s, ssize_t l, MUTTMENU * menu, int num) entry.num = num + 1; m_strformat(s, l, NONULL (PgpEntryFormat), pgp_entry_fmt, - (unsigned long)&entry, + (void*)&entry, option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0); } diff --git a/lib-crypt/smime.c b/lib-crypt/smime.c index bbaa198..0178d60 100644 --- a/lib-crypt/smime.c +++ b/lib-crypt/smime.c @@ -115,11 +115,11 @@ int smime_valid_passphrase (void) static const char * _mutt_fmt_smime_command (char *dest, ssize_t destlen, char op, const char *src, const char *prefix, - const char *ifstring, const char *elsestring, - unsigned long data, format_flag flags) + const char *ifstr, const char *elstr, + anytype data, format_flag flags) { char fmt[16]; - struct smime_command_context *cctx = (struct smime_command_context *) data; + struct smime_command_context *cctx = data.ptr; int optional = (flags & M_FORMAT_OPTIONAL); switch (op) { @@ -219,9 +219,9 @@ _mutt_fmt_smime_command (char *dest, ssize_t destlen, char op, } if (optional) - m_strformat(dest, destlen, ifstring, _mutt_fmt_smime_command, data, 0); + m_strformat(dest, destlen, ifstr, _mutt_fmt_smime_command, data, 0); else if (flags & M_FORMAT_OPTIONAL) - m_strformat(dest, destlen, elsestring, _mutt_fmt_smime_command, data, 0); + m_strformat(dest, destlen, elstr, _mutt_fmt_smime_command, data, 0); return (src); } @@ -232,8 +232,7 @@ static void mutt_smime_command (char *d, ssize_t dlen, struct smime_command_context *cctx, const char *fmt) { - m_strformat(d, dlen, NONULL (fmt), _mutt_fmt_smime_command, - (unsigned long)cctx, 0); + m_strformat(d, dlen, NONULL (fmt), _mutt_fmt_smime_command, cctx, 0); } static pid_t smime_invoke (FILE ** smimein, FILE ** smimeout, diff --git a/lib-lib/lib-lib.h b/lib-lib/lib-lib.h index 6aead29..c19a9ac 100644 --- a/lib-lib/lib-lib.h +++ b/lib-lib/lib-lib.h @@ -114,4 +114,11 @@ #include "rx.h" #include "url.h" +typedef union __attribute__((transparent_union)) anytype { + void *ptr; + long li; + int i; + short si; +} anytype; + #endif diff --git a/lib-mx/compress.c b/lib-mx/compress.c index 00064b7..b9b237c 100644 --- a/lib-mx/compress.c +++ b/lib-mx/compress.c @@ -137,14 +137,14 @@ static int get_size (const char *path) static const char *compresshook_format_str (char *dest, ssize_t destlen, char op, const char *src, const char *fmt, - const char *ifstring __attribute__ ((unused)), - const char *elsestring __attribute__ ((unused)), - unsigned long data, + const char *ifstr __attribute__ ((unused)), + const char *elstr __attribute__ ((unused)), + anytype data, format_flag flags __attribute__ ((unused))) { char tmp[STRING]; - CONTEXT *ctx = (CONTEXT *) data; + CONTEXT *ctx = data.ptr; switch (op) { case 'f': @@ -172,7 +172,7 @@ static char *get_compression_cmd (const char *cmd, const CONTEXT * ctx) char expanded[_POSIX_PATH_MAX]; m_strformat(expanded, sizeof (expanded), cmd, compresshook_format_str, - (unsigned long)ctx, 0); + (void *)ctx, 0); return m_strdup(expanded); } diff --git a/lib-ui/hdrline.c b/lib-ui/hdrline.c index 3d22756..ee03a15 100644 --- a/lib-ui/hdrline.c +++ b/lib-ui/hdrline.c @@ -215,11 +215,11 @@ static const char *hdr_format_str (char *dest, char op, const char *src, const char *prefix, - const char *ifstring, - const char *elsestring, - unsigned long data, format_flag flags) + const char *ifstr, + const char *elstr, + anytype data, format_flag flags) { - struct hdr_format_info *hfi = (struct hdr_format_info *) data; + struct hdr_format_info *hfi = data.ptr; HEADER *hdr, *htmp; CONTEXT *ctx; char fmt[STRING], buf2[STRING], ch, *p; @@ -707,11 +707,9 @@ static const char *hdr_format_str (char *dest, } if (optional) - m_strformat(dest, destlen, ifstring, hdr_format_str, - (unsigned long)hfi, flags); + m_strformat(dest, destlen, ifstr, hdr_format_str, data, flags); else if (flags & M_FORMAT_OPTIONAL) - m_strformat(dest, destlen, elsestring, hdr_format_str, - (unsigned long)hfi, flags); + m_strformat(dest, destlen, elstr, hdr_format_str, data, flags); return (src); #undef THREAD_NEW @@ -727,5 +725,5 @@ _mutt_make_string (char *dest, ssize_t destlen, const char *s, CONTEXT * ctx, hfi.hdr = hdr; hfi.ctx = ctx; - m_strformat(dest, destlen, s, hdr_format_str, (unsigned long) &hfi, flags); + m_strformat(dest, destlen, s, hdr_format_str, &hfi, flags); } diff --git a/lib-ui/sidebar.c b/lib-ui/sidebar.c index e55537f..9dcfce8 100644 --- a/lib-ui/sidebar.c +++ b/lib-ui/sidebar.c @@ -95,9 +95,9 @@ static char *shortened_hierarchy (char *hbox, int maxlen) 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, - unsigned long data, format_flag flags) { + anytype data, format_flag flags) { char tmp[STRING]; - BUFFY* b = Incoming.arr[data]; + BUFFY* b = Incoming.arr[data.i]; int opt = flags & M_FORMAT_OPTIONAL; int c = Context && !m_strcmp(Context->path, b->path); diff --git a/lib-ui/status.c b/lib-ui/status.c index 3da31d9..ffbdaee 100644 --- a/lib-ui/status.c +++ b/lib-ui/status.c @@ -48,14 +48,14 @@ static char *get_sort_str (char *buf, ssize_t buflen, int method) * %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 *ifstring, - const char *elsestring, - unsigned long data, format_flag flags) + const char *ifstr, + const char *elstr, + anytype data, format_flag flags) { char fmt[STRING], tmp[STRING]; const char *cp, *p; int count, optional = (flags & M_FORMAT_OPTIONAL); - MUTTMENU *menu = (MUTTMENU *) data; + MUTTMENU *menu = data.ptr; *buf = 0; switch (op) { @@ -280,9 +280,9 @@ static const char *status_format_str (char *buf, ssize_t buflen, char op, } if (optional) - menu_status_line (buf, buflen, menu, ifstring); + menu_status_line (buf, buflen, menu, ifstr); else if (flags & M_FORMAT_OPTIONAL) - menu_status_line (buf, buflen, menu, elsestring); + menu_status_line (buf, buflen, menu, elstr); return (src); } @@ -293,7 +293,6 @@ void menu_status_line (char* buf, ssize_t len, MUTTMENU* menu, const char* p) { * only to not wrap past end of screen */ int width = COLS - SW; - m_strformat (buf, (width >= len ? len : (width + 1)), - p, status_format_str, - (unsigned long) menu, 0); + m_strformat(buf, (width >= len ? len : (width + 1)), p, status_format_str, + menu, 0); } diff --git a/muttlib.c b/muttlib.c index 876c69c..c0cde0c 100644 --- a/muttlib.c +++ b/muttlib.c @@ -329,7 +329,7 @@ void mutt_safe_path(char *s, ssize_t l, address_t *a) } ssize_t m_strformat(char *dst, ssize_t dlen, const char *fmt, - format_t *callback, unsigned long data, format_flag flags) + format_t *callback, anytype cdata, format_flag flags) { ssize_t pos = flags & M_FORMAT_ARROWCURSOR ? 3 : 0; @@ -340,9 +340,9 @@ ssize_t m_strformat(char *dst, ssize_t dlen, const char *fmt, int ch; if (*fmt == '%') { - char ifstring[STRING], elsestring[STRING], prefix[STRING]; + char ifstr[STRING], elstr[STRING], prefix[STRING]; - *ifstring = *elsestring = *prefix = '\0'; + *ifstr = *elstr = *prefix = '\0'; if (*++fmt == '%') { pos += m_strputc(dst + pos, dlen - pos, *fmt++); @@ -375,7 +375,7 @@ ssize_t m_strformat(char *dst, ssize_t dlen, const char *fmt, /* eat the `if' part of the string */ iflen = strcspn(fmt, "?&"); - m_strncpy(ifstring, ssizeof(ifstring), fmt, iflen); + m_strncpy(ifstr, ssizeof(ifstr), fmt, iflen); fmt += iflen; /* eat the `else' part of the string (optional) */ @@ -383,7 +383,7 @@ ssize_t m_strformat(char *dst, ssize_t dlen, const char *fmt, fmt++; /* skip the & */ p = m_strchrnul(fmt, '?'); - m_strncpy(elsestring, ssizeof(elsestring), fmt, p - fmt); + m_strncpy(elstr, ssizeof(elstr), fmt, p - fmt); fmt = p; if (!*fmt++) /* move past the trailing `?' */ @@ -400,7 +400,7 @@ ssize_t m_strformat(char *dst, ssize_t dlen, const char *fmt, ch = *fmt++; /* pad char */ if (COLS - SW > col) { - m_strformat(buf, sizeof(buf), fmt, callback, data, flags); + m_strformat(buf, sizeof(buf), fmt, callback, cdata, flags); pos += m_strpad(dst + pos, dlen - pos, ch, COLS - SW - col - mutt_strwidth(buf)); pos += m_strcpy(dst + pos, dlen - pos, buf); @@ -422,7 +422,7 @@ ssize_t m_strformat(char *dst, ssize_t dlen, const char *fmt, /* use callback function to handle this case */ fmt = callback(buf, sizeof (buf), ch, fmt, prefix, - ifstring, elsestring, data, flags); + ifstr, elstr, cdata, flags); if (lower) m_strtolower(buf); diff --git a/nntp/newsrc.c b/nntp/newsrc.c index 2c95d8b..d80b21d 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -237,10 +237,12 @@ static int nntp_parse_cacheindex (NNTP_SERVER * news) return 0; } -const char *nntp_format_str (char *dest, ssize_t destlen, char op, - const char *src, const char *fmt, - const char *ifstring, const char *elsestring, - unsigned long data, format_flag flags) +const char *nntp_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 __attribute__((unused)), + format_flag flags __attribute__((unused))) { char fn[STRING], tmp[STRING]; @@ -344,8 +346,7 @@ NNTP_SERVER *mutt_select_newsserver (char *server) if (!conn) return NULL; - m_strformat (file, sizeof (file), NONULL (NewsRc), nntp_format_str, 0, - 0); + m_strformat(file, sizeof(file), NONULL(NewsRc), nntp_format_str, NULL, 0); mutt_expand_path (file, sizeof (file)); serv = (NNTP_SERVER *) conn->data; diff --git a/nntp/nntp.h b/nntp/nntp.h index 9baaed7..bdd2936 100644 --- a/nntp/nntp.h +++ b/nntp/nntp.h @@ -110,9 +110,8 @@ int nntp_check_children (CONTEXT *, const char *); void nntp_buffy (char* dst, ssize_t dstlen); void nntp_expand_path (char *, ssize_t, ACCOUNT *); void nntp_logout_all(void); -const char *nntp_format_str (char *, ssize_t, char, const char *, const char *, - const char *, const char *, unsigned long, - format_flag); +const char *nntp_format_str(char *, ssize_t, char, const char *, const char *, + const char *, const char *, anytype, format_flag); void nntp_sync_sidebar (NNTP_DATA*); WHERE NNTP_SERVER *CurrentNewsSrv INITVAL (NULL); diff --git a/protos.h b/protos.h index 2dc73ef..2f96bbc 100644 --- a/protos.h +++ b/protos.h @@ -16,10 +16,10 @@ void mutt_mktemp (char *) __attribute__((deprecated)); typedef const char *format_t (char *, ssize_t, char, const char *, const char *, const char *, const char *, - unsigned long, format_flag); + anytype, format_flag); ssize_t m_strformat(char *, ssize_t, const char *, format_t *, - unsigned long, format_flag); + anytype, format_flag); void set_quadoption (int, int); int query_quadoption (int, const char *); diff --git a/recvattach.c b/recvattach.c index ab21e54..8d94955 100644 --- a/recvattach.c +++ b/recvattach.c @@ -139,19 +139,18 @@ ATTACHPTR **mutt_gen_attach_list (BODY * m, * %s = size * %u = unlink */ -const char *mutt_attach_fmt (char *dest, - ssize_t destlen, +const char *mutt_attach_fmt (char *dest, ssize_t destlen, char op, const char *src, const char *prefix, - const char *ifstring, - const char *elsestring, - unsigned long data, format_flag flags) + const char *ifstr, + const char *elstr, + anytype data, format_flag flags) { char fmt[16]; char tmp[STRING]; char charset[STRING]; - ATTACHPTR *aptr = (ATTACHPTR *) data; + ATTACHPTR *aptr = data.ptr; int optional = (flags & M_FORMAT_OPTIONAL); ssize_t l; @@ -313,9 +312,9 @@ const char *mutt_attach_fmt (char *dest, } if (optional) - m_strformat (dest, destlen, ifstring, mutt_attach_fmt, data, 0); + m_strformat (dest, destlen, ifstr, mutt_attach_fmt, data, 0); else if (flags & M_FORMAT_OPTIONAL) - m_strformat (dest, destlen, elsestring, mutt_attach_fmt, data, 0); + m_strformat (dest, destlen, elstr, mutt_attach_fmt, data, 0); return (src); } @@ -323,7 +322,7 @@ static void attach_entry (char *b, ssize_t blen, MUTTMENU * menu, int num) { int w=(COLS-SW)>blen?blen:(COLS-SW); m_strformat (b, w, NONULL (AttachFormat), mutt_attach_fmt, - (unsigned long) (((ATTACHPTR **) menu->data)[num]), + ((ATTACHPTR **) menu->data)[num], option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0); } diff --git a/recvattach.h b/recvattach.h index cb7c9a6..d0d1243 100644 --- a/recvattach.h +++ b/recvattach.h @@ -25,9 +25,9 @@ const char *mutt_attach_fmt (char *dest, char op, const char *src, const char *prefix, - const char *ifstring, - const char *elsestring, - unsigned long data, format_flag flags); + const char *ifstr, + const char *elstr, + anytype data, format_flag flags); int mutt_tag_attach (MUTTMENU * menu, int n, int m); diff --git a/remailer.c b/remailer.c index bfb66b1..4722c1a 100644 --- a/remailer.c +++ b/remailer.c @@ -340,17 +340,13 @@ static const char *mix_format_caps (remailer_t * r) * %a address * */ -static const char *mix_entry_fmt (char *dest, - ssize_t destlen, - char op, - const char *src, - const char *prefix, - const char *ifstring, - const char *elsestring, - unsigned long data, format_flag flags) +static const char * +mix_entry_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]; - remailer_t *remailer = (remailer_t *) data; + remailer_t *remailer = data.ptr; int optional = (flags & M_FORMAT_OPTIONAL); switch (op) { @@ -388,9 +384,9 @@ static const char *mix_entry_fmt (char *dest, } if (optional) - m_strformat (dest, destlen, ifstring, mutt_attach_fmt, data, 0); + m_strformat (dest, destlen, ifstr, mutt_attach_fmt, data, 0); else if (flags & M_FORMAT_OPTIONAL) - m_strformat (dest, destlen, elsestring, mutt_attach_fmt, data, 0); + m_strformat (dest, destlen, elstr, mutt_attach_fmt, data, 0); return (src); } @@ -402,7 +398,7 @@ static void mix_entry (char *b, ssize_t blen, MUTTMENU * menu, int num) int w = (COLS-SW) > blen ? blen : (COLS-SW); m_strformat(b, w, NONULL (MixEntryFormat), mix_entry_fmt, - (unsigned long) type2_list[num], + type2_list[num], option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0); } diff --git a/sendlib.c b/sendlib.c index c7e8bfd..2c9b534 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1840,8 +1840,7 @@ static int mutt_invoke_sendmail (address_t * from, /* the sender */ if (option (OPTNEWSSEND)) { char cmd[LONG_STRING]; - m_strformat (cmd, sizeof (cmd), NONULL (Inews), nntp_format_str, 0, - 0); + m_strformat(cmd, sizeof (cmd), NONULL (Inews), nntp_format_str, 0, 0); if (m_strisempty(cmd)) { i = nntp_post (msg); unlink (msg);