Re: [PATCH 2/2] notmuch-reply.c: uncrustify

Subject: Re: [PATCH 2/2] notmuch-reply.c: uncrustify

Date: Thu, 12 Jan 2012 09:08:18 -0400

To: Austin Clements

Cc: notmuch@notmuchmail.org

From: David Bremner


On Wed, 11 Jan 2012 22:57:39 -0500, Austin Clements <amdragon@MIT.EDU> wrote:
> > From: David Bremner <bremner@debian.org>
> > 
> > This patch shows the raw result of running uncrustify on notmuch-reply.c.
> > The re-indenting of "format_reply" would probably not be desirable.
> 
> The good news is that that structure is on its way out.
> 
> > @@ -625,6 +612,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
> >      notmuch_query_t *query;
> >      char *query_string;
> >      int opt_index, ret = 0;
> > +
> 
> This one's a little weird.  Did it get confused by the function
> prototype?

Yes, I think it is thinking the block of variable declarations ends
there.

> All of the other format fixes look very reasonable to me.  I think you
> managed to find one of the least canonical source files in the tree.
> Was that intentional?

Yes, I expect there would be less changes elsewhere. Although the
changes might be more controversial, I guess. 

The corresponding diff for notmuch-search.c follows

diff --git a/notmuch-search.c b/notmuch-search.c
index 4baab56..8928e62 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -31,16 +31,16 @@ typedef enum {
 typedef struct search_format {
     const char *results_start;
     const char *item_start;
-    void (*item_id) (const void *ctx,
-		     const char *item_type,
-		     const char *item_id);
-    void (*thread_summary) (const void *ctx,
-			    const char *thread_id,
-			    const time_t date,
-			    const int matched,
-			    const int total,
-			    const char *authors,
-			    const char *subject);
+    void (*item_id)(const void *ctx,
+		    const char *item_type,
+		    const char *item_id);
+    void (*thread_summary)(const void *ctx,
+			   const char *thread_id,
+			   const time_t date,
+			   const int matched,
+			   const int total,
+			   const char *authors,
+			   const char *subject);
     const char *tag_start;
     const char *tag;
     const char *tag_sep;
@@ -66,13 +66,13 @@ format_thread_text (const void *ctx,
 		    const char *subject);
 static const search_format_t format_text = {
     "",
-	"",
-	    format_item_id_text,
-	    format_thread_text,
-	    " (",
-		"%s", " ",
-	    ")", "\n",
-	"",
+    "",
+    format_item_id_text,
+    format_thread_text,
+    " (",
+    "%s", " ",
+    ")", "\n",
+    "",
     "\n",
     "",
 };
@@ -92,13 +92,13 @@ format_thread_json (const void *ctx,
 		    const char *subject);
 static const search_format_t format_json = {
     "[",
-	"{",
-	    format_item_id_json,
-	    format_thread_json,
-	    "\"tags\": [",
-		"\"%s\"", ", ",
-	    "]", ",\n",
-	"}",
+    "{",
+    format_item_id_json,
+    format_thread_json,
+    "\"tags\": [",
+    "\"%s\"", ", ",
+    "]", ",\n",
+    "}",
     "]\n",
     "]\n",
 };
@@ -122,7 +122,7 @@ sanitize_string (const void *ctx, const char *str)
     loop = out = talloc_strdup (ctx, str);
 
     for (; *loop; loop++) {
-	if ((unsigned char)(*loop) < 32)
+	if ((unsigned char) (*loop) < 32)
 	    *loop = '?';
     }
     return out;
@@ -160,7 +160,7 @@ format_item_id_json (const void *ctx,
     printf ("%s", json_quote_str (ctx_quote, item_id));
 
     talloc_free (ctx_quote);
-    
+
 }
 
 static void
@@ -221,8 +221,7 @@ do_search_threads (const search_format_t *format,
 
     for (i = 0;
 	 notmuch_threads_valid (threads) && (limit < 0 || i < offset + limit);
-	 notmuch_threads_move_to_next (threads), i++)
-    {
+	 notmuch_threads_move_to_next (threads), i++) {
 	int first_tag = 1;
 
 	thread = notmuch_threads_get (threads);
@@ -232,7 +231,7 @@ do_search_threads (const search_format_t *format,
 	    continue;
 	}
 
-	if (! first_thread)
+	if (!first_thread)
 	    fputs (format->item_sep, stdout);
 
 	if (output == OUTPUT_THREADS) {
@@ -258,9 +257,8 @@ do_search_threads (const search_format_t *format,
 
 	    for (tags = notmuch_thread_get_tags (thread);
 		 notmuch_tags_valid (tags);
-		 notmuch_tags_move_to_next (tags))
-	    {
-		if (! first_tag)
+		 notmuch_tags_move_to_next (tags)) {
+		if (!first_tag)
 		    fputs (format->tag_sep, stdout);
 		printf (format->tag, notmuch_tags_get (tags));
 		first_tag = 0;
@@ -311,8 +309,7 @@ do_search_messages (const search_format_t *format,
 
     for (i = 0;
 	 notmuch_messages_valid (messages) && (limit < 0 || i < offset + limit);
-	 notmuch_messages_move_to_next (messages), i++)
-    {
+	 notmuch_messages_move_to_next (messages), i++) {
 	if (i < offset)
 	    continue;
 
@@ -323,9 +320,8 @@ do_search_messages (const search_format_t *format,
 
 	    for (;
 		 notmuch_filenames_valid (filenames);
-		 notmuch_filenames_move_to_next (filenames))
-	    {
-		if (! first_message)
+		 notmuch_filenames_move_to_next (filenames)) {
+		if (!first_message)
 		    fputs (format->item_sep, stdout);
 
 		format->item_id (message, "",
@@ -333,11 +329,11 @@ do_search_messages (const search_format_t *format,
 
 		first_message = 0;
 	    }
-	    
-	    notmuch_filenames_destroy( filenames );
+
+	    notmuch_filenames_destroy ( filenames );
 
 	} else { /* output == OUTPUT_MESSAGES */
-	    if (! first_message)
+	    if (!first_message)
 		fputs (format->item_sep, stdout);
 
 	    format->item_id (message, "id:",
@@ -385,11 +381,10 @@ do_search_tags (notmuch_database_t *notmuch,
 
     for (;
 	 notmuch_tags_valid (tags);
-	 notmuch_tags_move_to_next (tags))
-    {
+	 notmuch_tags_move_to_next (tags)) {
 	tag = notmuch_tags_get (tags);
 
-	if (! first_tag)
+	if (!first_tag)
 	    fputs (format->item_sep, stdout);
 
 	format->item_id (tags, "", tag);
@@ -425,7 +420,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
     int limit = -1; /* unlimited */
 
     enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }
-	format_sel = NOTMUCH_FORMAT_TEXT;
+    format_sel = NOTMUCH_FORMAT_TEXT;
 
     notmuch_opt_desc_t options[] = {
 	{ NOTMUCH_OPT_KEYWORD, &sort, "sort", 's',
@@ -472,7 +467,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
     if (notmuch == NULL)
 	return 1;
 
-    query_str = query_string_from_args (notmuch, argc-opt_index, argv+opt_index);
+    query_str = query_string_from_args (notmuch, argc - opt_index, argv + opt_index);
     if (query_str == NULL) {
 	fprintf (stderr, "Out of memory.\n");
 	return 1;

Thread: