Changeset 5457:7729b1ad530c

Show
Ignore:
Timestamp:
2008-07-10 06:38:25 (5 months ago)
Author:
Aron Griffis <agriffis@…>
Branch:
HEAD
Message:

Unify mutt_write_references

copy.c and sendlib.c have independent and different implementations of writing
references to a file. Choose the one in sendlib since it's conservative with
mallocs and supports trimming the list.

Signed-off-by: Aron Griffis <agriffis@…>

Files:
3 modified

Legend:

Unmodified
Added
Removed
  • copy.c

    r5456 r5457  
    370370      { 
    371371        LIST *listp = h->env->in_reply_to; 
    372         fputs ("In-Reply-To: ", out); 
     372        fputs ("In-Reply-To:", out); 
    373373        for (; listp; listp = listp->next) 
    374374        { 
     375          fputc (' ', out); 
    375376          fputs (listp->data, out); 
    376           fputc (' ', out); 
    377377        } 
    378378        fputc ('\n', out); 
     
    382382      { 
    383383        LIST *listp = h->env->references, *refs = NULL, *t; 
    384         fputs ("References: ", out); 
    385  
    386         /* Mutt stores references in reverse order, thus we create 
    387          * a reordered refs list that we can put in the headers */ 
    388         for (; listp; listp = listp->next, refs = t) 
    389         { 
    390           t = (LIST *)safe_malloc (sizeof (LIST)); 
    391           t->data = listp->data; 
    392           t->next = refs; 
    393         } 
    394  
    395         for (; refs; refs = refs->next) 
    396         { 
    397           fputs (refs->data, out); 
    398           fputc (' ', out); 
    399         } 
    400  
    401         /* clearing refs from memory */ 
    402         for (t = refs; refs; refs = t->next, t = refs) 
    403           FREE (&refs); 
    404  
     384        fputs ("References:", out); 
     385        mutt_write_references (h->env->references, out, 0); 
    405386        fputc ('\n', out); 
    406387      } 
  • protos.h

    r5448 r5457  
    372372int mutt_write_one_header (FILE *fp, const char *tag, const char *value, const char *pfx, int wraplen); 
    373373int mutt_write_rfc822_header (FILE *, ENVELOPE *, BODY *, int, int); 
     374void mutt_write_references (LIST *, FILE *, int); 
    374375int mutt_yesorno (const char *, int); 
    375376void mutt_set_header_color(CONTEXT *, HEADER *); 
  • sendlib.c

    r5397 r5457  
    15211521#define REF_INC 16 
    15221522 
    1523 #define TrimRef 10 
    1524  
    15251523/* need to write the list in reverse because they are stored in reverse order 
    15261524 * when parsed to speed up threading 
    15271525 */ 
    1528 static void write_references (LIST *r, FILE *f) 
     1526void mutt_write_references (LIST *r, FILE *f, int trim) 
    15291527{ 
    15301528  LIST **ref = NULL; 
    15311529  int refcnt = 0, refmax = 0; 
    15321530 
    1533   for ( ; (TrimRef == 0 || refcnt < TrimRef) && r ; r = r->next) 
     1531  for ( ; (trim == 0 || refcnt < trim) && r ; r = r->next) 
    15341532  { 
    15351533    if (refcnt == refmax) 
     
    18261824    { 
    18271825      fputs ("References:", fp); 
    1828       write_references (env->references, fp); 
     1826      mutt_write_references (env->references, fp, 10); 
    18291827      fputc('\n', fp); 
    18301828    } 
     
    18381836  { 
    18391837    fputs ("In-Reply-To:", fp); 
    1840     write_references (env->in_reply_to, fp); 
     1838    mutt_write_references (env->in_reply_to, fp, 1); 
    18411839    fputc ('\n', fp); 
    18421840  }