From f288d1771c814e6104da83e6f0f1761a40de1224 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Fri, 17 Nov 2006 22:03:38 +0100 Subject: [PATCH] more moves and dead code Signed-off-by: Pierre Habouzit --- imap/message.c | 44 +++++++++++++++ keymap.c | 6 +- lib-mime/rfc3676.c | 14 +++++ muttlib.c | 135 ++++++++++----------------------------------- protos.h | 9 --- sendlib.c | 2 +- 6 files changed, 88 insertions(+), 122 deletions(-) diff --git a/imap/message.c b/imap/message.c index 8412c61..1f634af 100644 --- a/imap/message.c +++ b/imap/message.c @@ -291,6 +291,50 @@ int imap_read_headers (IMAP_DATA * idata, int msgbegin, int msgend) return msgend; } +/* move all the headers from extra not present in base into base */ +static void mutt_merge_envelopes(ENVELOPE* base, ENVELOPE** extra) +{ + /* copies each existing element if necessary, and sets the element + * to NULL in the source so that envelope_delete doesn't leave us + * with dangling pointers. */ +#define MOVE_ELEM(h) if (!base->h) { base->h = (*extra)->h; (*extra)->h = NULL; } + MOVE_ELEM(return_path); + MOVE_ELEM(from); + MOVE_ELEM(to); + MOVE_ELEM(cc); + MOVE_ELEM(bcc); + MOVE_ELEM(sender); + MOVE_ELEM(reply_to); + MOVE_ELEM(mail_followup_to); + MOVE_ELEM(list_post); + MOVE_ELEM(message_id); + MOVE_ELEM(supersedes); + MOVE_ELEM(date); + MOVE_ELEM(x_label); + if (!base->refs_changed) { + MOVE_ELEM(references); + } + if (!base->irt_changed) { + MOVE_ELEM(in_reply_to); + } + /* real_subj is subordinate to subject */ + if (!base->subject) { + base->subject = (*extra)->subject; + base->real_subj = (*extra)->real_subj; + (*extra)->subject = NULL; + (*extra)->real_subj = NULL; + } + /* spam and user headers should never be hashed, and the new envelope may + * have better values. Use new versions regardless. */ + mutt_buffer_free (&base->spam); + string_list_wipe(&base->userhdrs); + MOVE_ELEM(spam); + MOVE_ELEM(userhdrs); +#undef MOVE_ELEM + + envelope_delete(extra); +} + int imap_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) { IMAP_DATA *idata; diff --git a/keymap.c b/keymap.c index 51a296f..7be6869 100644 --- a/keymap.c +++ b/keymap.c @@ -36,19 +36,15 @@ struct mapping_t Menus[] = { {"key_select_smime", MENU_KEY_SELECT_SMIME}, #endif - #ifdef MIXMASTER {"mix", MENU_MIX}, #endif - {"query", MENU_QUERY}, {"generic", MENU_GENERIC}, {NULL, 0} }; -#define mutt_check_menu(s) mutt_getvaluebyname(s, Menus) - static struct mapping_t KeyNames[] = { {"", KEY_PPAGE}, {"", KEY_NPAGE}, @@ -673,7 +669,7 @@ static char *parse_keymap (int *menu, BUFFER * s, int maxmenus, int *nummenus, if (q) *q = '\0'; - if ((menu[i] = mutt_check_menu (p)) == -1) { + if ((menu[i] = mutt_getvaluebyname(p, Menus)) == -1) { snprintf (err->data, err->dsize, _("%s: no such menu"), p); goto error; } diff --git a/lib-mime/rfc3676.c b/lib-mime/rfc3676.c index e9ae0a7..404b02b 100644 --- a/lib-mime/rfc3676.c +++ b/lib-mime/rfc3676.c @@ -11,6 +11,8 @@ #include +#include + #include #include "state.h" @@ -200,6 +202,18 @@ int rfc3676_handler (BODY * a, STATE * s) { return (0); } +/* sets mtime of 'to' to mtime of 'from' */ +static void mutt_set_mtime (const char* from, const char* to) { + struct utimbuf utim; + struct stat st; + + if (stat (from, &st) != -1) { + utim.actime = st.st_mtime; + utim.modtime = st.st_mtime; + utime (to, &utim); + } +} + void rfc3676_space_stuff (HEADER* hdr) { FILE* in = NULL, *out = NULL; char buf[LONG_STRING]; diff --git a/muttlib.c b/muttlib.c index 2cf42eb..efb991b 100644 --- a/muttlib.c +++ b/muttlib.c @@ -150,29 +150,6 @@ int mutt_matches_ignore (const char *s, string_list_t * t) return 0; } -/* prepend the path part of *path to *lnk */ -void mutt_expand_link (char *newpath, const char *path, const char *lnk) -{ - const char *lb = NULL; - ssize_t len; - - /* lnk is full path */ - if (*lnk == '/') { - m_strcpy(newpath, _POSIX_PATH_MAX, lnk); - return; - } - - if ((lb = strrchr (path, '/')) == NULL) { - /* no path in lnk */ - m_strcpy(newpath, _POSIX_PATH_MAX, lnk); - return; - } - - len = lb - path + 1; - memcpy (newpath, path, len); - m_strcpy(newpath + len, _POSIX_PATH_MAX - len, lnk); -} - char *mutt_expand_path (char *s, ssize_t slen) { return _mutt_expand_path (s, slen, 0); @@ -325,50 +302,6 @@ char *_mutt_expand_path (char *s, ssize_t slen, int rx) return (s); } -/* move all the headers from extra not present in base into base */ -void mutt_merge_envelopes(ENVELOPE* base, ENVELOPE** extra) -{ - /* copies each existing element if necessary, and sets the element - * to NULL in the source so that envelope_delete doesn't leave us - * with dangling pointers. */ -#define MOVE_ELEM(h) if (!base->h) { base->h = (*extra)->h; (*extra)->h = NULL; } - MOVE_ELEM(return_path); - MOVE_ELEM(from); - MOVE_ELEM(to); - MOVE_ELEM(cc); - MOVE_ELEM(bcc); - MOVE_ELEM(sender); - MOVE_ELEM(reply_to); - MOVE_ELEM(mail_followup_to); - MOVE_ELEM(list_post); - MOVE_ELEM(message_id); - MOVE_ELEM(supersedes); - MOVE_ELEM(date); - MOVE_ELEM(x_label); - if (!base->refs_changed) { - MOVE_ELEM(references); - } - if (!base->irt_changed) { - MOVE_ELEM(in_reply_to); - } - /* real_subj is subordinate to subject */ - if (!base->subject) { - base->subject = (*extra)->subject; - base->real_subj = (*extra)->real_subj; - (*extra)->subject = NULL; - (*extra)->real_subj = NULL; - } - /* spam and user headers should never be hashed, and the new envelope may - * have better values. Use new versions regardless. */ - mutt_buffer_free (&base->spam); - string_list_wipe(&base->userhdrs); - MOVE_ELEM(spam); - MOVE_ELEM(userhdrs); -#undef MOVE_ELEM - - envelope_delete(extra); -} - void mutt_mktemp (char *s) { @@ -899,18 +832,6 @@ time_t mutt_decrease_mtime (const char *f, struct stat *st) return mtime; } -/* sets mtime of 'to' to mtime of 'from' */ -void mutt_set_mtime (const char* from, const char* to) { - struct utimbuf utim; - struct stat st; - - if (stat (from, &st) != -1) { - utim.actime = st.st_mtime; - utim.modtime = st.st_mtime; - utime (to, &utim); - } -} - const char *mutt_make_version (int full) { static char vstring[STRING]; @@ -983,32 +904,8 @@ int mutt_match_spam_list (const char *s, SPAM_LIST * l, char *text, int x) return 0; } -int mutt_cmp_header (const HEADER * h1, const HEADER * h2) { - if (h1 && h2) { - if (h1->received != h2->received || - h1->date_sent != h2->date_sent || - h1->content->length != h2->content->length || - h1->lines != h2->lines || - h1->zhours != h2->zhours || - h1->zminutes != h2->zminutes || - h1->zoccident != h2->zoccident || - h1->mime != h2->mime || - !mutt_cmp_env (h1->env, h2->env) || - !mutt_cmp_body (h1->content, h2->content)) - return (0); - else - return (1); - } - else { - if (h1 == NULL && h2 == NULL) - return (1); - else - return (0); - } -} - /* return 1 if address lists are strictly identical */ -int mutt_cmp_addr (const address_t * a, const address_t * b) +static int mutt_cmp_addr (const address_t * a, const address_t * b) { while (a && b) { if (m_strcmp(a->mailbox, b->mailbox) || @@ -1024,7 +921,7 @@ int mutt_cmp_addr (const address_t * a, const address_t * b) return (1); } -int mutt_cmp_list (const string_list_t * a, const string_list_t * b) +static int mutt_cmp_list (const string_list_t * a, const string_list_t * b) { while (a && b) { if (m_strcmp(a->data, b->data)) @@ -1039,7 +936,7 @@ int mutt_cmp_list (const string_list_t * a, const string_list_t * b) return (1); } -int mutt_cmp_env (const ENVELOPE * e1, const ENVELOPE * e2) +static int mutt_cmp_env (const ENVELOPE * e1, const ENVELOPE * e2) { if (e1 && e2) { if (m_strcmp(e1->message_id, e2->message_id) || @@ -1063,7 +960,7 @@ int mutt_cmp_env (const ENVELOPE * e1, const ENVELOPE * e2) } } -int mutt_cmp_body (const BODY * b1, const BODY * b2) +static int mutt_cmp_body (const BODY * b1, const BODY * b2) { if (b1->type != b2->type || b1->encoding != b2->encoding || @@ -1074,6 +971,30 @@ int mutt_cmp_body (const BODY * b1, const BODY * b2) return (0); return (1); } +int mutt_cmp_header (const HEADER * h1, const HEADER * h2) { + if (h1 && h2) { + if (h1->received != h2->received || + h1->date_sent != h2->date_sent || + h1->content->length != h2->content->length || + h1->lines != h2->lines || + h1->zhours != h2->zhours || + h1->zminutes != h2->zminutes || + h1->zoccident != h2->zoccident || + h1->mime != h2->mime || + !mutt_cmp_env (h1->env, h2->env) || + !mutt_cmp_body (h1->content, h2->content)) + return (0); + else + return (1); + } + else { + if (h1 == NULL && h2 == NULL) + return (1); + else + return (0); + } +} + int mutt_extract_token(BUFFER *dest, BUFFER *tok, int flags) { diff --git a/protos.h b/protos.h index 4ca6313..586adaa 100644 --- a/protos.h +++ b/protos.h @@ -32,13 +32,8 @@ BODY *mutt_make_multipart (BODY *); CONTENT *mutt_get_content_info (const char *fname, BODY * b); int mutt_cmp_header (const HEADER*, const HEADER*); -int mutt_cmp_addr (const address_t * a, const address_t * b); -int mutt_cmp_list (const string_list_t * a, const string_list_t * b); -int mutt_cmp_env (const ENVELOPE * e1, const ENVELOPE * e2); -int mutt_cmp_body (const BODY * b1, const BODY * b2); time_t mutt_decrease_mtime (const char *, struct stat *); -void mutt_set_mtime (const char*, const char*); int is_from (const char *, char *, ssize_t, time_t *); const char *mutt_charset_hook (const char *); @@ -46,7 +41,6 @@ const char *mutt_iconv_hook (const char *); char *mutt_expand_path (char *, ssize_t); char *_mutt_expand_path (char *, ssize_t, int); char *mutt_find_hook (int, const char *); -char *mutt_gen_msgid (void); char *mutt_get_body_charset (char *, ssize_t, BODY *); const char *mutt_get_name (address_t *); const char *mutt_crypt_hook (address_t *); @@ -69,7 +63,6 @@ void mutt_edit_headers (const char *, const char *, HEADER *, char *, ssize_t); void mutt_enter_command (void); void mutt_expand_file_fmt (char *, ssize_t, const char *, const char *); void mutt_expand_fmt (char *, ssize_t, const char *, const char *); -void mutt_expand_link (char *, const char *, const char *); void mutt_fix_reply_recipients (ENVELOPE * env); void mutt_folder_hook (char *); void mutt_forward_intro (FILE * fp, HEADER * cur); @@ -83,7 +76,6 @@ char *mutt_compile_help(char *, ssize_t, int, struct mapping_t *); void mutt_make_misc_reply_headers (ENVELOPE * env, CONTEXT * ctx, HEADER * cur, ENVELOPE * curenv); void mutt_make_post_indent (CONTEXT * ctx, HEADER * cur, FILE * out); -void mutt_merge_envelopes (ENVELOPE* base, ENVELOPE** extra); void mutt_message_to_7bit (BODY *, FILE *); void mutt_mktemp (char *); @@ -116,7 +108,6 @@ void mutt_write_address_list (address_t * adr, FILE * fp, int linelen, int mutt_can_decode (BODY *); int mutt_change_flag (HEADER *, int); -int mutt_check_menu (const char *); int mutt_check_month (const char *); int mutt_check_overwrite (const char *, const char *, char *, ssize_t, int *, char **); diff --git a/sendlib.c b/sendlib.c index ae595c3..4dfca68 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1669,7 +1669,7 @@ static void mutt_gen_localpart(char *buf, unsigned int len, const char *fmt) #undef APPEND_FMT } -char *mutt_gen_msgid (void) +static char *mutt_gen_msgid (void) { char buf[SHORT_STRING]; char localpart[SHORT_STRING]; -- 2.20.1