From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id CAE526DE141F for ; Wed, 12 Jun 2019 04:35:03 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.048 X-Spam-Level: X-Spam-Status: No, score=-0.048 tagged_above=-999 required=5 tests=[AWL=-0.047, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bR4rpzSvXyvT for ; Wed, 12 Jun 2019 04:35:02 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id BD9666DE0F6C for ; Wed, 12 Jun 2019 04:34:59 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1hb1Ws-0003Sz-TZ; Wed, 12 Jun 2019 07:34:58 -0400 Received: (nullmailer pid 2974 invoked by uid 1000); Wed, 12 Jun 2019 11:35:08 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 1/7] cli: replace use of !! with macro Date: Wed, 12 Jun 2019 08:35:00 -0300 Message-Id: <20190612113506.2892-2-david@tethera.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612113506.2892-1-david@tethera.net> References: <20190612113506.2892-1-david@tethera.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jun 2019 11:35:03 -0000 The slightly annoying reason to do this is because uncrustify can't handle '!! foo' sensibly. The less annoying reason is that it helps understand what the code does. --- command-line-arguments.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/command-line-arguments.c b/command-line-arguments.c index d64aa85b..5f0607be 100644 --- a/command-line-arguments.c +++ b/command-line-arguments.c @@ -4,6 +4,8 @@ #include "error_util.h" #include "command-line-arguments.h" +#define TO_BOOL(thing) (!! thing) + typedef enum { OPT_FAILED, /* false */ OPT_OK, /* good */ @@ -120,13 +122,13 @@ _process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char * static int _opt_set_count (const notmuch_opt_desc_t *opt_desc) { return - !!opt_desc->opt_inherit + - !!opt_desc->opt_bool + - !!opt_desc->opt_int + - !!opt_desc->opt_keyword + - !!opt_desc->opt_flags + - !!opt_desc->opt_string + - !!opt_desc->opt_position; + TO_BOOL (opt_desc->opt_inherit) + + TO_BOOL (opt_desc->opt_bool) + + TO_BOOL (opt_desc->opt_int) + + TO_BOOL (opt_desc->opt_keyword) + + TO_BOOL (opt_desc->opt_flags) + + TO_BOOL (opt_desc->opt_string) + + TO_BOOL (opt_desc->opt_position); } /* Return true if opt_desc is valid. */ -- 2.20.1