unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Uncrustify on notmuch-restore.c, notmuch-dump.c and notmuch-tag.c
@ 2012-11-15  1:33 david
  2012-11-15  1:33 ` [PATCH 1/3] notmuch-tag: tidy formatting david
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: david @ 2012-11-15  1:33 UTC (permalink / raw)
  To: notmuch

Here is the result of running uncrustify on 3 files affected by an
upcoming patch series. It makes easier to make sure my new code is
reasonable styled if the whole file is uncrustify clean.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] notmuch-tag: tidy formatting
  2012-11-15  1:33 Uncrustify on notmuch-restore.c, notmuch-dump.c and notmuch-tag.c david
@ 2012-11-15  1:33 ` david
  2012-11-15  1:33 ` [PATCH 2/3] notmuch-restore: " david
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: david @ 2012-11-15  1:33 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner

From: David Bremner <bremner@debian.org>

This is just the result of running uncrustify.
---
 notmuch-tag.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/notmuch-tag.c b/notmuch-tag.c
index d15f1ed..88d559b 100644
--- a/notmuch-tag.c
+++ b/notmuch-tag.c
@@ -31,7 +31,7 @@ handle_sigint (unused (int sig))
      * result.  It is not required for correctness, and if it does
      * fail or produce a short write, we want to get out of the signal
      * handler as quickly as possible, not retry it. */
-    IGNORE_RESULT (write (2, msg, sizeof(msg)-1));
+    IGNORE_RESULT (write (2, msg, sizeof (msg) - 1));
     interrupted = 1;
 }
 
@@ -40,6 +40,7 @@ _escape_tag (char *buf, const char *tag)
 {
     const char *in = tag;
     char *out = buf;
+
     /* Boolean terms surrounded by double quotes can contain any
      * character.  Double quotes are quoted by doubling them. */
     *out++ = '"';
@@ -85,8 +86,8 @@ _optimize_tag_query (void *ctx, const char *orig_query_string,
     for (i = 0; tag_ops[i].tag; i++)
 	if (strlen (tag_ops[i].tag) > max_tag_len)
 	    max_tag_len = strlen (tag_ops[i].tag);
-    escaped = talloc_array(ctx, char, max_tag_len * 2 + 3);
-    if (!escaped)
+    escaped = talloc_array (ctx, char, max_tag_len * 2 + 3);
+    if (! escaped)
 	return NULL;
 
     /* Build the new query string */
@@ -140,9 +141,8 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,
     notmuch_query_set_sort (query, NOTMUCH_SORT_UNSORTED);
 
     for (messages = notmuch_query_search_messages (query);
-	 notmuch_messages_valid (messages) && !interrupted;
-	 notmuch_messages_move_to_next (messages))
-    {
+	 notmuch_messages_valid (messages) && ! interrupted;
+	 notmuch_messages_move_to_next (messages)) {
 	message = notmuch_messages_get (messages);
 
 	notmuch_message_freeze (message);
@@ -204,14 +204,14 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])
 	}
 	if (argv[i][0] == '+' || argv[i][0] == '-') {
 	    if (argv[i][0] == '+' && argv[i][1] == '\0') {
-		fprintf(stderr, "Error: tag names cannot be empty.\n");
+		fprintf (stderr, "Error: tag names cannot be empty.\n");
 		return 1;
 	    }
 	    if (argv[i][0] == '+' && argv[i][1] == '-') {
 		/* This disallows adding the non-removable tag "-" and
 		 * enables notmuch tag to take long options in the
 		 * future. */
-		fprintf(stderr, "Error: tag names must not start with '-'.\n");
+		fprintf (stderr, "Error: tag names must not start with '-'.\n");
 		return 1;
 	    }
 	    tag_ops[tag_ops_count].tag = argv[i] + 1;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] notmuch-restore: tidy formatting
  2012-11-15  1:33 Uncrustify on notmuch-restore.c, notmuch-dump.c and notmuch-tag.c david
  2012-11-15  1:33 ` [PATCH 1/3] notmuch-tag: tidy formatting david
