Re: [PATCH 1/2] cli: convert notmuch_bool_t to stdbool

2017-10-09 Thread Daniel Kahn Gillmor
On Sat 2017-10-07 11:44:04 +0300, Jani Nikula wrote:
> C99 stdbool turned 18 this year. There really is no reason to use our
> own, except in the library interface for backward
> compatibility. Convert the cli and test binaries to stdbool.

+1 LGTM.

I'd also be interested in contemplating a switch to stdbool for the
library interface whenever we do the next ABI bump, but that's
presumably something to consider separately.

Thanks for this work, Jani.

--dkg


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/2] cli: convert notmuch_bool_t to stdbool

2017-10-07 Thread Tomi Ollila
On Sat, Oct 07 2017, Jani Nikula wrote:

> C99 stdbool turned 18 this year. There really is no reason to use our
> own, except in the library interface for backward
> compatibility. Convert the cli and test binaries to stdbool.

+2 (i.e. +1 for both patches). I trust the changes works...

> ---
>  command-line-arguments.c | 58 +++
>  command-line-arguments.h | 10 ---
>  crypto.c |  6 ++---
>  debugger.c   |  8 +++---
>  gmime-filter-reply.c | 32 +++---
>  mime-node.c  | 10 +++
>  notmuch-client.h | 35 
>  notmuch-compact.c|  2 +-
>  notmuch-config.c | 28 +--
>  notmuch-count.c  | 18 ++---
>  notmuch-dump.c   | 10 +++
>  notmuch-insert.c | 70 
> 
>  notmuch-new.c| 30 ++---
>  notmuch-reply.c  | 30 ++---
>  notmuch-restore.c|  4 +--
>  notmuch-search.c | 24 -
>  notmuch-setup.c  |  6 ++---
>  notmuch-show.c   | 52 +--
>  notmuch-tag.c|  6 ++---
>  notmuch.c| 12 -
>  sprinter-json.c  | 18 ++---
>  sprinter-sexp.c  | 16 +--
>  sprinter-text.c  |  6 ++---
>  sprinter.h   |  6 ++---
>  tag-util.c   | 24 -
>  tag-util.h   |  8 +++---
>  test/arg-test.c  |  6 ++---
>  test/hex-xcode.c |  8 +++---
>  test/random-corpus.c |  2 +-
>  29 files changed, 275 insertions(+), 270 deletions(-)
>
> diff --git a/command-line-arguments.c b/command-line-arguments.c
> index 3fa8d9044966..1ff5aae578c6 100644
> --- a/command-line-arguments.c
> +++ b/command-line-arguments.c
> @@ -6,11 +6,11 @@
>  
>  /*
>Search the array of keywords for a given argument, assigning the
> -  output variable to the corresponding value.  Return FALSE if nothing
> +  output variable to the corresponding value.  Return false if nothing
>matches.
>  */
>  
> -static notmuch_bool_t
> +static bool
>  _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const 
> char *arg_str) {
>  
>  const notmuch_keyword_t *keywords;
> @@ -29,64 +29,64 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, 
> char next, const char
>   else
>   *arg_desc->opt_keyword = keywords->value;
>  
> - return TRUE;
> + return true;
>  }
>  if (next != '\0')
>   fprintf (stderr, "Unknown keyword argument \"%s\" for option 
> \"%s\".\n", arg_str, arg_desc->name);
>  else
>   fprintf (stderr, "Option \"%s\" needs a keyword argument.\n", 
> arg_desc->name);
> -return FALSE;
> +return false;
>  }
>  
> -static notmuch_bool_t
> +static bool
>  _process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const 
> char *arg_str) {
> -notmuch_bool_t value;
> +bool value;
>  
>  if (next == '\0' || strcmp (arg_str, "true") == 0) {
> - value = TRUE;
> + value = true;
>  } else if (strcmp (arg_str, "false") == 0) {
> - value = FALSE;
> + value = false;
>  } else {
>   fprintf (stderr, "Unknown argument \"%s\" for (boolean) option 
> \"%s\".\n", arg_str, arg_desc->name);
> - return FALSE;
> + return false;
>  }
>  
>  *arg_desc->opt_bool = value;
>  
> -return TRUE;
> +return true;
>  }
>  
> -static notmuch_bool_t
> +static bool
>  _process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char 
> *arg_str) {
>  
>  char *endptr;
>  if (next == '\0' || arg_str[0] == '\0') {
>   fprintf (stderr, "Option \"%s\" needs an integer argument.\n", 
> arg_desc->name);
> - return FALSE;
> + return false;
>  }
>  
>  *arg_desc->opt_int = strtol (arg_str, , 10);
>  if (*endptr == '\0')
> - return TRUE;
> + return true;
>  
>  fprintf (stderr, "Unable to parse argument \"%s\" for option \"%s\" as 
> an integer.\n",
>arg_str, arg_desc->name);
> -return FALSE;
> +return false;
>  }
>  
> -static notmuch_bool_t
> +static bool
>  _process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const 
> char *arg_str) {
>  
>  if (next == '\0') {
>   fprintf (stderr, "Option \"%s\" needs a string argument.\n", 
> arg_desc->name);
> - return FALSE;
> + return false;
>  }
>  if (arg_str[0] == '\0') {
>   fprintf (stderr, "String argument for option \"%s\" must be 
> non-empty.\n", arg_desc->name);
> - return FALSE;
> + return false;
>  }
>  *arg_desc->opt_string = arg_str;
> -return TRUE;
> +return true;
>  }
>  
>  /* Return number of non-NULL opt_* fields in opt_desc. */
> @@ -102,8 +102,8 @@ static int _opt_set_count (const notmuch_opt_desc_t 
> *opt_desc)
>   !!opt_desc->opt_position;
>  }
>  
> -/* 

[PATCH 1/2] cli: convert notmuch_bool_t to stdbool

2017-10-07 Thread Jani Nikula
C99 stdbool turned 18 this year. There really is no reason to use our
own, except in the library interface for backward
compatibility. Convert the cli and test binaries to stdbool.
---
 command-line-arguments.c | 58 +++
 command-line-arguments.h | 10 ---
 crypto.c |  6 ++---
 debugger.c   |  8 +++---
 gmime-filter-reply.c | 32 +++---
 mime-node.c  | 10 +++
 notmuch-client.h | 35 
 notmuch-compact.c|  2 +-
 notmuch-config.c | 28 +--
 notmuch-count.c  | 18 ++---
 notmuch-dump.c   | 10 +++
 notmuch-insert.c | 70 
 notmuch-new.c| 30 ++---
 notmuch-reply.c  | 30 ++---
 notmuch-restore.c|  4 +--
 notmuch-search.c | 24 -
 notmuch-setup.c  |  6 ++---
 notmuch-show.c   | 52 +--
 notmuch-tag.c|  6 ++---
 notmuch.c| 12 -
 sprinter-json.c  | 18 ++---
 sprinter-sexp.c  | 16 +--
 sprinter-text.c  |  6 ++---
 sprinter.h   |  6 ++---
 tag-util.c   | 24 -
 tag-util.h   |  8 +++---
 test/arg-test.c  |  6 ++---
 test/hex-xcode.c |  8 +++---
 test/random-corpus.c |  2 +-
 29 files changed, 275 insertions(+), 270 deletions(-)

diff --git a/command-line-arguments.c b/command-line-arguments.c
index 3fa8d9044966..1ff5aae578c6 100644
--- a/command-line-arguments.c
+++ b/command-line-arguments.c
@@ -6,11 +6,11 @@
 
 /*
   Search the array of keywords for a given argument, assigning the
-  output variable to the corresponding value.  Return FALSE if nothing
+  output variable to the corresponding value.  Return false if nothing
   matches.
 */
 
