--- /dev/null
+Return-Path: <sojkam1@fel.cvut.cz>\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 0DA50431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 3 Nov 2014 15:51:23 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3] 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 2EnuzhFVxXVt for <notmuch@notmuchmail.org>;\r
+ Mon, 3 Nov 2014 15:51:19 -0800 (PST)\r
+Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
+ by olra.theworths.org (Postfix) with ESMTP id 44996429E36\r
+ for <notmuch@notmuchmail.org>; Mon, 3 Nov 2014 15:50:53 -0800 (PST)\r
+Received: from localhost (unknown [192.168.200.7])\r
+ by max.feld.cvut.cz (Postfix) with ESMTP id BCD885CD005\r
+ for <notmuch@notmuchmail.org>; Tue, 4 Nov 2014 00:50:52 +0100 (CET)\r
+X-Virus-Scanned: IMAP STYX AMAVIS\r
+Received: from max.feld.cvut.cz ([192.168.200.1])\r
+ by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new,\r
+ port 10044) with ESMTP id uoK5k0-pv_uy for <notmuch@notmuchmail.org>;\r
+ Tue, 4 Nov 2014 00:50:46 +0100 (CET)\r
+Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
+ by max.feld.cvut.cz (Postfix) with ESMTP id E58255CD00D\r
+ for <notmuch@notmuchmail.org>; Tue, 4 Nov 2014 00:50:40 +0100 (CET)\r
+Received: from wsh by steelpick.2x.cz with local (Exim 4.84)\r
+ (envelope-from <sojkam1@fel.cvut.cz>)\r
+ id 1XlROM-0005WU-2w; Tue, 04 Nov 2014 00:50:34 +0100\r
+From: Michal Sojka <sojkam1@fel.cvut.cz>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 03/10] cli: search: Convert ctx. to ctx->\r
+Date: Tue, 4 Nov 2014 00:50:15 +0100\r
+Message-Id: <1415058622-21162-4-git-send-email-sojkam1@fel.cvut.cz>\r
+X-Mailer: git-send-email 2.1.1\r
+In-Reply-To: <1415058622-21162-1-git-send-email-sojkam1@fel.cvut.cz>\r
+References: <1415058622-21162-1-git-send-email-sojkam1@fel.cvut.cz>\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: Mon, 03 Nov 2014 23:51:23 -0000\r
+\r
+Mostly text replacement.\r
+---\r
+ notmuch-search.c | 81 ++++++++++++++++++++++++++++----------------------------\r
+ 1 file changed, 41 insertions(+), 40 deletions(-)\r
+\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 3d2012b..6765a16 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -474,7 +474,7 @@ do_search_tags (const search_context_t *ctx)\r
+ int\r
+ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+ {\r
+- search_context_t ctx = {\r
++ search_context_t search_context = {\r
+ .format_sel = NOTMUCH_FORMAT_TEXT,\r
+ .exclude = NOTMUCH_EXCLUDE_TRUE,\r
+ .sort = NOTMUCH_SORT_NEWEST_FIRST,\r
+@@ -483,23 +483,24 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+ .limit = -1, /* unlimited */\r
+ .dupe = -1,\r
+ };\r
++ search_context_t *ctx = &search_context;\r
+ char *query_str;\r
+ int opt_index, ret;\r
+ unsigned int i;\r
+ \r
+ notmuch_opt_desc_t options[] = {\r
+- { NOTMUCH_OPT_KEYWORD, &ctx.sort, "sort", 's',\r
++ { NOTMUCH_OPT_KEYWORD, &ctx->sort, "sort", 's',\r
+ (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },\r
+ { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },\r
+ { 0, 0 } } },\r
+- { NOTMUCH_OPT_KEYWORD, &ctx.format_sel, "format", 'f',\r
++ { NOTMUCH_OPT_KEYWORD, &ctx->format_sel, "format", 'f',\r
+ (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },\r
+ { "sexp", NOTMUCH_FORMAT_SEXP },\r
+ { "text", NOTMUCH_FORMAT_TEXT },\r
+ { "text0", NOTMUCH_FORMAT_TEXT0 },\r
+ { 0, 0 } } },\r
+ { NOTMUCH_OPT_INT, ¬much_format_version, "format-version", 0, 0 },\r
+- { NOTMUCH_OPT_KEYWORD_FLAGS, &ctx.output, "output", 'o',\r
++ { NOTMUCH_OPT_KEYWORD_FLAGS, &ctx->output, "output", 'o',\r
+ (notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY },\r
+ { "threads", OUTPUT_THREADS },\r
+ { "messages", OUTPUT_MESSAGES },\r
+@@ -508,15 +509,15 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+ { "files", OUTPUT_FILES },\r
+ { "tags", OUTPUT_TAGS },\r
+ { 0, 0 } } },\r
+- { NOTMUCH_OPT_KEYWORD, &ctx.exclude, "exclude", 'x',\r
++ { NOTMUCH_OPT_KEYWORD, &ctx->exclude, "exclude", 'x',\r
+ (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },\r
+ { "false", NOTMUCH_EXCLUDE_FALSE },\r
+ { "flag", NOTMUCH_EXCLUDE_FLAG },\r
+ { "all", NOTMUCH_EXCLUDE_ALL },\r
+ { 0, 0 } } },\r
+- { NOTMUCH_OPT_INT, &ctx.offset, "offset", 'O', 0 },\r
+- { NOTMUCH_OPT_INT, &ctx.limit, "limit", 'L', 0 },\r
+- { NOTMUCH_OPT_INT, &ctx.dupe, "duplicate", 'D', 0 },\r
++ { NOTMUCH_OPT_INT, &ctx->offset, "offset", 'O', 0 },\r
++ { NOTMUCH_OPT_INT, &ctx->limit, "limit", 'L', 0 },\r
++ { NOTMUCH_OPT_INT, &ctx->dupe, "duplicate", 'D', 0 },\r
+ { 0, 0, 0, 0, 0 }\r
+ };\r
+ \r
+@@ -524,31 +525,31 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+ if (opt_index < 0)\r
+ return EXIT_FAILURE;\r
+ \r
+- if (! ctx.output)\r
+- ctx.output = OUTPUT_SUMMARY;\r
++ if (! ctx->output)\r
++ ctx->output = OUTPUT_SUMMARY;\r
+ \r
+- if (ctx.output != OUTPUT_FILES && ctx.output != OUTPUT_MESSAGES &&\r
+- ctx.dupe != -1) {\r
++ if (ctx->output != OUTPUT_FILES && ctx->output != OUTPUT_MESSAGES &&\r
++ ctx->dupe != -1) {\r
+ fprintf (stderr, "Error: --duplicate=N is only supported with --output=files and --output=messages.\n");\r
+ return EXIT_FAILURE;\r
+ }\r
+ \r
+- switch (ctx.format_sel) {\r
++ switch (ctx->format_sel) {\r
+ case NOTMUCH_FORMAT_TEXT:\r
+- ctx.format = sprinter_text_create (config, stdout);\r
++ ctx->format = sprinter_text_create (config, stdout);\r
+ break;\r
+ case NOTMUCH_FORMAT_TEXT0:\r
+- if (ctx.output == OUTPUT_SUMMARY) {\r
++ if (ctx->output == OUTPUT_SUMMARY) {\r
+ fprintf (stderr, "Error: --format=text0 is not compatible with --output=summary.\n");\r
+ return EXIT_FAILURE;\r
+ }\r
+- ctx.format = sprinter_text0_create (config, stdout);\r
++ ctx->format = sprinter_text0_create (config, stdout);\r
+ break;\r
+ case NOTMUCH_FORMAT_JSON:\r
+- ctx.format = sprinter_json_create (config, stdout);\r
++ ctx->format = sprinter_json_create (config, stdout);\r
+ break;\r
+ case NOTMUCH_FORMAT_SEXP:\r
+- ctx.format = sprinter_sexp_create (config, stdout);\r
++ ctx->format = sprinter_sexp_create (config, stdout);\r
+ break;\r
+ default:\r
+ /* this should never happen */\r
+@@ -558,10 +559,10 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+ notmuch_exit_if_unsupported_format ();\r
+ \r
+ if (notmuch_database_open (notmuch_config_get_database_path (config),\r
+- NOTMUCH_DATABASE_MODE_READ_ONLY, &ctx.notmuch))\r
++ NOTMUCH_DATABASE_MODE_READ_ONLY, &ctx->notmuch))\r
+ return EXIT_FAILURE;\r
+ \r
+- query_str = query_string_from_args (ctx.notmuch, argc-opt_index, argv+opt_index);\r
++ query_str = query_string_from_args (ctx->notmuch, argc-opt_index, argv+opt_index);\r
+ if (query_str == NULL) {\r
+ fprintf (stderr, "Out of memory.\n");\r
+ return EXIT_FAILURE;\r
+@@ -571,51 +572,51 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+ return EXIT_FAILURE;\r
+ }\r
+ \r
+- ctx.query = notmuch_query_create (ctx.notmuch, query_str);\r
+- if (ctx.query == NULL) {\r
++ ctx->query = notmuch_query_create (ctx->notmuch, query_str);\r
++ if (ctx->query == NULL) {\r
+ fprintf (stderr, "Out of memory\n");\r
+ return EXIT_FAILURE;\r
+ }\r
+ \r
+- notmuch_query_set_sort (ctx.query, ctx.sort);\r
++ notmuch_query_set_sort (ctx->query, ctx->sort);\r
+ \r
+- if (ctx.exclude == NOTMUCH_EXCLUDE_FLAG && ctx.output != OUTPUT_SUMMARY) {\r
++ if (ctx->exclude == NOTMUCH_EXCLUDE_FLAG && ctx->output != OUTPUT_SUMMARY) {\r
+ /* If we are not doing summary output there is nowhere to\r
+ * print the excluded flag so fall back on including the\r
+ * excluded messages. */\r
+ fprintf (stderr, "Warning: this output format cannot flag excluded messages.\n");\r
+- ctx.exclude = NOTMUCH_EXCLUDE_FALSE;\r
++ ctx->exclude = NOTMUCH_EXCLUDE_FALSE;\r
+ }\r
+ \r
+- if (ctx.exclude != NOTMUCH_EXCLUDE_FALSE) {\r
++ if (ctx->exclude != NOTMUCH_EXCLUDE_FALSE) {\r
+ const char **search_exclude_tags;\r
+ size_t search_exclude_tags_length;\r
+ \r
+ search_exclude_tags = notmuch_config_get_search_exclude_tags\r
+ (config, &search_exclude_tags_length);\r
+ for (i = 0; i < search_exclude_tags_length; i++)\r
+- notmuch_query_add_tag_exclude (ctx.query, search_exclude_tags[i]);\r
+- notmuch_query_set_omit_excluded (ctx.query, ctx.exclude);\r
++ notmuch_query_add_tag_exclude (ctx->query, search_exclude_tags[i]);\r
++ notmuch_query_set_omit_excluded (ctx->query, ctx->exclude);\r
+ }\r
+ \r
+- if (ctx.output == OUTPUT_SUMMARY ||\r
+- ctx.output == OUTPUT_THREADS)\r
+- ret = do_search_threads (&ctx);\r
+- else if (ctx.output == OUTPUT_MESSAGES ||\r
+- ctx.output == OUTPUT_FILES ||\r
+- (ctx.output & OUTPUT_ADDRESS_FLAGS && !(ctx.output & ~OUTPUT_ADDRESS_FLAGS)))\r
+- ret = do_search_messages (&ctx);\r
+- else if (ctx.output == OUTPUT_TAGS)\r
+- ret = do_search_tags (&ctx);\r
++ if (ctx->output == OUTPUT_SUMMARY ||\r
++ ctx->output == OUTPUT_THREADS)\r
++ ret = do_search_threads (ctx);\r
++ else if (ctx->output == OUTPUT_MESSAGES ||\r
++ ctx->output == OUTPUT_FILES ||\r
++ (ctx->output & OUTPUT_ADDRESS_FLAGS && !(ctx->output & ~OUTPUT_ADDRESS_FLAGS)))\r
++ ret = do_search_messages (ctx);\r
++ else if (ctx->output == OUTPUT_TAGS)\r
++ ret = do_search_tags (ctx);\r
+ else {\r
+ fprintf (stderr, "Error: the combination of outputs is not supported.\n");\r
+ ret = 1;\r
+ }\r
+ \r
+- notmuch_query_destroy (ctx.query);\r
+- notmuch_database_destroy (ctx.notmuch);\r
++ notmuch_query_destroy (ctx->query);\r
++ notmuch_database_destroy (ctx->notmuch);\r
+ \r
+- talloc_free (ctx.format);\r
++ talloc_free (ctx->format);\r
+ \r
+ return ret ? EXIT_FAILURE : EXIT_SUCCESS;\r
+ }\r
+-- \r
+2.1.1\r
+\r