Ticket #3090: mutt-3090-references.patch

File mutt-3090-references.patch, 23.6 kB (added by Aron Griffis, 6 months ago)

Added by email2trac

  • Makefile.am

    diff -r f72fce68ca19 Makefile.am
    a b  
    2424        getdomain.c group.c \ 
    2525        handler.c hash.c hdrline.c headers.c help.c hook.c keymap.c \ 
    2626        main.c mbox.c menu.c mh.c mx.c pager.c parse.c pattern.c \ 
    27         postpone.c query.c recvattach.c recvcmd.c \ 
     27        postpone.c query.c recvattach.c recvcmd.c references.c \ 
    2828        rfc822.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \ 
    2929        score.c send.c sendlib.c signal.c sort.c \ 
    3030        status.c system.c thread.c charset.c history.c lib.c \ 
  • copy.c

    diff -r f72fce68ca19 copy.c
    a b  
    370370  { 
    371371    if ((flags & CH_NOSTATUS) == 0) 
    372372    { 
    373       if (h->env->irt_changed && h->env->in_reply_to) 
     373      if (h->env->irt_changed) 
    374374      { 
    375         LIST *listp = h->env->in_reply_to; 
    376  
    377         if (fputs ("In-Reply-To: ", out) == EOF) 
    378           return (-1); 
    379  
    380         for (; listp; listp = listp->next) 
    381           if ((fputs (listp->data, out) == EOF) || (fputc (' ', out) == EOF)) 
    382             return (-1); 
    383  
    384         if (fputc ('\n', out) == EOF) 
    385           return (-1); 
     375        char *s = mutt_in_reply_to_str(h->env); 
     376        if (s && fprintf (out, "In-Reply-To: %s\n", s) < 0) 
     377          return -1; 
    386378      } 
    387379 
    388       if (h->env->refs_changed && h->env->references) 
     380      if (h->env->refs_changed) 
    389381      { 
    390         LIST *listp = h->env->references, *refs = NULL, *t; 
    391  
    392         if (fputs ("References: ", out) == EOF) 
    393           return (-1); 
    394  
    395         /* Mutt stores references in reverse order, thus we create 
    396          * a reordered refs list that we can put in the headers */ 
    397         for (; listp; listp = listp->next, refs = t) 
    398         { 
    399           t = (LIST *)safe_malloc (sizeof (LIST)); 
    400           t->data = listp->data; 
    401           t->next = refs; 
    402         } 
    403  
    404         for (; refs; refs = refs->next) 
    405           if ((fputs (refs->data, out) == EOF) || (fputc (' ', out) == EOF)) 
    406             return (-1); 
    407  
    408         /* clearing refs from memory */ 
    409         for (t = refs; refs; refs = t->next, t = refs) 
    410           FREE (&refs); 
    411  
    412         if (fputc ('\n', out) == EOF) 
    413           return (-1); 
     382        char *s = mutt_references_str(h->env, 0); 
     383        if (s && fprintf (out, "References: %s\n", s) < 0) 
     384          return -1; 
    414385      } 
    415386 
    416387      if (h->old || h->read) 
  • hcache.c

    diff -r f72fce68ca19 hcache.c
    a b  
    423423 
    424424  d = dump_buffer(e->spam, d, off, convert); 
    425425 
    426   d = dump_list(e->references, d, off, 0); 
    427   d = dump_list(e->in_reply_to, d, off, 0); 
     426  d = dump_char(mutt_references_str(e, 0), d, off, convert); 
     427  d = dump_char(mutt_in_reply_to_str(e), d, off, convert); 
    428428  d = dump_list(e->userhdrs, d, off, convert); 
    429429 
    430430  return d; 
     
    460460 
    461461  restore_buffer(&e->spam, d, off, convert); 
    462462 
    463   restore_list(&e->references, d, off, 0); 
    464   restore_list(&e->in_reply_to, d, off, 0); 
     463  restore_char(&e->references_s, d, off, convert); 
     464  restore_char(&e->in_reply_to_s, d, off, convert); 
    465465  restore_list(&e->userhdrs, d, off, convert); 
    466466} 
    467467 
  • headers.c

    diff -r f72fce68ca19 headers.c
    a b  
    111111  mutt_unlink (path); 
    112112 
    113113  /* restore old info. */ 
    114   n->references = msg->env->references; 
    115   msg->env->references = NULL; 
     114  mutt_move_references (n, msg->env); 
    116115 
    117116  mutt_free_envelope (&msg->env); 
    118117  msg->env = n; n = NULL; 
    119118 
    120   if (!msg->env->in_reply_to) 
    121     mutt_free_list (&msg->env->references); 
     119  if (!mutt_has_in_reply_to(msg->env)) 
     120    mutt_free_references (msg->env); 
    122121 
    123122  mutt_expand_aliases_env (msg->env); 
    124123 
    125   /* search through the user defined headers added to see if either a  
    126    * fcc: or attach-file: field was specified.   
     124  /* search through the user defined headers added to see if any of 
     125   * fcc: or attach-file: or pgp: fields were specified.   
    127126   */ 
    128127 
    129128  cur = msg->env->userhdrs; 
     
    132131  { 
    133132    keep = 1; 
    134133 
    135     /* keep track of whether or not we see the in-reply-to field.  if we did 
    136      * not, remove the references: field later so that we can generate a new 
    137      * message based upon this one. 
    138      */ 
    139134    if (fcc && ascii_strncasecmp ("fcc:", cur->data, 4) == 0) 
    140135    { 
    141136      p = cur->data + 4; 
     
    179174      } 
    180175      keep = 0; 
    181176    } 
    182  
    183  
    184177    else if ((WithCrypto & APPLICATION_PGP) 
    185178             &&ascii_strncasecmp ("pgp:", cur->data, 4) == 0) 
    186179    { 
  • mbox.c

    diff -r f72fce68ca19 mbox.c
    a b  
    466466  return (1); 
    467467} 
    468468 
    469 static int strict_cmp_lists (const LIST *a, const LIST *b) 
    470 { 
    471   while (a && b) 
    472   { 
    473     if (mutt_strcmp (a->data, b->data)) 
    474       return (0); 
    475  
    476     a = a->next; 
    477     b = b->next; 
    478   } 
    479   if (a || b) 
    480     return (0); 
    481  
    482   return (1); 
    483 } 
    484  
    485 static int strict_cmp_envelopes (const ENVELOPE *e1, const ENVELOPE *e2) 
     469static int strict_cmp_envelopes (ENVELOPE *e1, ENVELOPE *e2) 
    486470{ 
    487471  if (e1 && e2) 
    488472  { 
    489473    if (mutt_strcmp (e1->message_id, e2->message_id) || 
    490474        mutt_strcmp (e1->subject, e2->subject) || 
    491         !strict_cmp_lists (e1->references, e2->references) || 
     475        mutt_strcmp (mutt_references_str(e1, 0), mutt_references_str(e2, 0)) || 
    492476        !strict_addrcmp (e1->from, e2->from) || 
    493477        !strict_addrcmp (e1->sender, e2->sender) || 
    494478        !strict_addrcmp (e1->reply_to, e2->reply_to) || 
  • mutt.h

    diff -r f72fce68ca19 mutt.h
    a b  
    596596  char *date; 
    597597  char *x_label; 
    598598  BUFFER *spam; 
    599   LIST *references;             /* message references (in reverse order) */ 
    600   LIST *in_reply_to;            /* in-reply-to header content */ 
     599  char *references_s;           /* references header content */ 
     600  LIST *references_l;           /* references (parsed, in reverse order) */ 
     601  char *in_reply_to_s;          /* in-reply-to header content */ 
     602  LIST *in_reply_to_l;          /* in-reply-to (parsed) */ 
    601603  LIST *userhdrs;               /* user defined headers */ 
    602604 
    603605  unsigned int irt_changed : 1; /* In-Reply-To changed to link/break threads */ 
     
    956958 
    957959#include "ascii.h" 
    958960#include "protos.h" 
     961#include "references.h" 
    959962#include "lib.h" 
    960963#include "globals.h" 
    961964 
  • muttlib.c

    diff -r f72fce68ca19 muttlib.c
    a b  
    677677 
    678678  mutt_buffer_free (&(*p)->spam); 
    679679 
    680   mutt_free_list (&(*p)->references); 
    681   mutt_free_list (&(*p)->in_reply_to); 
     680  mutt_free_references (*p); 
     681  mutt_free_in_reply_to (*p); 
    682682  mutt_free_list (&(*p)->userhdrs); 
    683683  FREE (p);             /* __FREE_CHECKED__ */ 
    684684} 
     
    703703  MOVE_ELEM(supersedes); 
    704704  MOVE_ELEM(date); 
    705705  MOVE_ELEM(x_label); 
    706   if (!base->refs_changed) 
     706 
     707  if (!base->refs_changed && !mutt_has_references(base)) 
    707708  { 
    708     MOVE_ELEM(references); 
     709    MOVE_ELEM(references_l); 
     710    MOVE_ELEM(references_s); 
    709711  } 
    710   if (!base->irt_changed) 
     712 
     713  if (!base->irt_changed && !mutt_has_in_reply_to(base)) 
    711714  { 
    712     MOVE_ELEM(in_reply_to); 
     715    MOVE_ELEM(in_reply_to_l); 
     716    MOVE_ELEM(in_reply_to_s); 
    713717  } 
    714    
     718 
    715719  /* real_subj is subordinate to subject */ 
    716720  if (!base->subject) 
    717721  { 
  • parse.c

    diff -r f72fce68ca19 parse.c
    a b  
    8787    } 
    8888  } 
    8989  /* not reached */ 
    90 } 
    91  
    92 static LIST *mutt_parse_references (char *s, int in_reply_to) 
    93 { 
    94   LIST *t, *lst = NULL; 
    95   int m, n = 0; 
    96   char *o = NULL, *new, *at; 
    97  
    98   while ((s = strtok (s, " \t;")) != NULL) 
    99   { 
    100     /* 
    101      * some mail clients add other garbage besides message-ids, so do a quick 
    102      * check to make sure this looks like a valid message-id 
    103      * some idiotic clients also break their message-ids between lines, deal 
    104      * with that too (give up if it's more than two lines, though) 
    105      */ 
    106     t = NULL; 
    107     new = NULL; 
    108  
    109     if (*s == '<') 
    110     { 
    111       n = strlen (s); 
    112       if (s[n-1] != '>') 
    113       { 
    114         o = s; 
    115         s = NULL; 
    116         continue; 
    117       } 
    118  
    119       new = safe_strdup (s); 
    120     } 
    121     else if (o) 
    122     { 
    123       m = strlen (s); 
    124       if (s[m - 1] == '>') 
    125       { 
    126         new = safe_malloc (sizeof (char) * (n + m + 1)); 
    127         strcpy (new, o);        /* __STRCPY_CHECKED__ */ 
    128         strcpy (new + n, s);    /* __STRCPY_CHECKED__ */ 
    129       } 
    130     } 
    131     if (new) 
    132     { 
    133       /* make sure that this really does look like a message-id. 
    134        * it should have exactly one @, and if we're looking at 
    135        * an in-reply-to header, make sure that the part before 
    136        * the @ has more than eight characters or it's probably 
    137        * an email address 
    138        */ 
    139       if (!(at = strchr (new, '@')) || strchr (at + 1, '@') 
    140           || (in_reply_to && at - new <= 8)) 
    141         FREE (&new); 
    142       else 
    143       { 
    144         t = (LIST *) safe_malloc (sizeof (LIST)); 
    145         t->data = new; 
    146         t->next = lst; 
    147         lst = t; 
    148       } 
    149     } 
    150     o = NULL; 
    151     s = NULL; 
    152   } 
    153  
    154   return (lst); 
    15590} 
    15691 
    15792int mutt_check_encoding (const char *c) 
     
    10731008    case 'i': 
    10741009    if (!ascii_strcasecmp (line+1, "n-reply-to")) 
    10751010    { 
    1076       mutt_free_list (&e->in_reply_to); 
    1077       e->in_reply_to = mutt_parse_references (p, 1); 
     1011      mutt_free_list (&e->in_reply_to_l); 
     1012      FREE (&e->in_reply_to_s); 
     1013      e->in_reply_to_s = safe_strdup (p); 
    10781014      matched = 1; 
    10791015    } 
    10801016    break; 
     
    11551091    case 'r': 
    11561092    if (!ascii_strcasecmp (line + 1, "eferences")) 
    11571093    { 
    1158       mutt_free_list (&e->references); 
    1159       e->references = mutt_parse_references (p, 0); 
     1094      mutt_free_list (&e->references_l); 
     1095      FREE (&e->references_s); 
     1096      e->references_s = safe_strdup (p); 
    11601097      matched = 1; 
    11611098    } 
    11621099    else if (!ascii_strcasecmp (line + 1, "eply-to")) 
  • pattern.c

    diff -r f72fce68ca19 pattern.c
    a b  
    10151015  return pat->alladdr; /* No matches, or all matches if alladdr */ 
    10161016} 
    10171017 
    1018 static int match_reference (pattern_t *pat, LIST *refs) 
    1019 { 
    1020   for (; refs; refs = refs->next) 
    1021     if (patmatch (pat, refs->data) == 0) 
    1022       return 1; 
    1023   return 0; 
    1024 } 
    1025  
    10261018/* 
    10271019 * Matches subscribed mailing lists 
    10281020 */ 
     
    11661158    case M_SIZE: 
    11671159      return (pat->not ^ (h->content->length >= pat->min && (pat->max == M_MAXRANGE || h->content->length <= pat->max))); 
    11681160    case M_REFERENCE: 
    1169       return (pat->not ^ match_reference (pat, h->env->references)); 
     1161      return (pat->not ^ (mutt_references_str (h->env, 0) && 
     1162                          patmatch (pat, mutt_references_str (h->env, 0)) == 0)); 
    11701163    case M_ADDRESS: 
    11711164      return (pat->not ^ match_adrlist (pat, flags & M_MATCH_FULL_ADDRESS, 4, 
    11721165                                        h->env->from, h->env->sender, 
  • (a) /dev/null vs. (b) b/references.c

    diff -r f72fce68ca19 references.c
    a b  
     1/* 
     2 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org> 
     3 * Copyright (C) 2008 Aron Griffis <agriffis@n01se.net> 
     4 *  
     5 *     This program is free software; you can redistribute it and/or modify 
     6 *     it under the terms of the GNU General Public License as published by 
     7 *     the Free Software Foundation; either version 2 of the License, or 
     8 *     (at your option) any later version. 
     9 *  
     10 *     This program is distributed in the hope that it will be useful, 
     11 *     but WITHOUT ANY WARRANTY; without even the implied warranty of 
     12 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13 *     GNU General Public License for more details. 
     14 *  
     15 *     You should have received a copy of the GNU General Public License 
     16 *     along with this program; if not, write to the Free Software 
     17 *     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
     18 */  
     19 
     20#if HAVE_CONFIG_H 
     21# include "config.h" 
     22#endif 
     23 
     24#include "mutt.h" 
     25#include "mutt_regex.h" 
     26#include "mailbox.h" 
     27#include "mime.h" 
     28#include "rfc2047.h" 
     29#include "rfc2231.h" 
     30#include "mutt_crypt.h" 
     31#include "url.h" 
     32 
     33#include <string.h> 
     34#include <ctype.h> 
     35#include <sys/stat.h> 
     36#include <stdlib.h> 
     37 
     38static LIST *mutt_parse_references (char *s, int in_reply_to) 
     39{ 
     40  LIST *t, *lst = NULL; 
     41  int m, n = 0; 
     42  char *o = NULL, *new, *at; 
     43 
     44  while ((s = strtok (s, " \t;")) != NULL) 
     45  { 
     46    /* some mail clients add other garbage besides message-ids, so do a quick 
     47     * check to make sure this looks like a valid message-id 
     48     * some idiotic clients also break their message-ids between lines, deal 
     49     * with that too (give up if it's more than two lines, though) 
     50     */ 
     51    t = NULL; 
     52    new = NULL; 
     53 
     54    if (*s == '<') 
     55    { 
     56      n = strlen (s); 
     57      if (s[n-1] != '>') 
     58      { 
     59        o = s; 
     60        s = NULL; 
     61        continue; 
     62      } 
     63 
     64      new = safe_strdup (s); 
     65    } 
     66    else if (o) 
     67    { 
     68      m = strlen (s); 
     69      if (s[m - 1] == '>') 
     70      { 
     71        new = safe_malloc (sizeof (char) * (n + m + 1)); 
     72        strcpy (new, o);        /* __STRCPY_CHECKED__ */ 
     73        strcpy (new + n, s);    /* __STRCPY_CHECKED__ */ 
     74      } 
     75    } 
     76    if (new) 
     77    { 
     78      /* make sure that this really does look like a message-id. 
     79       * it should have exactly one @, and if we're looking at 
     80       * an in-reply-to header, make sure that the part before 
     81       * the @ has more than eight characters or it's probably 
     82       * an email address 
     83       */ 
     84      if (!(at = strchr (new, '@')) || strchr (at + 1, '@') 
     85          || (in_reply_to && at - new <= 8)) 
     86        FREE (&new); 
     87      else 
     88      { 
     89        t = (LIST *) safe_malloc (sizeof (LIST)); 
     90        t->data = new; 
     91        t->next = lst; 
     92        lst = t; 
     93      } 
     94    } 
     95    o = NULL; 
     96    s = NULL; 
     97  } 
     98 
     99  return (lst); 
     100} 
     101 
     102LIST *mutt_references_list (ENVELOPE *e) 
     103{ 
     104  if (!e->references_l && e->references_s) 
     105    e->references_l = mutt_parse_references (e->references_s, 0); 
     106  return e->references_l; 
     107} 
     108 
     109LIST *mutt_in_reply_to_list (ENVELOPE *e) 
     110{ 
     111  if (!e->in_reply_to_l && e->in_reply_to_s) 
     112    e->in_reply_to_l = mutt_parse_references (e->in_reply_to_s, 1); 
     113  return e->in_reply_to_l; 
     114} 
     115 
     116LIST **mutt_references_listp (ENVELOPE *e) 
     117{ 
     118  /* giving away a pointer invalidates the stored string */ 
     119  (void) mutt_references_list (e); 
     120  FREE (&e->references_s); 
     121  return &e->references_l; 
     122} 
     123 
     124LIST **mutt_in_reply_to_listp (ENVELOPE *e) 
     125{ 
     126  /* giving away a pointer invalidates the stored string */ 
     127  (void) mutt_in_reply_to_list (e); 
     128  FREE (&e->in_reply_to_s); 
     129  return &e->in_reply_to_l; 
     130} 
     131 
     132/* this is a generally useful function that should probably live elsewhere */ 
     133static void reverse_list (LIST **list) 
     134{ 
     135  LIST *l = *list, *prev = NULL, *next = NULL; 
     136  if (!l || !l->next) 
     137    return; 
     138  do { 
     139    next = l->next; 
     140    l->next = prev; 
     141    prev = l; 
     142    l = next; 
     143  } while (l); 
     144  *list = prev; 
     145} 
     146 
     147static char *refs_str (char **sp, LIST *l, int max) 
     148{ 
     149  LIST *ref; 
     150  int len, buflen, count; 
     151  char *s = NULL; 
     152 
     153  /* if no max then preemptively return stored value */ 
     154  if (!max && *sp) 
     155    return *sp; 
     156 
     157  /* list is stored in reverse order to speed up threading; 
     158   * switch it forward temporarily. 
     159   */ 
     160  reverse_list (&l); 
     161 
     162  for (ref = l, count = 0, buflen = 0; 
     163       ref && (max == 0 || count < max); 
     164       ref = ref->next, count++) 
     165  { 
     166    len = strlen (ref->data); 
     167    buflen += len + 1; 
     168    safe_realloc (&s, buflen); 
     169    memcpy (&s[buflen - len - 1], ref->data, len); 
     170    s[buflen - 1] = ' '; 
     171  } 
     172  if (s) 
     173    s[buflen - 1] = '\0'; 
     174 
     175  /* reverse it back */ 
     176  reverse_list (&l); 
     177 
     178  if (!max) 
     179    *sp = s; 
     180 
     181  return s; 
     182} 
     183 
     184char *mutt_references_str (ENVELOPE *e, int max) 
     185{ 
     186  if (max) 
     187  { 
     188    /* make sure the list is populated, since specifying a max value 
     189     * forces the list-to-string generation. 
     190     */ 
     191    (void) mutt_references_list (e); 
     192  } 
     193  return refs_str (&e->references_s, e->references_l, max); 
     194} 
     195 
     196char *mutt_in_reply_to_str (ENVELOPE *e) 
     197{ 
     198  return refs_str (&e->in_reply_to_s, e->in_reply_to_l, 1); 
     199} 
     200 
     201void mutt_move_references (ENVELOPE *to, ENVELOPE *from) 
     202{ 
     203  to->references_l = from->references_l; 
     204  to->references_s = from->references_s; 
     205  from->references_l = NULL; 
     206  from->references_s = NULL; 
     207} 
     208 
     209void mutt_free_references (ENVELOPE *e) 
     210{ 
     211  mutt_free_list (&e->references_l); 
     212  FREE (&e->references_s); 
     213} 
     214 
     215void mutt_free_in_reply_to (ENVELOPE *e) 
     216{ 
     217  mutt_free_list (&e->in_reply_to_l); 
     218  FREE (&e->in_reply_to_s); 
     219} 
     220 
     221void mutt_null_references (ENVELOPE *e) 
     222{ 
     223  e->references_l = NULL; 
     224  e->references_s = NULL; 
     225} 
     226 
     227void mutt_null_in_reply_to (ENVELOPE *e) 
     228{ 
     229  e->in_reply_to_l = NULL; 
     230  e->in_reply_to_s = NULL; 
     231} 
     232 
     233void mutt_set_in_reply_to_s (ENVELOPE *e, char *s) 
     234{ 
     235  mutt_free_list (&e->in_reply_to_l); 
     236  FREE (&e->in_reply_to_s); 
     237  e->in_reply_to_s = safe_strdup (s); 
     238} 
     239 
  • (a) /dev/null vs. (b) b/references.h

    diff -r f72fce68ca19 references.h
    a b  
     1/* 
     2 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org> 
     3 * Copyright (C) 2008 Aron Griffis <agriffis@n01se.net> 
     4 *  
     5 *     This program is free software; you can redistribute it and/or modify 
     6 *     it under the terms of the GNU General Public License as published by 
     7 *     the Free Software Foundation; either version 2 of the License, or 
     8 *     (at your option) any later version. 
     9 *  
     10 *     This program is distributed in the hope that it will be useful, 
     11 *     but WITHOUT ANY WARRANTY; without even the implied warranty of 
     12 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13 *     GNU General Public License for more details. 
     14 *  
     15 *     You should have received a copy of the GNU General Public License 
     16 *     along with this program; if not, write to the Free Software 
     17 *     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
     18 */  
     19 
     20LIST *mutt_references_list (ENVELOPE *e); 
     21LIST **mutt_references_listp (ENVELOPE *e); 
     22char *mutt_references_str (ENVELOPE *e, int max); 
     23void mutt_null_references (ENVELOPE *e); 
     24void mutt_move_references (ENVELOPE *to, ENVELOPE *from); 
     25void mutt_free_references (ENVELOPE *e); 
     26 
     27LIST *mutt_in_reply_to_list (ENVELOPE *e); 
     28LIST **mutt_in_reply_to_listp (ENVELOPE *e); 
     29char *mutt_in_reply_to_str (ENVELOPE *e); 
     30void mutt_null_in_reply_to (ENVELOPE *e); 
     31void mutt_set_in_reply_to_s (ENVELOPE *e, char *s); 
     32void mutt_free_in_reply_to (ENVELOPE *e); 
     33 
     34#define mutt_has_references(e) ((e)->references_s || (e)->references_l) 
     35#define mutt_has_in_reply_to(e) ((e)->in_reply_to_s || (e)->in_reply_to_l) 
  • send.c

    diff -r f72fce68ca19 send.c
    a b  
    565565{ 
    566566  LIST *t = NULL, *l = NULL; 
    567567 
    568   if (e->references) 
    569     l = mutt_copy_list (e->references); 
    570   else 
    571     l = mutt_copy_list (e->in_reply_to); 
     568  if (mutt_has_references (e)) 
     569    l = mutt_copy_list (mutt_references_list (e)); 
     570  else if (mutt_has_in_reply_to (e)) 
     571    l = mutt_copy_list (mutt_in_reply_to_list (e)); 
    572572   
    573573  if (e->message_id) 
    574574  { 
     
    636636  if (pp) p = *pp; 
    637637  if (qq) q = *qq; 
    638638   
    639   if (!p) p = &env->references; 
    640   if (!q) q = &env->in_reply_to; 
     639  /* make sure the lists are populated */ 
     640  if (!p) p = mutt_references_listp (env); 
     641  if (!q) q = mutt_in_reply_to_listp (env); 
    641642   
    642643  while (*p) p = &(*p)->next; 
    643644  while (*q) q = &(*q)->next; 
     
    658659static void  
    659660mutt_make_reference_headers (ENVELOPE *curenv, ENVELOPE *env, CONTEXT *ctx) 
    660661{ 
    661   env->references = NULL; 
    662   env->in_reply_to = NULL; 
     662  mutt_null_references (env); 
     663  mutt_null_in_reply_to (env); 
    663664   
    664665  if (!curenv) 
    665666  { 
  • sendlib.c

    diff -r f72fce68ca19 sendlib.c
    a b  
    15171517  fputc ('\n', fp); 
    15181518} 
    15191519 
    1520 /* arbitrary number of elements to grow the array by */ 
    1521 #define REF_INC 16 
    1522  
    1523 #define TrimRef 10 
    1524  
    1525 /* need to write the list in reverse because they are stored in reverse order 
    1526  * when parsed to speed up threading 
    1527  */ 
    1528 static void write_references (LIST *r, FILE *f) 
    1529 { 
    1530   LIST **ref = NULL; 
    1531   int refcnt = 0, refmax = 0; 
    1532  
    1533   for ( ; (TrimRef == 0 || refcnt < TrimRef) && r ; r = r->next) 
    1534   { 
    1535     if (refcnt == refmax) 
    1536       safe_realloc (&ref, (refmax += REF_INC) * sizeof (LIST *)); 
    1537     ref[refcnt++] = r; 
    1538   } 
    1539  
    1540   while (refcnt-- > 0) 
    1541   { 
    1542     fputc (' ', f); 
    1543     fputs (ref[refcnt]->data, f); 
    1544   } 
    1545  
    1546   FREE (&ref); 
    1547 } 
    1548  
    1549  
    15501520static void foldingstrfcpy (char *d, const char *s, int n) 
    15511521{ 
    15521522  while (--n >= 0 && *s) 
     
    18221792 
    18231793  if (mode <= 0) 
    18241794  { 
    1825     if (env->references) 
    1826     { 
    1827       fputs ("References:", fp); 
    1828       write_references (env->references, fp); 
    1829       fputc('\n', fp); 
    1830     } 
     1795    if (mutt_has_references (env)) 
     1796      fprintf (fp, "References: %s\n", mutt_references_str (env, 10)); 
    18311797 
    18321798    /* Add the MIME headers */ 
    18331799    fputs ("MIME-Version: 1.0\n", fp); 
    18341800    mutt_write_mime_header (attach, fp); 
    18351801  } 
    18361802 
    1837   if (env->in_reply_to) 
    1838   { 
    1839     fputs ("In-Reply-To:", fp); 
    1840     write_references (env->in_reply_to, fp); 
    1841     fputc ('\n', fp); 
    1842   } 
     1803  if (mutt_has_in_reply_to (env)) 
     1804    fprintf (fp, "In-Reply-To: %s\n", mutt_in_reply_to_str (env)); 
    18431805   
    18441806  /* Add any user defined headers */ 
    18451807  for (; tmp; tmp = tmp->next) 
  • thread.c

    diff -r f72fce68ca19 thread.c
    a b  
    888888      if (using_refs == 0) 
    889889      { 
    890890        /* look at the beginning of in-reply-to: */ 
    891         if ((ref = cur->env->in_reply_to) != NULL) 
     891        if ((ref = mutt_in_reply_to_list (cur->env)) != NULL) 
    892892          using_refs = 1; 
    893893        else 
    894894        { 
    895           ref = cur->env->references; 
     895          ref = mutt_references_list (cur->env); 
    896896          using_refs = 2; 
    897897        } 
    898898      } 
     
    904904         * the second reference (since at least eudora puts the most 
    905905         * recent reference in in-reply-to and the rest in references) 
    906906         */