Changeset 5457:7729b1ad530c
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r5456
|
r5457
|
|
| 370 | 370 | { |
| 371 | 371 | LIST *listp = h->env->in_reply_to; |
| 372 | | fputs ("In-Reply-To: ", out); |
| | 372 | fputs ("In-Reply-To:", out); |
| 373 | 373 | for (; listp; listp = listp->next) |
| 374 | 374 | { |
| | 375 | fputc (' ', out); |
| 375 | 376 | fputs (listp->data, out); |
| 376 | | fputc (' ', out); |
| 377 | 377 | } |
| 378 | 378 | fputc ('\n', out); |
| … |
… |
|
| 382 | 382 | { |
| 383 | 383 | 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); |
| 405 | 386 | fputc ('\n', out); |
| 406 | 387 | } |
-
|
r5448
|
r5457
|
|
| 372 | 372 | int mutt_write_one_header (FILE *fp, const char *tag, const char *value, const char *pfx, int wraplen); |
| 373 | 373 | int mutt_write_rfc822_header (FILE *, ENVELOPE *, BODY *, int, int); |
| | 374 | void mutt_write_references (LIST *, FILE *, int); |
| 374 | 375 | int mutt_yesorno (const char *, int); |
| 375 | 376 | void mutt_set_header_color(CONTEXT *, HEADER *); |
-
|
r5397
|
r5457
|
|
| 1521 | 1521 | #define REF_INC 16 |
| 1522 | 1522 | |
| 1523 | | #define TrimRef 10 |
| 1524 | | |
| 1525 | 1523 | /* need to write the list in reverse because they are stored in reverse order |
| 1526 | 1524 | * when parsed to speed up threading |
| 1527 | 1525 | */ |
| 1528 | | static void write_references (LIST *r, FILE *f) |
| | 1526 | void mutt_write_references (LIST *r, FILE *f, int trim) |
| 1529 | 1527 | { |
| 1530 | 1528 | LIST **ref = NULL; |
| 1531 | 1529 | int refcnt = 0, refmax = 0; |
| 1532 | 1530 | |
| 1533 | | for ( ; (TrimRef == 0 || refcnt < TrimRef) && r ; r = r->next) |
| | 1531 | for ( ; (trim == 0 || refcnt < trim) && r ; r = r->next) |
| 1534 | 1532 | { |
| 1535 | 1533 | if (refcnt == refmax) |
| … |
… |
|
| 1826 | 1824 | { |
| 1827 | 1825 | fputs ("References:", fp); |
| 1828 | | write_references (env->references, fp); |
| | 1826 | mutt_write_references (env->references, fp, 10); |
| 1829 | 1827 | fputc('\n', fp); |
| 1830 | 1828 | } |
| … |
… |
|
| 1838 | 1836 | { |
| 1839 | 1837 | fputs ("In-Reply-To:", fp); |
| 1840 | | write_references (env->in_reply_to, fp); |
| | 1838 | mutt_write_references (env->in_reply_to, fp, 1); |
| 1841 | 1839 | fputc ('\n', fp); |
| 1842 | 1840 | } |