Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id CC9F66DE1AE1 for ; Mon, 6 Apr 2015 05:23:55 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.481 X-Spam-Level: X-Spam-Status: No, score=0.481 tagged_above=-999 required=5 tests=[AWL=0.471, T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] 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 Glgyw6EqjGo2 for ; Mon, 6 Apr 2015 05:23:53 -0700 (PDT) Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net [87.98.215.224]) by arlo.cworth.org (Postfix) with ESMTPS id 12FE16DE1AC6 for ; Mon, 6 Apr 2015 05:23:52 -0700 (PDT) Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim 4.80) (envelope-from ) id 1Yf63a-00058n-9J; Mon, 06 Apr 2015 12:23:10 +0000 Received: (nullmailer pid 3269 invoked by uid 1000); Mon, 06 Apr 2015 12:22:52 -0000 From: David Bremner To: David Bremner , notmuch@notmuchmail.org Subject: argument parsing refactoring, round 2 Date: Mon, 6 Apr 2015 21:22:34 +0900 Message-Id: <1428322958-2887-1-git-send-email-david@tethera.net> X-Mailer: git-send-email 2.1.4 In-Reply-To: <87d23ixnr7.fsf@maritornes.cs.unb.ca> References: <87d23ixnr7.fsf@maritornes.cs.unb.ca> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.18 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: Mon, 06 Apr 2015 12:23:56 -0000 Thanks to Mark for pointing out on IRC that the previous version had problems linking the test suite helpers. That's fixed here by adding a couple stubs. Here's the diff, roughly with the previous version (actually the first hunk is with a slightly later version, where I fixed one bug and introduced another). diff --git a/notmuch-config.c b/notmuch-config.c index 568b3dc..f2cd6a8 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -885,9 +885,9 @@ notmuch_config_command (notmuch_config_t *config, int argc, char *argv[]) notmuch_process_shared_options (argv[0]); - /* skip subcommand argument */ - argc-= opt_index+1; - argv+= opt_index+1; + /* skip at least subcommand argument */ + argc-= opt_index; + argv+= opt_index; if (argc < 1) { fprintf (stderr, "Error: notmuch config requires at least one argument.\n"); diff --git a/notmuch-setup.c b/notmuch-setup.c index 5fc6e25..6a020dc 100644 --- a/notmuch-setup.c +++ b/notmuch-setup.c @@ -155,7 +155,7 @@ notmuch_setup_command (notmuch_config_t *config, if (opt_index < 0) return EXIT_FAILURE; - notmuch_process_shared_options (argv[0]); + notmuch_process_shared_options ("setup"); if (notmuch_config_is_new (config)) welcome_message_pre_setup (); diff --git a/test/random-corpus.c b/test/random-corpus.c index 790193d..6c467bb 100644 --- a/test/random-corpus.c +++ b/test/random-corpus.c @@ -114,6 +114,15 @@ random_utf8_string (void *ctx, size_t char_count) return buf; } +/* stubs since we cannot link with notmuch.o */ +const notmuch_opt_desc_t notmuch_shared_options[] = { + { 0, 0, 0, 0, 0 } +}; + +void +notmuch_process_shared_options (unused (const char *dummy)) +{ +} int main (int argc, char **argv)