X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=sendlib.c;h=8c3d68c87ee1bb39a74576bdd094408344726557;hp=cfb71cfb0a6b4962315bec944deb3298556bfea0;hb=f3cbb9f51357972f6e74244494236a41dc4d84cd;hpb=6ce74784b17c30f98db577d03b03e67d9885df47 diff --git a/sendlib.c b/sendlib.c index cfb71cf..8c3d68c 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1308,31 +1308,22 @@ void mutt_write_address_list (address_t * adr, FILE * fp, int linelen, fputc ('\n', fp); } -/* arbitrary number of elements to grow the array by */ -#define REF_INC 16 - -#define TrimRef 10 - /* need to write the list in reverse because they are stored in reverse order * when parsed to speed up threading */ -void mutt_write_references (string_list_t * r, FILE * f) +void mutt_write_references(string_list_t *r, FILE *f) { - string_list_t **ref = NULL; - int refcnt = 0, refmax = 0; - - for (; (TrimRef == 0 || refcnt < TrimRef) && r; r = r->next) { - if (refcnt == refmax) - p_realloc(&ref, refmax += REF_INC); - ref[refcnt++] = r; - } + string_list_t *refs[10]; + int i; - while (refcnt-- > 0) { - fputc (' ', f); - fputs (ref[refcnt]->data, f); - } + p_clear(refs, countof(refs)); + for (i = 0; i < countof(refs) && r; r = r->next) { + refs[i++] = r; + } - p_delete(&ref); + while (i-- > 0) { + fprintf(f, " %s", refs[i]->data); + } } static int edit_header(int mode, const char *s) @@ -1543,7 +1534,7 @@ static void encode_headers (string_list_t * h) rfc2047_encode_string (&tmp); p_realloc(&h->data, m_strlen(h->data) + 2 + m_strlen(tmp) + 1); - sprintf (h->data + i, ": %s", NONULL (tmp)); /* __SPRINTF_CHECKED__ */ + sprintf (h->data + i, ": %s", NONULL (tmp)); p_delete(&tmp); } @@ -1572,12 +1563,6 @@ const char *mutt_fqdn (short may_hide_host) return p; } -/* normalized character (we're stricter than RFC2822, 3.6.4) */ -static char mutt_normalized_char(char c) -{ - return (isalnum(c) || strchr(".!#$%&'*+-/=?^_`{|}~", c)) ? c : '.'; -} - static void mutt_gen_localpart(char *buf, unsigned int len, const char *fmt) { #define APPEND_FMT(fmt, arg) \ @@ -1605,7 +1590,8 @@ static void mutt_gen_localpart(char *buf, unsigned int len, const char *fmt) int c = *fmt++; if (c != '%') { - APPEND_BYTE(mutt_normalized_char(c)); + /* normalized character (we're stricter than RFC2822, 3.6.4) */ + APPEND_BYTE((isalnum(c) || strchr(".!#$%&'*+-/=?^_`{|}~", c)) ? c : '.'); continue; } @@ -1657,7 +1643,6 @@ static void mutt_gen_localpart(char *buf, unsigned int len, const char *fmt) break; default: /* invalid formats are replaced by '.' */ APPEND_BYTE('.'); - m_strncat(buf, len, ".", 1); } } @@ -1669,16 +1654,16 @@ static void mutt_gen_localpart(char *buf, unsigned int len, const char *fmt) static char *mutt_gen_msgid (void) { - char buf[SHORT_STRING]; - char localpart[SHORT_STRING]; - const char *fqdn; + char buf[SHORT_STRING]; + char localpart[SHORT_STRING]; + const char *fqdn; - if (!(fqdn = mutt_fqdn(0))) - fqdn = NONULL(Hostname); + if (!(fqdn = mutt_fqdn(0))) + fqdn = NONULL(Hostname); - mutt_gen_localpart(localpart, sizeof(localpart), MsgIdFormat); - snprintf(buf, sizeof(buf), "<%s@%s>", localpart, fqdn); - return m_strdup(buf); + mutt_gen_localpart(localpart, sizeof(localpart), MsgIdFormat); + snprintf(buf, sizeof(buf), "<%s@%s>", localpart, fqdn); + return m_strdup(buf); } static RETSIGTYPE alarm_handler (int sig __attribute__ ((unused))) @@ -1863,7 +1848,7 @@ static int mutt_invoke_sendmail (address_t * from, /* the sender */ mutt_FormatString (cmd, sizeof (cmd), NONULL (Inews), nntp_format_str, 0, 0); - if (!*cmd) { + if (m_strisempty(cmd)) { i = nntp_post (msg); unlink (msg); return i; @@ -2232,11 +2217,9 @@ int mutt_write_fcc (const char *path, HEADER * hdr, const char *msgid, fputc ('\n', msg->fp); } -#ifdef MIXMASTER /* (postponement) if the mail is to be sent through a mixmaster * chain, save that information */ - if (post && hdr->chain && hdr->chain) { string_list_t *p; @@ -2246,7 +2229,6 @@ int mutt_write_fcc (const char *path, HEADER * hdr, const char *msgid, fputc ('\n', msg->fp); } -#endif if (tempfp) { char sasha[LONG_STRING];