Re: [PATCH 3/4] Utility function to seek in MIME trees in depth-first order.
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Sun, 25 Dec 2011 23:39:57 +0000 (03:39 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:41:17 +0000 (09:41 -0800)
93/3cb6d53b281f117b253d932718d3b28f8ad2f0 [new file with mode: 0644]

diff --git a/93/3cb6d53b281f117b253d932718d3b28f8ad2f0 b/93/3cb6d53b281f117b253d932718d3b28f8ad2f0
new file mode 100644 (file)
index 0000000..62d89d3
--- /dev/null
@@ -0,0 +1,147 @@
+Return-Path: <dmitry.kurochkin@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id B83D8431FD0\r
+       for <notmuch@notmuchmail.org>; Sun, 25 Dec 2011 15:40:45 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id bglNPG7swhvX for <notmuch@notmuchmail.org>;\r
+       Sun, 25 Dec 2011 15:40:45 -0800 (PST)\r
+Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
+       [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 149F0431FB6\r
+       for <notmuch@notmuchmail.org>; Sun, 25 Dec 2011 15:40:44 -0800 (PST)\r
+Received: by wibhq2 with SMTP id hq2so5051930wib.26\r
+       for <notmuch@notmuchmail.org>; Sun, 25 Dec 2011 15:40:43 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=from:to:cc:subject:in-reply-to:references:user-agent:date\r
+       :message-id:mime-version:content-type;\r
+       bh=Tk4hQXiMEPsanJ4hPAMsiZeFUtqIOUUnP0Uw0rWR2Y0=;\r
+       b=bup5Vdx4r4lTFNIN60MIdV+MgcFDx6lD6S6Dcfxhma12G1U1M5txXKx/vCW5NCQp7E\r
+       JiP1cqL+FlS928+AUnSDsGkDv2DBa78Z32KjNSIffH4o/huRH5+BdtTwKMAwumPQV1h/\r
+       +ys79sCn02JwtnAvY5a4GddfMWdHu24l28bNA=\r
+Received: by 10.180.19.106 with SMTP id d10mr49658931wie.2.1324856443766;\r
+       Sun, 25 Dec 2011 15:40:43 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+       by mx.google.com with ESMTPS id fy5sm52303194wib.7.2011.12.25.15.40.42\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sun, 25 Dec 2011 15:40:42 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: Austin Clements <amdragon@MIT.EDU>\r
+Subject: Re: [PATCH 3/4] Utility function to seek in MIME trees in depth-first\r
+       order.\r
+In-Reply-To: <20111224034603.GC1927@mit.edu>\r
+References: <1323027100-10307-1-git-send-email-amdragon@mit.edu>\r
+       <1323460468-4030-1-git-send-email-amdragon@mit.edu>\r
+       <1323460468-4030-4-git-send-email-amdragon@mit.edu>\r
+       <87hb187iu6.fsf@gmail.com> <20111224034603.GC1927@mit.edu>\r
+User-Agent: Notmuch/0.10.2+116~g4c449d4 (http://notmuchmail.org) Emacs/23.3.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Mon, 26 Dec 2011 03:39:57 +0400\r
+Message-ID: <87pqfc1ar6.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 25 Dec 2011 23:40:45 -0000\r
+\r
+On Fri, 23 Dec 2011 22:46:19 -0500, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> Quoth Dmitry Kurochkin on Dec 10 at  3:43 pm:\r
+> > On Fri,  9 Dec 2011 14:54:27 -0500, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> > > This function matches how we number parts for the --part argument to\r
+> > > show.  It will allow us to jump directly to the desired part, rather\r
+> > > than traversing the entire tree and carefully tracking whether or not\r
+> > > we're "in the zone".\r
+> > > ---\r
+> > >  mime-node.c      |   25 +++++++++++++++++++++++++\r
+> > >  notmuch-client.h |    5 +++++\r
+> > >  2 files changed, 30 insertions(+), 0 deletions(-)\r
+> > > \r
+> > > diff --git a/mime-node.c b/mime-node.c\r
+> > > index a8e4a59..207818e 100644\r
+> > > --- a/mime-node.c\r
+> > > +++ b/mime-node.c\r
+> > > @@ -232,3 +232,28 @@ mime_node_child (const mime_node_t *parent, int child)\r
+> > >                          g_type_name (G_OBJECT_TYPE (parent->part)));\r
+> > >      }\r
+> > >  }\r
+> > > +\r
+> > > +static mime_node_t *\r
+> > > +_mime_node_seek_dfs_walk (mime_node_t *node, int *n)\r
+> > > +{\r
+> > > +    mime_node_t *ret = NULL;\r
+> > > +    int i;\r
+> > > +\r
+> > \r
+> > Can we move declarations below the if (which does not need them)?  I\r
+> > always have troubles remembering if (recent enough) C standard allows\r
+> > that or it is a GCC extension.  FWIW in the previous patch there are\r
+> > declarations in the middle of a block, e.g.:\r
+> > \r
+> >    } else {\r
+> >        out->is_signed = TRUE;\r
+> >             ...\r
+> >        GMimeSignatureValidity *sig_validity = g_mime_multipart_signed_verify\r
+> >            (GMIME_MULTIPART_SIGNED (part), out->ctx->cryptoctx, &err);\r
+> > \r
+> > So either we can move these declarations to where they are needed, or we\r
+> > should fix it in _mime_node_create().\r
+> \r
+> Since prevailing notmuch style seems to be top-declarations, I fixed\r
+> up _mime_node_create instead (personally I prefer C99-style\r
+> declarations, but *shrug*).\r
+> \r
+\r
+If there is any code which already uses C99-style declarations, then we\r
+should use them in the new code IMO.  Perhaps whether to use C99-style\r
+declarations or not should be a coding style requirement.\r
+\r
+Regards,\r
+  Dmitry\r
+\r
+> > > +    if (*n <= 0)\r
+> > \r
+> > Comment for mime_node_seek_dfs() says that the function returns the node\r
+> > itself for n = 0, but does not say anything about n < 0.  I would expect\r
+> > the function to return NULL for n < 0.  In any case, the comment below\r
+> > should probably mention what happens for n < 0;\r
+> \r
+> Good point.  I made it return NULL for n < 0.  I think this logically\r
+> falls under "Returns NULL if there is no such part."\r
+> \r
+> > > +        return node;\r
+> > > +\r
+> > > +    *n = *n - 1;\r
+> > \r
+> > Perhaps *n -= 1?  Or even --(*n)?\r
+> \r
+> Changed to *n -= 1.\r
+> \r
+> > > +    for (i = 0; i < node->children && !ret; i++) {\r
+> > \r
+> > Consider s/i++/++i/.\r
+> \r
+> notmuch uses i++ remarkably consistently, so I left this.\r
+> \r
+> > Regards,\r
+> >   Dmitry\r