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;
+ string_list_t *refs[10];
+ int i;
- for (; (TrimRef == 0 || refcnt < TrimRef) && r; r = r->next) {
- if (refcnt == refmax)
- p_realloc(&ref, refmax += REF_INC);
- ref[refcnt++] = r;
- }
-
- 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)
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) \
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;
}
break;
default: /* invalid formats are replaced by '.' */
APPEND_BYTE('.');
- m_strncat(buf, len, ".", 1);
}
}
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)))