Re: [PATCH 3/4] Utility function to seek in MIME trees in depth-first order.
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Sat, 10 Dec 2011 11:43:29 +0000 (15:43 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:40:43 +0000 (09:40 -0800)
89/6f54247a69116c80444514764d003452635954 [new file with mode: 0644]

diff --git a/89/6f54247a69116c80444514764d003452635954 b/89/6f54247a69116c80444514764d003452635954
new file mode 100644 (file)
index 0000000..b97e2cd
--- /dev/null
@@ -0,0 +1,160 @@
+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 92A11429E25\r
+       for <notmuch@notmuchmail.org>; Sat, 10 Dec 2011 03:44:13 -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 WBY0V6+GGZA6 for <notmuch@notmuchmail.org>;\r
+       Sat, 10 Dec 2011 03:44:11 -0800 (PST)\r
+Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com\r
+       [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 543EA431FB6\r
+       for <notmuch@notmuchmail.org>; Sat, 10 Dec 2011 03:44:11 -0800 (PST)\r
+Received: by bkat8 with SMTP id t8so4092685bka.26\r
+       for <notmuch@notmuchmail.org>; Sat, 10 Dec 2011 03:44:08 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+       :mime-version:content-type;\r
+       bh=fR0KfrGdU4UJ+gVbfzI5Uc39RkYGVKLGRVeGtlrP/Ik=;\r
+       b=rApFqKHO9ZpYidoYTtQ5KxGMC/XGozmXPbeDe+qJzlWHums7w0fK8xIfATzBcYTUTX\r
+       ENn23zhT1xG7nYUZMnetSCj+jcbILESH83bnzyFpJ6Kf1nDGz969xzeubhjdmZUTtpyj\r
+       6ktVBPxCypEATDTFAqfm2mUGqO/WaZLDk1oJQ=\r
+Received: by 10.204.128.130 with SMTP id k2mr5691320bks.7.1323517444209;\r
+       Sat, 10 Dec 2011 03:44:04 -0800 (PST)\r
+Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id\r
+       fg16sm16533407bkb.16.2011.12.10.03.44.02\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sat, 10 Dec 2011 03:44:02 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 3/4] Utility function to seek in MIME trees in depth-first\r
+       order.\r
+In-Reply-To: <1323460468-4030-4-git-send-email-amdragon@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
+User-Agent: Notmuch/0.10.2+82~g96a629c (http://notmuchmail.org) Emacs/23.3.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Sat, 10 Dec 2011 15:43:29 +0400\r
+Message-ID: <87hb187iu6.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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: Sat, 10 Dec 2011 11:44:13 -0000\r
+\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
+> +    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
+> +    return node;\r
+> +\r
+> +    *n = *n - 1;\r
+\r
+Perhaps *n -= 1?  Or even --(*n)?\r
+\r
+> +    for (i = 0; i < node->children && !ret; i++) {\r
+\r
+Consider s/i++/++i/.\r
+\r
+Regards,\r
+  Dmitry\r
+\r
+> +    mime_node_t *child = mime_node_child (node, i);\r
+> +    ret = _mime_node_seek_dfs_walk (child, n);\r
+> +    if (!ret)\r
+> +        talloc_free (child);\r
+> +    }\r
+> +    return ret;\r
+> +}\r
+> +\r
+> +mime_node_t *\r
+> +mime_node_seek_dfs (mime_node_t *node, int n)\r
+> +{\r
+> +    return _mime_node_seek_dfs_walk (node, &n);\r
+> +}\r
+> diff --git a/notmuch-client.h b/notmuch-client.h\r
+> index fce1187..f215d4b 100644\r
+> --- a/notmuch-client.h\r
+> +++ b/notmuch-client.h\r
+> @@ -318,5 +318,10 @@ mime_node_open (const void *ctx, notmuch_message_t *message,\r
+>  mime_node_t *\r
+>  mime_node_child (const mime_node_t *parent, int child);\r
+>  \r
+> +/* Return the nth child of node in a depth-first traversal.  If n is\r
+> + * 0, returns node itself.  Returns NULL if there is no such part. */\r
+> +mime_node_t *\r
+> +mime_node_seek_dfs (mime_node_t *node, int n);\r
+> +\r
+>  #include "command-line-arguments.h"\r
+>  #endif\r
+> -- \r
+> 1.7.7.3\r
+> \r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r