--- /dev/null
+Return-Path: <too@guru-group.fi>\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 34CD0431FC0\r
+ for <notmuch@notmuchmail.org>; Sat, 4 Jan 2014 05:47:45 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ 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 owfyC3rUGyy1 for <notmuch@notmuchmail.org>;\r
+ Sat, 4 Jan 2014 05:47:39 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id AEB02431FBD\r
+ for <notmuch@notmuchmail.org>; Sat, 4 Jan 2014 05:47:38 -0800 (PST)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id 8A41E10014F; Sat, 4 Jan 2014 15:47:32 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/1] cli: tuned coding style on a small set of c files in root\r
+ dir\r
+Date: Sat, 4 Jan 2014 15:47:30 +0200\r
+Message-Id: <1388843250-4714-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 1.8.0\r
+Cc: tomi.ollila@iki.fi\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, 04 Jan 2014 13:47:45 -0000\r
+\r
+The c files in root directory not starting with 'notmuch'.\r
+\r
+gmime-filter-reply.c used 8-character indenting and seems to\r
+be "external" in this project; therefore it was left intact.\r
+\r
+No functional change.\r
+---\r
+\r
+Based on the response to this patch I may submit much larger\r
+patch which tunes the style in ./notmuch*.[ch] files...\r
+\r
+ command-line-arguments.c | 71 +++++++++++++++++++++++++++---------------------\r
+ command-line-arguments.h | 34 +++++++++++------------\r
+ debugger.c | 3 +-\r
+ hooks.c | 4 +--\r
+ mime-node.c | 24 ++++++++--------\r
+ 5 files changed, 73 insertions(+), 63 deletions(-)\r
+\r
+diff --git a/command-line-arguments.c b/command-line-arguments.c\r
+index bf9aeca..969269c 100644\r
+--- a/command-line-arguments.c\r
++++ b/command-line-arguments.c\r
+@@ -5,13 +5,14 @@\r
+ #include "command-line-arguments.h"\r
+ \r
+ /*\r
+- Search the array of keywords for a given argument, assigning the\r
+- output variable to the corresponding value. Return FALSE if nothing\r
+- matches.\r
+-*/\r
++ * Search the array of keywords for a given argument, assigning the\r
++ * output variable to the corresponding value. Return FALSE if nothing\r
++ * matches.\r
++ */\r
+ \r
+ static notmuch_bool_t\r
+-_process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {\r
++_process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str)\r
++{\r
+ \r
+ const notmuch_keyword_t *keywords = arg_desc->keywords;\r
+ \r
+@@ -23,7 +24,7 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char\r
+ while (keywords->name) {\r
+ if (strcmp (arg_str, keywords->name) == 0) {\r
+ if (arg_desc->output_var) {\r
+- *((int *)arg_desc->output_var) = keywords->value;\r
++ *((int *) arg_desc->output_var) = keywords->value;\r
+ }\r
+ return TRUE;\r
+ }\r
+@@ -37,18 +38,19 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char\r
+ }\r
+ \r
+ static notmuch_bool_t\r
+-_process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {\r
++_process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str)\r
++{\r
+ \r
+ if (next == '\0') {\r
+- *((notmuch_bool_t *)arg_desc->output_var) = TRUE;\r
++ *((notmuch_bool_t *) arg_desc->output_var) = TRUE;\r
+ return TRUE;\r
+ }\r
+ if (strcmp (arg_str, "false") == 0) {\r
+- *((notmuch_bool_t *)arg_desc->output_var) = FALSE;\r
++ *((notmuch_bool_t *) arg_desc->output_var) = FALSE;\r
+ return TRUE;\r
+ }\r
+ if (strcmp (arg_str, "true") == 0) {\r
+- *((notmuch_bool_t *)arg_desc->output_var) = TRUE;\r
++ *((notmuch_bool_t *) arg_desc->output_var) = TRUE;\r
+ return TRUE;\r
+ }\r
+ fprintf (stderr, "Unknown argument \"%s\" for (boolean) option \"%s\".\n", arg_str, arg_desc->name);\r
+@@ -56,15 +58,17 @@ _process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char\r
+ }\r
+ \r
+ static notmuch_bool_t\r
+-_process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {\r
++_process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str)\r
++{\r
+ \r
+ char *endptr;\r
++\r
+ if (next == '\0' || arg_str[0] == '\0') {\r
+ fprintf (stderr, "Option \"%s\" needs an integer argument.\n", arg_desc->name);\r
+ return FALSE;\r
+ }\r
+ \r
+- *((int *)arg_desc->output_var) = strtol (arg_str, &endptr, 10);\r
++ *((int *) arg_desc->output_var) = strtol (arg_str, &endptr, 10);\r
+ if (*endptr == '\0')\r
+ return TRUE;\r
+ \r
+@@ -74,7 +78,8 @@ _process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg\r
+ }\r
+ \r
+ static notmuch_bool_t\r
+-_process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {\r
++_process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str)\r
++{\r
+ \r
+ if (next == '\0') {\r
+ fprintf (stderr, "Option \"%s\" needs a string argument.\n", arg_desc->name);\r
+@@ -84,25 +89,27 @@ _process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *\r
+ fprintf (stderr, "String argument for option \"%s\" must be non-empty.\n", arg_desc->name);\r
+ return FALSE;\r
+ }\r
+- *((const char **)arg_desc->output_var) = arg_str;\r
++ *((const char **) arg_desc->output_var) = arg_str;\r
+ return TRUE;\r
+ }\r
+ \r
+ /*\r
+- Search for the {pos_arg_index}th position argument, return FALSE if\r
+- that does not exist.\r
+-*/\r
++ * Search for the {pos_arg_index}th position argument, return FALSE if\r
++ * that does not exist.\r
++ */\r
+ \r
+ notmuch_bool_t\r
+ parse_position_arg (const char *arg_str, int pos_arg_index,\r
+- const notmuch_opt_desc_t *arg_desc) {\r
++ const notmuch_opt_desc_t *arg_desc)\r
++{\r
+ \r
+ int pos_arg_counter = 0;\r
+- while (arg_desc->opt_type != NOTMUCH_OPT_END){\r
++\r
++ while (arg_desc->opt_type != NOTMUCH_OPT_END) {\r
+ if (arg_desc->opt_type == NOTMUCH_OPT_POSITION) {\r
+ if (pos_arg_counter == pos_arg_index) {\r
+ if (arg_desc->output_var) {\r
+- *((const char **)arg_desc->output_var) = arg_str;\r
++ *((const char **) arg_desc->output_var) = arg_str;\r
+ }\r
+ return TRUE;\r
+ }\r
+@@ -120,10 +127,11 @@ parse_position_arg (const char *arg_str, int pos_arg_index,\r
+ \r
+ notmuch_bool_t\r
+ parse_option (const char *arg,\r
+- const notmuch_opt_desc_t *options) {\r
++ const notmuch_opt_desc_t *options)\r
++{\r
+ \r
+- assert(arg);\r
+- assert(options);\r
++ assert (arg);\r
++ assert (options);\r
+ \r
+ arg += 2;\r
+ \r
+@@ -131,13 +139,13 @@ parse_option (const char *arg,\r
+ for (try = options; try->opt_type != NOTMUCH_OPT_END; try++) {\r
+ if (try->name && strncmp (arg, try->name, strlen (try->name)) == 0) {\r
+ char next = arg[strlen (try->name)];\r
+- const char *value= arg+strlen(try->name)+1;\r
++ const char *value = arg + strlen (try->name) + 1;\r
+ \r
+ /* If we have not reached the end of the argument\r
+- (i.e. the next character is not a space or delimiter)\r
+- then the argument could still match a longer option\r
+- name later in the option table.\r
+- */\r
++ * (i.e. the next character is not a space or delimiter)\r
++ * then the argument could still match a longer option\r
++ * name later in the option table.\r
++ */\r
+ if (next != '=' && next != ':' && next != '\0')\r
+ continue;\r
+ \r
+@@ -172,13 +180,14 @@ parse_option (const char *arg,\r
+ /* See command-line-arguments.h for description */\r
+ int\r
+ parse_arguments (int argc, char **argv,\r
+- const notmuch_opt_desc_t *options, int opt_index) {\r
++ const notmuch_opt_desc_t *options, int opt_index)\r
++{\r
+ \r
+ int pos_arg_index = 0;\r
+ notmuch_bool_t more_args = TRUE;\r
+ \r
+ while (more_args && opt_index < argc) {\r
+- if (strncmp (argv[opt_index],"--",2) != 0) {\r
++ if (strncmp (argv[opt_index], "--", 2) != 0) {\r
+ \r
+ more_args = parse_position_arg (argv[opt_index], pos_arg_index, options);\r
+ \r
+@@ -190,7 +199,7 @@ parse_arguments (int argc, char **argv,\r
+ } else {\r
+ \r
+ if (strlen (argv[opt_index]) == 2)\r
+- return opt_index+1;\r
++ return opt_index + 1;\r
+ \r
+ more_args = parse_option (argv[opt_index], options);\r
+ if (more_args) {\r
+diff --git a/command-line-arguments.h b/command-line-arguments.h\r
+index de1734a..3ac714e 100644\r
+--- a/command-line-arguments.h\r
++++ b/command-line-arguments.h\r
+@@ -37,26 +37,26 @@ typedef struct notmuch_opt_desc {\r
+ enum notmuch_opt_type opt_type;\r
+ void *output_var;\r
+ const char *name;\r
+- int arg_id;\r
++ int arg_id;\r
+ const struct notmuch_keyword *keywords;\r
+ } notmuch_opt_desc_t;\r
+ \r
+ \r
+ /*\r
+- This is the main entry point for command line argument parsing.\r
+-\r
+- Parse command line arguments according to structure options,\r
+- starting at position opt_index.\r
+-\r
+- All output of parsed values is via pointers in options.\r
+-\r
+- Parsing stops at -- (consumed) or at the (k+1)st argument\r
+- not starting with -- (a "positional argument") if options contains\r
+- k positional argument descriptors.\r
+-\r
+- Returns the index of first non-parsed argument, or -1 in case of error.\r
+-\r
+-*/\r
++ * This is the main entry point for command line argument parsing.\r
++ *\r
++ * Parse command line arguments according to structure options,\r
++ * starting at position opt_index.\r
++ *\r
++ * All output of parsed values is via pointers in options.\r
++ *\r
++ * Parsing stops at -- (consumed) or at the (k+1)st argument\r
++ * not starting with -- (a "positional argument") if options contains\r
++ * k positional argument descriptors.\r
++ *\r
++ * Returns the index of first non-parsed argument, or -1 in case of error.\r
++ *\r
++ */\r
+ int\r
+ parse_arguments (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_index);\r
+ \r
+@@ -69,12 +69,12 @@ parse_arguments (int argc, char **argv, const notmuch_opt_desc_t *options, int o\r
+ */\r
+ \r
+ notmuch_bool_t\r
+-parse_option (const char *arg, const notmuch_opt_desc_t* options);\r
++parse_option (const char *arg, const notmuch_opt_desc_t *options);\r
+ \r
+ notmuch_bool_t\r
+ parse_position_arg (const char *arg,\r
+ int position_arg_index,\r
+- const notmuch_opt_desc_t* options);\r
++ const notmuch_opt_desc_t *options);\r
+ \r
+ \r
+ #endif\r
+diff --git a/debugger.c b/debugger.c\r
+index e8b9378..1d35e1f 100644\r
+--- a/debugger.c\r
++++ b/debugger.c\r
+@@ -38,8 +38,7 @@ debugger_is_active (void)\r
+ \r
+ sprintf (buf, "/proc/%d/exe", getppid ());\r
+ if (readlink (buf, buf, sizeof (buf)) != -1 &&\r
+- strncmp (basename (buf), "gdb", 3) == 0)\r
+- {\r
++ strncmp (basename (buf), "gdb", 3) == 0) {\r
+ return TRUE;\r
+ }\r
+ \r
+diff --git a/hooks.c b/hooks.c\r
+index 44ee419..d995171 100644\r
+--- a/hooks.c\r
++++ b/hooks.c\r
+@@ -50,7 +50,7 @@ notmuch_run_hook (const char *db_path, const char *hook)\r
+ goto DONE;\r
+ }\r
+ \r
+- pid = fork();\r
++ pid = fork ();\r
+ if (pid == -1) {\r
+ fprintf (stderr, "Error: %s hook fork failed: %s\n", hook,\r
+ strerror (errno));\r
+@@ -75,7 +75,7 @@ notmuch_run_hook (const char *db_path, const char *hook)\r
+ goto DONE;\r
+ }\r
+ \r
+- if (!WIFEXITED (status) || WEXITSTATUS (status)) {\r
++ if (! WIFEXITED (status) || WEXITSTATUS (status)) {\r
+ if (WIFEXITED (status)) {\r
+ fprintf (stderr, "Error: %s hook failed with status %d\n",\r
+ hook, WEXITSTATUS (status));\r
+diff --git a/mime-node.c b/mime-node.c\r
+index fd9e4a4..2ff93de 100644\r
+--- a/mime-node.c\r
++++ b/mime-node.c\r
+@@ -87,7 +87,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,\r
+ }\r
+ \r
+ mctx->stream = g_mime_stream_file_new (mctx->file);\r
+- if (!mctx->stream) {\r
++ if (! mctx->stream) {\r
+ fprintf (stderr, "Out of memory.\n");\r
+ status = NOTMUCH_STATUS_OUT_OF_MEMORY;\r
+ goto DONE;\r
+@@ -95,14 +95,14 @@ mime_node_open (const void *ctx, notmuch_message_t *message,\r
+ g_mime_stream_file_set_owner (GMIME_STREAM_FILE (mctx->stream), FALSE);\r
+ \r
+ mctx->parser = g_mime_parser_new_with_stream (mctx->stream);\r
+- if (!mctx->parser) {\r
++ if (! mctx->parser) {\r
+ fprintf (stderr, "Out of memory.\n");\r
+ status = NOTMUCH_STATUS_OUT_OF_MEMORY;\r
+ goto DONE;\r
+ }\r
+ \r
+ mctx->mime_message = g_mime_parser_construct_message (mctx->parser);\r
+- if (!mctx->mime_message) {\r
++ if (! mctx->mime_message) {\r
+ fprintf (stderr, "Failed to parse %s\n", filename);\r
+ status = NOTMUCH_STATUS_FILE_ERROR;\r
+ goto DONE;\r
+@@ -124,7 +124,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,\r
+ *root_out = root;\r
+ return NOTMUCH_STATUS_SUCCESS;\r
+ \r
+-DONE:\r
++ DONE:\r
+ talloc_free (root);\r
+ return status;\r
+ }\r
+@@ -144,6 +144,7 @@ static void\r
+ set_signature_list_destructor (mime_node_t *node)\r
+ {\r
+ GMimeSignatureList **proxy = talloc (node, GMimeSignatureList *);\r
++\r
+ if (proxy) {\r
+ *proxy = node->sig_list;\r
+ talloc_set_destructor (proxy, _signature_list_free);\r
+@@ -200,7 +201,7 @@ node_decrypt_and_verify (mime_node_t *node, GMimeObject *part,\r
+ }\r
+ g_object_unref (decrypt_result);\r
+ \r
+- DONE:\r
++ DONE:\r
+ if (err)\r
+ g_error_free (err);\r
+ }\r
+@@ -221,6 +222,7 @@ set_signature_validity_destructor (mime_node_t *node,\r
+ GMimeSignatureValidity *sig_validity)\r
+ {\r
+ GMimeSignatureValidity **proxy = talloc (node, GMimeSignatureValidity *);\r
++\r
+ if (proxy) {\r
+ *proxy = sig_validity;\r
+ talloc_set_destructor (proxy, _signature_validity_free);\r
+@@ -279,12 +281,12 @@ node_decrypt_and_verify (mime_node_t *node, GMimeObject *part,\r
+ fprintf (stderr, "Failed to verify encrypted signed part: %s\n",\r
+ err ? err->message : "no error explanation given");\r
+ \r
+- DONE:\r
++ DONE:\r
+ if (err)\r
+ g_error_free (err);\r
+ }\r
+ \r
+-#endif /* GMIME_ATLEAST_26 */\r
++#endif /* GMIME_ATLEAST_26 */\r
+ \r
+ static mime_node_t *\r
+ _mime_node_create (mime_node_t *parent, GMimeObject *part)\r
+@@ -295,7 +297,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)\r
+ /* Set basic node properties */\r
+ node->part = part;\r
+ node->ctx = parent->ctx;\r
+- if (!talloc_reference (node, node->ctx)) {\r
++ if (! talloc_reference (node, node->ctx)) {\r
+ fprintf (stderr, "Out of memory.\n");\r
+ talloc_free (node);\r
+ return NULL;\r
+@@ -360,7 +362,7 @@ mime_node_child (mime_node_t *parent, int child)\r
+ GMimeObject *sub;\r
+ mime_node_t *node;\r
+ \r
+- if (!parent || !parent->part || child < 0 || child >= parent->nchildren)\r
++ if (! parent || ! parent->part || child < 0 || child >= parent->nchildren)\r
+ return NULL;\r
+ \r
+ if (GMIME_IS_MULTIPART (parent->part)) {\r
+@@ -412,10 +414,10 @@ _mime_node_seek_dfs_walk (mime_node_t *node, int *n)\r
+ return node;\r
+ \r
+ *n -= 1;\r
+- for (i = 0; i < node->nchildren && !ret; i++) {\r
++ for (i = 0; i < node->nchildren && ! ret; i++) {\r
+ mime_node_t *child = mime_node_child (node, i);\r
+ ret = _mime_node_seek_dfs_walk (child, n);\r
+- if (!ret)\r
++ if (! ret)\r
+ talloc_free (child);\r
+ }\r
+ return ret;\r
+-- \r
+1.8.4.2\r
+\r