Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 39A33429E21 for ; Wed, 11 Jan 2012 10:26:43 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XiVB7IAi3rmO for ; Wed, 11 Jan 2012 10:26:42 -0800 (PST) Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU [18.9.25.13]) by olra.theworths.org (Postfix) with ESMTP id 94761431FB6 for ; Wed, 11 Jan 2012 10:26:42 -0800 (PST) X-AuditID: 1209190d-b7fbf6d0000008ba-d3-4f0dd461e2e8 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP id 84.DC.02234.164DD0F4; Wed, 11 Jan 2012 13:26:42 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q0BIQfbG002409; Wed, 11 Jan 2012 13:26:41 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0BIQbqX005764 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Wed, 11 Jan 2012 13:26:38 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1Rl2sG-0004D3-I3; Wed, 11 Jan 2012 13:26:12 -0500 Date: Wed, 11 Jan 2012 13:26:12 -0500 From: Austin Clements To: Jani Nikula Subject: Re: [PATCH 1/3] count: Convert to new-style argument parsing Message-ID: <20120111182453.GS20796@mit.edu> References: <20120109043101.GH20796@mit.edu> <1326258173-21163-1-git-send-email-amdragon@mit.edu> <1326258173-21163-2-git-send-email-amdragon@mit.edu> <87zkdulkla.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87zkdulkla.fsf@nikula.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hRV1k26wutvcPs4o0XTdGeL6zdnMjsw edy6/5rd49mqW8wBTFFcNimpOZllqUX6dglcGZvvnmcuWM9bcbdzFUsD43KuLkZODgkBE4mb zd+YIGwxiQv31rN1MXJxCAnsY5T48msmK4SzgVHi7qyFUM5JJomep+eZIJwljBIz770H62cR UJX4cHw+C4jNJqAhsW3/ckYQW0RAUWLzyf1gNrOAtMS3381g9cICrhL3z9xhBbF5BXQk5vU2 gcWFBHYwSjTszYaIC0qcnPmEBaJXS+LGv5dANRxgc5b/4wAJcwKtWvn8MRuILSqgIjHl5Da2 CYxCs5B0z0LSPQuhewEj8ypG2ZTcKt3cxMyc4tRk3eLkxLy81CJdI73czBK91JTSTYzgsJbk 3cH47qDSIUYBDkYlHt6de3n9hVgTy4orcw8xSnIwKYnyhl0CCvEl5adUZiQWZ8QXleakFh9i lOBgVhLhdaoByvGmJFZWpRblw6SkOViUxHlVtd75CQmkJ5akZqemFqQWwWRlODiUJHhPXgZq FCxKTU+tSMvMKUFIM3FwggznARruClLDW1yQmFucmQ6RP8WoKCXO+wgkIQCSyCjNg+uFpZ1X jOJArwjz7gep4gGmLLjuV0CDmYAGb1nHAzK4JBEhJdXA6DWdo/tfV9TrOeUH2Q98Dj95+PUe l+1HW1pPPfr99sXs02I6cruDlp3nd75y4cHFpiszjk15fYn3v/KpoN0rrZ8W7hdN+PUoPO1M U0jo7p8XE6y0Mz7p3D7HGL9odfE5X5YtM//r/ypJ0eBU//K021co0HvXK6ffUs27kpbYyP9L U/0uqVvlwa7EUpyRaKjFXFScCABGhCqxFgMAAA== Cc: notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 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, 11 Jan 2012 18:26:43 -0000 Quoth Jani Nikula on Jan 11 at 8:17 am: > On Wed, 11 Jan 2012 00:02:51 -0500, Austin Clements wrote: > > --- > > notmuch-count.c | 53 +++++++++++++++++++++++++---------------------------- > > 1 files changed, 25 insertions(+), 28 deletions(-) > > > > diff --git a/notmuch-count.c b/notmuch-count.c > > index 20ce334..fb7401b 100644 > > --- a/notmuch-count.c > > +++ b/notmuch-count.c > > @@ -21,6 +21,11 @@ > > > > #include "notmuch-client.h" > > > > +typedef enum { > > + OUTPUT_THREADS, > > + OUTPUT_MESSAGES, > > +} output_t; > > + > > int > > notmuch_count_command (void *ctx, int argc, char *argv[]) > > { > > @@ -28,35 +33,23 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) > > notmuch_database_t *notmuch; > > notmuch_query_t *query; > > char *query_str; > > - int i; > > - notmuch_bool_t output_messages = TRUE; > > + int opt_index; > > + output_t output = OUTPUT_MESSAGES; > > > > - argc--; argv++; /* skip subcommand argument */ > > + notmuch_opt_desc_t options[] = { > > + { NOTMUCH_OPT_KEYWORD, &output, "output", 'o', > > + (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS }, > > + { "messages", OUTPUT_MESSAGES }, > > + { 0, 0 } } }, > > To be pedantic, parse_arguments() expects 'output_var' to be a pointer > to int for NOTMUCH_OPT_KEYWORD. sizeof(enum) is implementation > dependent. I would forget about output_t typedef, use plain enum, and > int type for 'output'. Pedantic or not, that's a good point. We should fix this in notmuch-search.c, too (which is where I shamelessly copied this from). Or make the argument parser more type-safe.