1 Return-Path: <dmitry.kurochkin@gmail.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 92A11429E25
\r
6 for <notmuch@notmuchmail.org>; Sat, 10 Dec 2011 03:44:13 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id WBY0V6+GGZA6 for <notmuch@notmuchmail.org>;
\r
17 Sat, 10 Dec 2011 03:44:11 -0800 (PST)
\r
18 Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com
\r
19 [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 543EA431FB6
\r
22 for <notmuch@notmuchmail.org>; Sat, 10 Dec 2011 03:44:11 -0800 (PST)
\r
23 Received: by bkat8 with SMTP id t8so4092685bka.26
\r
24 for <notmuch@notmuchmail.org>; Sat, 10 Dec 2011 03:44:08 -0800 (PST)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
26 h=from:to:subject:in-reply-to:references:user-agent:date:message-id
\r
27 :mime-version:content-type;
\r
28 bh=fR0KfrGdU4UJ+gVbfzI5Uc39RkYGVKLGRVeGtlrP/Ik=;
\r
29 b=rApFqKHO9ZpYidoYTtQ5KxGMC/XGozmXPbeDe+qJzlWHums7w0fK8xIfATzBcYTUTX
\r
30 ENn23zhT1xG7nYUZMnetSCj+jcbILESH83bnzyFpJ6Kf1nDGz969xzeubhjdmZUTtpyj
\r
31 6ktVBPxCypEATDTFAqfm2mUGqO/WaZLDk1oJQ=
\r
32 Received: by 10.204.128.130 with SMTP id k2mr5691320bks.7.1323517444209;
\r
33 Sat, 10 Dec 2011 03:44:04 -0800 (PST)
\r
34 Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id
\r
35 fg16sm16533407bkb.16.2011.12.10.03.44.02
\r
36 (version=TLSv1/SSLv3 cipher=OTHER);
\r
37 Sat, 10 Dec 2011 03:44:02 -0800 (PST)
\r
38 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
\r
39 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org
\r
40 Subject: Re: [PATCH 3/4] Utility function to seek in MIME trees in depth-first
\r
42 In-Reply-To: <1323460468-4030-4-git-send-email-amdragon@mit.edu>
\r
43 References: <1323027100-10307-1-git-send-email-amdragon@mit.edu>
\r
44 <1323460468-4030-1-git-send-email-amdragon@mit.edu>
\r
45 <1323460468-4030-4-git-send-email-amdragon@mit.edu>
\r
46 User-Agent: Notmuch/0.10.2+82~g96a629c (http://notmuchmail.org) Emacs/23.3.1
\r
47 (x86_64-pc-linux-gnu)
\r
48 Date: Sat, 10 Dec 2011 15:43:29 +0400
\r
49 Message-ID: <87hb187iu6.fsf@gmail.com>
\r
51 Content-Type: text/plain; charset=us-ascii
\r
52 X-BeenThere: notmuch@notmuchmail.org
\r
53 X-Mailman-Version: 2.1.13
\r
55 List-Id: "Use and development of the notmuch mail system."
\r
56 <notmuch.notmuchmail.org>
\r
57 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
58 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
59 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
60 List-Post: <mailto:notmuch@notmuchmail.org>
\r
61 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
62 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
64 X-List-Received-Date: Sat, 10 Dec 2011 11:44:13 -0000
\r
66 On Fri, 9 Dec 2011 14:54:27 -0500, Austin Clements <amdragon@MIT.EDU> wrote:
\r
67 > This function matches how we number parts for the --part argument to
\r
68 > show. It will allow us to jump directly to the desired part, rather
\r
69 > than traversing the entire tree and carefully tracking whether or not
\r
70 > we're "in the zone".
\r
72 > mime-node.c | 25 +++++++++++++++++++++++++
\r
73 > notmuch-client.h | 5 +++++
\r
74 > 2 files changed, 30 insertions(+), 0 deletions(-)
\r
76 > diff --git a/mime-node.c b/mime-node.c
\r
77 > index a8e4a59..207818e 100644
\r
80 > @@ -232,3 +232,28 @@ mime_node_child (const mime_node_t *parent, int child)
\r
81 > g_type_name (G_OBJECT_TYPE (parent->part)));
\r
85 > +static mime_node_t *
\r
86 > +_mime_node_seek_dfs_walk (mime_node_t *node, int *n)
\r
88 > + mime_node_t *ret = NULL;
\r
92 Can we move declarations below the if (which does not need them)? I
\r
93 always have troubles remembering if (recent enough) C standard allows
\r
94 that or it is a GCC extension. FWIW in the previous patch there are
\r
95 declarations in the middle of a block, e.g.:
\r
98 out->is_signed = TRUE;
\r
100 GMimeSignatureValidity *sig_validity = g_mime_multipart_signed_verify
\r
101 (GMIME_MULTIPART_SIGNED (part), out->ctx->cryptoctx, &err);
\r
103 So either we can move these declarations to where they are needed, or we
\r
104 should fix it in _mime_node_create().
\r
108 Comment for mime_node_seek_dfs() says that the function returns the node
\r
109 itself for n = 0, but does not say anything about n < 0. I would expect
\r
110 the function to return NULL for n < 0. In any case, the comment below
\r
111 should probably mention what happens for n < 0;
\r
117 Perhaps *n -= 1? Or even --(*n)?
\r
119 > + for (i = 0; i < node->children && !ret; i++) {
\r
121 Consider s/i++/++i/.
\r
126 > + mime_node_t *child = mime_node_child (node, i);
\r
127 > + ret = _mime_node_seek_dfs_walk (child, n);
\r
129 > + talloc_free (child);
\r
135 > +mime_node_seek_dfs (mime_node_t *node, int n)
\r
137 > + return _mime_node_seek_dfs_walk (node, &n);
\r
139 > diff --git a/notmuch-client.h b/notmuch-client.h
\r
140 > index fce1187..f215d4b 100644
\r
141 > --- a/notmuch-client.h
\r
142 > +++ b/notmuch-client.h
\r
143 > @@ -318,5 +318,10 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
\r
145 > mime_node_child (const mime_node_t *parent, int child);
\r
147 > +/* Return the nth child of node in a depth-first traversal. If n is
\r
148 > + * 0, returns node itself. Returns NULL if there is no such part. */
\r
150 > +mime_node_seek_dfs (mime_node_t *node, int n);
\r
152 > #include "command-line-arguments.h"
\r
157 > _______________________________________________
\r
158 > notmuch mailing list
\r
159 > notmuch@notmuchmail.org
\r
160 > http://notmuchmail.org/mailman/listinfo/notmuch
\r