@ 2012-11-15  1:33 ` david
  2012-11-15 15:21   ` Tomi Ollila
  2012-11-15  1:33 ` [PATCH 3/3] notmuch-dump: " david
  2012-11-16 12:49 ` Uncrustify on notmuch-restore.c, notmuch-dump.c and notmuch-tag.c David Bremner
  3 siblings, 1 reply; 6+ messages in thread
From: david @ 2012-11-15  1:33 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner

From: David Bremner <bremner@debian.org>

This is again the work of uncrustify.

I remember there is some controversy about "! foo" versus "!foo", but
in context I think "! foo" looks OK. Also, for functions "! foo
(blah)" seems better than "!foo (blah)".
---
 notmuch-restore.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/notmuch-restore.c b/notmuch-restore.c
index 7d8f44c..f03dcac 100644
--- a/notmuch-restore.c
+++ b/notmuch-restore.c
@@ -38,13 +38,13 @@ tag_message (notmuch_database_t *notmuch, const char *message_id,
 	fprintf (stderr, "Warning: Cannot apply tags to %smessage: %s\n",
 		 message ? "" : "missing ", message_id);
 	if (status)
-	    fprintf (stderr, "%s\n", notmuch_status_to_string(status));
+	    fprintf (stderr, "%s\n", notmuch_status_to_string (status));
 	return 1;
     }
 
     /* In order to detect missing messages, this check/optimization is
      * intentionally done *after* first finding the message. */
-    if (!remove_all && (file_tags == NULL || *file_tags == '\0'))
+    if (! remove_all && (file_tags == NULL || *file_tags == '\0'))
 	goto DONE;
 
     db_tags_str = NULL;
