1 Return-Path: <m.walters@qmul.ac.uk>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id F089E431FAF
\r
6 for <notmuch@notmuchmail.org>; Tue, 5 Jun 2012 07:34:21 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5
\r
12 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,
\r
13 NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id 338a2AplJeSk for <notmuch@notmuchmail.org>;
\r
17 Tue, 5 Jun 2012 07:34:21 -0700 (PDT)
\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 4CFDB431FAE
\r
22 for <notmuch@notmuchmail.org>; Tue, 5 Jun 2012 07:34:21 -0700 (PDT)
\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])
\r
24 by mail2.qmul.ac.uk with esmtp (Exim 4.71)
\r
25 (envelope-from <m.walters@qmul.ac.uk>)
\r
26 id 1Sbupt-00063f-9m; Tue, 05 Jun 2012 15:34:17 +0100
\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]
\r
29 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)
\r
30 (envelope-from <m.walters@qmul.ac.uk>)
\r
31 id 1Sbups-0007lf-Vv; Tue, 05 Jun 2012 15:34:17 +0100
\r
32 From: Mark Walters <markwalters1009@gmail.com>
\r
33 To: Peter Wang <novalazy@gmail.com>, notmuch@notmuchmail.org
\r
34 Subject: Re: [PATCH] cli: make the command line parser's errors more
\r
36 In-Reply-To: <20120605184037.GB14297@hili.localdomain>
\r
37 References: <1338723972-13063-1-git-send-email-markwalters1009@gmail.com>
\r
38 <1338724128-13158-1-git-send-email-markwalters1009@gmail.com>
\r
39 <20120605184037.GB14297@hili.localdomain>
\r
40 User-Agent: Notmuch/0.13+55~g992aa73 (http://notmuchmail.org) Emacs/23.3.1
\r
41 (x86_64-pc-linux-gnu)
\r
42 Date: Tue, 05 Jun 2012 15:34:19 +0100
\r
43 Message-ID: <87oboxakus.fsf@qmul.ac.uk>
\r
45 Content-Type: text/plain; charset=us-ascii
\r
46 X-Sender-Host-Address: 94.192.233.223
\r
47 X-QM-SPAM-Info: Sender has good ham record. :)
\r
48 X-QM-Body-MD5: a79baf0f0899e319b14bb1c657376935 (of first 20000 bytes)
\r
49 X-SpamAssassin-Score: -1.8
\r
50 X-SpamAssassin-SpamBar: -
\r
51 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
53 spam. We require at least 5.0 points to mark a message as spam.
\r
54 This message scored -1.8 points.
\r
55 Summary of the scoring:
\r
56 * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,
\r
58 * [138.37.6.40 listed in list.dnswl.org]
\r
59 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
60 provider * (markwalters1009[at]gmail.com)
\r
61 * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay
\r
63 * 0.5 AWL AWL: From: address is in the auto white-list
\r
64 X-QM-Scan-Virus: ClamAV says the message is clean
\r
65 X-BeenThere: notmuch@notmuchmail.org
\r
66 X-Mailman-Version: 2.1.13
\r
68 List-Id: "Use and development of the notmuch mail system."
\r
69 <notmuch.notmuchmail.org>
\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
73 List-Post: <mailto:notmuch@notmuchmail.org>
\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
76 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
77 X-List-Received-Date: Tue, 05 Jun 2012 14:34:22 -0000
\r
80 On Tue, 05 Jun 2012, Peter Wang <novalazy@gmail.com> wrote:
\r
81 > On Sun, 3 Jun 2012 12:48:48 +0100, Mark Walters <markwalters1009@gmail.com> wrote:
\r
83 >> +static notmuch_bool_t
\r
84 >> +_process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
\r
87 >> + if (next == 0 || arg_str[0] == 0) {
\r
88 >> + fprintf (stderr, "Option \"%s\" needs an integer argument.\n", arg_desc->name);
\r
92 >> + *((int *)arg_desc->output_var) = strtol (arg_str, &endptr, 10);
\r
93 >> + if (*endptr == 0)
\r
96 > It's usually clearer to write '\0' for the null character.
\r
98 Yes I agree: fixed. I also changed the other instances.
\r
100 >> @@ -99,20 +133,13 @@ parse_option (const char *arg,
\r
101 >> char next = arg[strlen (try->name)];
\r
102 >> const char *value= arg+strlen(try->name)+1;
\r
106 >> - /* Everything but boolean arguments (switches) needs a
\r
107 >> - * delimiter, and a non-zero length value. Boolean
\r
108 >> - * arguments may take an optional =true or =false value.
\r
110 >> - if (next != '=' && next != ':' && next != 0) return FALSE;
\r
111 >> - if (next == 0) {
\r
112 >> - if (try->opt_type != NOTMUCH_OPT_BOOLEAN &&
\r
113 >> - try->opt_type != NOTMUCH_OPT_KEYWORD)
\r
116 >> - if (value[0] == 0) return FALSE;
\r
118 >> + /* If this is not the end of the argument (i.e. the next
\r
119 >> + * character is not a space or a delimiter) we stop
\r
120 >> + * parsing for this option but allow the parsing to
\r
121 >> + * continue to for other options. This should allow
\r
122 >> + * options to be initial segments of other options. */
\r
124 > It took me a little while to figure out what the last sentence was
\r
127 > If we have not reached the end of the argument (i.e. the next
\r
128 > character is not a space or delimiter) then the argument could
\r
129 > still match a longer option name later in the option table.
\r
131 This is much clearer, thanks!
\r
133 > (otherwise, "continue to for other")
\r
135 >> + if (next != '=' && next != ':' && next != 0)
\r
136 >> + goto DONE_THIS_OPTION;
\r
138 > The `goto' could be expressed as a `continue' in a `for' loop, AFAICS.
\r
140 This is also much nicer. Updated patch follows
\r
142 Thanks for the review!
\r