Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 2366C429E48 for ; Wed, 25 May 2011 18:01:37 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.921 X-Spam-Level: X-Spam-Status: No, score=-1.921 tagged_above=-999 required=5 tests=[NO_DNS_FOR_FROM=0.379, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RXAShqdU+RD2 for ; Wed, 25 May 2011 18:01:36 -0700 (PDT) Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu [131.215.239.19]) by olra.theworths.org (Postfix) with ESMTP id 44E01429E32 for ; Wed, 25 May 2011 18:01:34 -0700 (PDT) Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1]) by fire-doxen-postvirus (Postfix) with ESMTP id E0F2A3282D3; Wed, 25 May 2011 17:55:18 -0700 (PDT) X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new Received: from servo.finestructure.net (gwave-104.ligo.caltech.edu [131.215.114.104]) (Authenticated sender: jrollins) by fire-doxen-submit (Postfix) with ESMTP id DF0DB3281DB; Wed, 25 May 2011 17:55:11 -0700 (PDT) Received: by servo.finestructure.net (Postfix, from userid 1000) id 6DA457BE; Wed, 25 May 2011 18:01:26 -0700 (PDT) From: Jameson Graef Rollins To: notmuch@notmuchmail.org Subject: [PATCH 01/11] Simplify reply_part function to eliminate redundant code paths. Date: Wed, 25 May 2011 18:01:10 -0700 Message-Id: <1306371680-19441-2-git-send-email-jrollins@finestructure.net> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1306371680-19441-1-git-send-email-jrollins@finestructure.net> References: <1306371680-19441-1-git-send-email-jrollins@finestructure.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 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: Thu, 26 May 2011 01:01:37 -0000 This is the same logic but with less code. --- notmuch-reply.c | 41 ++++++++++++++--------------------------- 1 files changed, 14 insertions(+), 27 deletions(-) diff --git a/notmuch-reply.c b/notmuch-reply.c index ab15650..5d72b1f 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -88,31 +88,8 @@ static void reply_part (GMimeObject *part, unused (int *part_count)) { - GMimeContentDisposition *disposition; - GMimeContentType *content_type; - - disposition = g_mime_object_get_content_disposition (part); - if (disposition && - strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0) - { - const char *filename = g_mime_part_get_filename (GMIME_PART (part)); - content_type = g_mime_object_get_content_type (GMIME_OBJECT (part)); - - if (g_mime_content_type_is_type (content_type, "text", "*") && - !g_mime_content_type_is_type (content_type, "text", "html")) - { - reply_part_content (part); - } - else - { - printf ("Attachment: %s (%s)\n", filename, - g_mime_content_type_to_string (content_type)); - } - - return; - } - - content_type = g_mime_object_get_content_type (GMIME_OBJECT (part)); + GMimeContentType *content_type = g_mime_object_get_content_type (GMIME_OBJECT (part)); + GMimeContentDisposition *disposition = g_mime_object_get_content_disposition (part); if (g_mime_content_type_is_type (content_type, "text", "*") && !g_mime_content_type_is_type (content_type, "text", "html")) @@ -121,8 +98,18 @@ reply_part (GMimeObject *part, } else { - printf ("Non-text part: %s\n", - g_mime_content_type_to_string (content_type)); + if (disposition && + strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0) + { + const char *filename = g_mime_part_get_filename (GMIME_PART (part)); + printf ("Attachment: %s (%s)\n", filename, + g_mime_content_type_to_string (content_type)); + } + else + { + printf ("Non-text part: %s\n", + g_mime_content_type_to_string (content_type)); + } } } -- 1.7.4.4