@@ -88,7 +88,7 @@ tag_message (notmuch_database_t *notmuch, const char *message_id,
     if (synchronize_flags)
 	notmuch_message_tags_to_maildir_flags (message);
 
-DONE:
+  DONE:
     if (message)
 	notmuch_message_destroy (message);
 
@@ -145,7 +145,7 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
 
     if (opt_index < argc) {
 	fprintf (stderr,
-	 "Unused positional parameter: %s\n",
+		 "Unused positional parameter: %s\n",
 		 argv[opt_index]);
 	return 1;
     }
@@ -157,7 +157,7 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
     if ( xregcomp (&regex,
 		   "^([^ ]+) \\(([^)]*)\\)$",
 		   REG_EXTENDED) )
-	INTERNAL_ERROR("compile time constant regex failed.");
+	INTERNAL_ERROR ("compile time constant regex failed.");
 
     while ((line_len = getline (&line, &line_size, input)) != -1) {
 	regmatch_t match[3];
@@ -166,8 +166,7 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
 	chomp_newline (line);
 
 	rerr = xregexec (&regex, line, 3, match, 0);
-	if (rerr == REG_NOMATCH)
-	{
+	if (rerr == REG_NOMATCH) {
 	    fprintf (stderr, "Warning: Ignoring invalid input line: %s\n",
 		     line);
 	    continue;
@@ -178,7 +177,7 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
 	file_tags = xstrndup (line + match[2].rm_so,
 			      match[2].rm_eo - match[2].rm_so);
 
-	tag_message (notmuch, message_id, file_tags, !accumulate,
+	tag_message (notmuch, message_id, file_tags, ! accumulate,
 		     synchronize_flags);
 
 	free (message_id);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] notmuch-dump: tidy formatting
  2012-11-15  1:33 Uncrustify on notmuch-restore.c, notmuch-dump.c and notmuch-tag.c david
  2012-11-15  1:33 ` [PATCH 1/3] notmuch-tag: tidy formatting david
  2012-11-15  1:33 ` [PATCH 2/3] notmuch-restore: " david
@ 2012-11-15  1:33 ` david
  2012-11-16 12:49 ` Uncrustify on notmuch-restore.c, notmuch-dump.c and notmuch-tag.c David Bremner
  3 siblings, 0 replies; 6+ messages in thread
From: david @ 2012-11-15  1:33 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner

From: David Bremner <bremner@debian.org>

More uncrustify at work.
---
 notmuch-dump.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/notmuch-dump.c b/notmuch-dump.c
index d8186fb..88f598a 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -30,7 +30,7 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
     notmuch_messages_t *messages;
     notmuch_message_t *message;
     notmuch_tags_t *tags;
-    const char* query_str = "";
+    const char *query_str = "";
 
     config = notmuch_config_open (ctx, NULL, NULL);
     if (config == NULL)
@@ -66,7 +66,7 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
 
 
     if (opt_index < argc) {
-	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;
@@ -85,8 +85,7 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
 
     for (messages = notmuch_query_search_messages (query);
 	 notmuch_messages_valid (messages);
-	 notmuch_messages_move_to_next (messages))
-    {
+	 notmuch_messages_move_to_next (messages)) {
 	int first = 1;
 	message = notmuch_messages_get (messages);
 
@@ -95,8 +94,7 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
 
 	for (tags = notmuch_message_get_tags (message);
 	     notmuch_tags_valid (tags);
-	     notmuch_tags_move_to_next (tags))
-	{
+	     notmuch_tags_move_to_next (tags)) {
 	    if (! first)
 		fprintf (output, " ");
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] notmuch-restore: tidy formatting
  2012-11-15  1:33 ` [PATCH 2/3] notmuch-restore: " david
@ 2012-11-15 15:21   ` Tomi Ollila
  0 siblings, 0 replies; 6+ messages in thread
From: Tomi Ollila @ 2012-11-15 15:21 UTC (permalink / raw)
  To: david, notmuch; +Cc: David Bremner

On Thu, Nov 15 2012, david@tethera.net wrote:

> From: David Bremner <bremner@debian.org>
>
> This is again the work of uncrustify.
>
> I remember there is some controversy about "! foo" versus "!foo", but
> in context I think "! foo" looks OK. Also, for functions "! foo
> (blah)" seems better than "!foo (blah)".

Currently:
$ egrep '! ' *.c | wc
     19     108    1074
$ egrep '![^ =]' *.c | wc 
     41     250    2223

Anyway IIRC Carl preferred the ! foo format and the code might
have drifted away from that...

Whatever this choice will eventually be for "pure" notmuch code
should not affect what the code that can be considered as
external libraries should be formatted; e.g. parse-time-string
code should keep the formatting Jani prefers.

The uncrustify.cfg option 'sp_not' affects whether there is
space after ! or not -- and it can even be configured to 'ignore'
this case.

Tomi

// patch dropped.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Uncrustify on notmuch-restore.c, notmuch-dump.c and notmuch-tag.c
  2012-11-15  1:33 Uncrustify on notmuch-restore.c, notmuch-dump.c and notmuch-tag.c david
                   ` (2 preceding siblings ...)
  2012-11-15  1:33 ` [PATCH 3/3] notmuch-dump: " david
@ 2012-11-16 12:49 ` David Bremner
  3 siblings, 0 replies; 6+ messages in thread
From: David Bremner @ 2012-11-16 12:49 UTC (permalink / raw)
  To: notmuch

david@tethera.net writes:

> Here is the result of running uncrustify on 3 files affected by an
> upcoming patch series. It makes easier to make sure my new code is
> reasonable styled if the whole file is uncrustify clean.

Pushed, 

d

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-11-16 12:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-15  1:33 Uncrustify on notmuch-restore.c, notmuch-dump.c and notmuch-tag.c david
2012-11-15  1:33 ` [PATCH 1/3] notmuch-tag: tidy formatting david
2012-11-15  1:33 ` [PATCH 2/3] notmuch-restore: " david
2012-11-15 15:21   ` Tomi Ollila
2012-11-15  1:33 ` [PATCH 3/3] notmuch-dump: " david
2012-11-16 12:49 ` Uncrustify on notmuch-restore.c, notmuch-dump.c and notmuch-tag.c David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).