cli/reply: make references header creation easier to follow
authorJani Nikula <jani@nikula.org>
Tue, 13 Sep 2016 17:14:14 +0000 (20:14 +0300)
committerDavid Bremner <david@tethera.net>
Sat, 17 Sep 2016 12:00:31 +0000 (09:00 -0300)
Just use strdup when original references is not available, instead of
trying to cram everything into a monster asprintf. There should be no
functional changes.

notmuch-reply.c

index eb07405591fd55185337612c2b3a8e5259d633e1..c2d7402d40ae0874ff1bdec5bbe5a82024545e36 100644 (file)
@@ -538,13 +538,12 @@ create_reply_message(void *ctx,
     g_mime_object_set_header (GMIME_OBJECT (reply), "In-Reply-To", in_reply_to);
 
     orig_references = notmuch_message_get_header (message, "references");
-    if (!orig_references)
-       /* Treat errors like missing References headers. */
-       orig_references = "";
-    references = talloc_asprintf (ctx, "%s%s%s",
-                                 *orig_references ? orig_references : "",
-                                 *orig_references ? " " : "",
-                                 in_reply_to);
+    if (orig_references && *orig_references)
+       references = talloc_asprintf (ctx, "%s %s", orig_references,
+                                     in_reply_to);
+    else
+       references = talloc_strdup (ctx, in_reply_to);
+
     g_mime_object_set_header (GMIME_OBJECT (reply), "References", references);
 
     from_addr = add_recipients_from_message (reply, config,