+ if (h->irt_changed && h->NEW_ENV->in_reply_to)
+ {
+ LIST *listp = h->NEW_ENV->in_reply_to;
+
+ if (fputs ("In-Reply-To: ", out) == EOF)
+ return (-1);
+
+ for (; listp; listp = listp->next)
+ if ((fputs (listp->data, out) == EOF) || (fputc (' ', out) == EOF))
+ return (-1);
+
+ if (fputc ('\n', out) == EOF)
+ return (-1);
+ }
+
+ if (h->refs_changed && h->NEW_ENV->references)
+ {
+ LIST *listp = h->NEW_ENV->references, *refs = NULL, *t;
+
+ if (fputs ("References: ", out) == EOF)
+ return (-1);
+
+ /* Mutt stores references in reverse order, thus we create
+ * a reordered refs list that we can put in the headers */
+ for (; listp; listp = listp->next, refs = t)
+ {
+ t = (LIST *)safe_malloc (sizeof (LIST));
+ t->data = listp->data;
+ t->next = refs;
+ }
+
+ for (; refs; refs = refs->next)
+ if ((fputs (refs->data, out) == EOF) || (fputc (' ', out) == EOF))
+ return (-1);
+
+ /* clearing refs from memory */
+ for (t = refs; refs; refs = t->next, t = refs)
+ safe_free ((void **)&refs);
+
+ if (fputc ('\n', out) == EOF)
+ return (-1);
+ }
+#undef NEW_ENV
+