-static notmuch_bool_t
+static bool
 _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const 
char *arg_str) {
 
 const notmuch_keyword_t *keywords;
@@ -29,64 +29,64 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, 
char next, const char
else
*arg_desc->opt_keyword = keywords->value;
 
-   return TRUE;
+   return true;
 }
 if (next != '\0')
fprintf (stderr, "Unknown keyword argument \"%s\" for option 
\"%s\".\n", arg_str, arg_desc->name);
 else
fprintf (stderr, "Option \"%s\" needs a keyword argument.\n", 
arg_desc->name);
-return FALSE;
+return false;
 }
 
-static notmuch_bool_t
+static bool
 _process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const 
char *arg_str) {
-notmuch_bool_t value;
+bool value;
 
 if (next == '\0' || strcmp (arg_str, "true") == 0) {
-   value = TRUE;
+   value = true;
 } else if (strcmp (arg_str, "false") == 0) {
-   value = FALSE;
+   value = false;
 } else {
fprintf (stderr, "Unknown argument \"%s\" for (boolean) option 
\"%s\".\n", arg_str, arg_desc->name);
-   return FALSE;
+   return false;
 }
 
 *arg_desc->opt_bool = value;
 
-return TRUE;
+return true;
 }
 
-static notmuch_bool_t
+static bool
 _process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char 
*arg_str) {
 
 char *endptr;
 if (next == '\0' || arg_str[0] == '\0') {
fprintf (stderr, "Option \"%s\" needs an integer argument.\n", 
arg_desc->name);
-   return FALSE;
+   return false;
 }
 
 *arg_desc->opt_int = strtol (arg_str, , 10);
 if (*endptr == '\0')
-   return TRUE;
+   return true;
 
 fprintf (stderr, "Unable to parse argument \"%s\" for option \"%s\" as an 
integer.\n",
 arg_str, arg_desc->name);
-return FALSE;
+return false;
 }
 
-static notmuch_bool_t
+static bool
 _process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char 
*arg_str) {
 
 if (next == '\0') {
fprintf (stderr, "Option \"%s\" needs a string argument.\n", 
arg_desc->name);
-   return FALSE;
+   return false;
 }
 if (arg_str[0] == '\0') {
fprintf (stderr, "String argument for option \"%s\" must be 
non-empty.\n", arg_desc->name);
-   return FALSE;
+   return false;
 }
 *arg_desc->opt_string = arg_str;
-return TRUE;
+return true;
 }
 
 /* Return number of non-NULL opt_* fields in opt_desc. */
@@ -102,8 +102,8 @@ static int _opt_set_count (const notmuch_opt_desc_t 
*opt_desc)
!!opt_desc->opt_position;
 }
 
-/* Return TRUE if opt_desc is valid. */
-static notmuch_bool_t _opt_valid (const notmuch_opt_desc_t *opt_desc)
+/* Return true if opt_desc is valid. */
+static bool _opt_valid (const notmuch_opt_desc_t *opt_desc)
 {
 int n = _opt_set_count (opt_desc);
 
@@ -115,11 +115,11 @@ static notmuch_bool_t _opt_valid (const 
notmuch_opt_desc_t *opt_desc)
 }
 
 /*
-