Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 6D3626DE028C for ; Sat, 18 Jun 2016 14:33:26 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: -0.563 X-Spam-Level: X-Spam-Status: No, score=-0.563 tagged_above=-999 required=5 tests=[AWL=0.157, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NyIsEA5Iqzqt for ; Sat, 18 Jun 2016 14:33:18 -0700 (PDT) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by arlo.cworth.org (Postfix) with ESMTPS id CE26A6DE02D1 for ; Sat, 18 Jun 2016 14:33:06 -0700 (PDT) Received: by mail-wm0-f67.google.com with SMTP id r201so5510080wme.0 for ; Sat, 18 Jun 2016 14:33:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nikula-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=pYUqjKEAM2QcAMxPIpXQWiHvzp0ChQDW96w9W+kxwCw=; b=RasAI0nmLk1MCB9A5xji8+gJRppTliIHrck9AkmpNnfEYnlnxLfE4jnBS49vdR9i8R X0CwKqtzZh4FaD1Ver0rdxtHfnSRc4fSi0IGDIBYIJPkSXXxgViIQMrrunXuLtRgYjA2 vVQiGOWpm+BDScdAE/KGFYARYhMvXjQKxI8btB+IorzHI5GgjacaDlsfT84pNbXLnEU4 yeK60yOC6a5jPNCflDCZ9YOwBk4fU8in3+/2w9WOPFabFvyOglKPmH6re2pce/MYGF2Y ZtrmFii3gzkP8HTOs/522LbO9NbC5twlD+Dd0n4VtdGkxHvCGEx+EtwWVRyhUBbTGBXI JBqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=pYUqjKEAM2QcAMxPIpXQWiHvzp0ChQDW96w9W+kxwCw=; b=YtPrJgcRry6JnH7ZTEb/0LXbBRdGL9AoRUqJWeTYHN83m/VlAl3wawkDZo840lHdSp HkzLwGaLPbNB+BwqfpEZImAVtodo6y3j79CG54xN35dAjLsSqoL16NJ+e5MibFFoCStL vGDStW928IaArnj+P+uuysY3Z4tKzQUCPtYWWZbNWzvUt7yxJwTSHMZV8MQ0+Lp+YAlx TO7eDNukqdMt5YSbG8573HwVvWibEBFyVBteDjk5mHyLA0/9g5fP/XFfFPUtFDHRpKE7 PPJ1wPxMtrCWO+eU350CowhnNa8aVzIKNbHQYrShvU/rq4wi3+PllqSvlIsPBwxviFh0 pkJQ== X-Gm-Message-State: ALyK8tIBmFHNXO3BoxpR6e4HKo8GhBITPhxzEtQISjYRMmZ45n5QKbGHgi03qLOTgq+GvA== X-Received: by 10.194.237.33 with SMTP id uz1mr7637646wjc.5.1466285585445; Sat, 18 Jun 2016 14:33:05 -0700 (PDT) Received: from localhost (mobile-access-bcee4e-81.dhcp.inet.fi. [188.238.78.81]) by smtp.gmail.com with ESMTPSA id o10sm18783341wjs.38.2016.06.18.14.33.04 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 18 Jun 2016 14:33:04 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Cc: jani@nikula.org, Daniel Kahn Gillmor Subject: [PATCH 5/7] cli/reply: make references header creation easier to follow Date: Sun, 19 Jun 2016 00:31:31 +0300 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Jun 2016 21:33:26 -0000 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 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/notmuch-reply.c b/notmuch-reply.c index eb07405591fd..c2d7402d40ae 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -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, -- 2.1.4