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 E6708431FAF
\r
6 for <notmuch@notmuchmail.org>; Sun, 25 Nov 2012 08:13:13 -0800 (PST)
\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 TN9ObLkNZQy9 for <notmuch@notmuchmail.org>;
\r
17 Sun, 25 Nov 2012 08:13:13 -0800 (PST)
\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 4021E431FAE
\r
22 for <notmuch@notmuchmail.org>; Sun, 25 Nov 2012 08:13:13 -0800 (PST)
\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 1TcepT-00051s-RF; Sun, 25 Nov 2012 16:13:12 +0000
\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)
\r
28 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)
\r
29 (envelope-from <m.walters@qmul.ac.uk>)
\r
30 id 1TcepT-0001Tm-G2; Sun, 25 Nov 2012 16:13:11 +0000
\r
31 From: Mark Walters <markwalters1009@gmail.com>
\r
32 To: Peter Wang <novalazy@gmail.com>, notmuch@notmuchmail.org
\r
33 Subject: Re: [PATCH v2 01/20] tag: factor out tag operation parsing
\r
34 In-Reply-To: <1353806206-29133-2-git-send-email-novalazy@gmail.com>
\r
35 References: <1353806206-29133-1-git-send-email-novalazy@gmail.com>
\r
36 <1353806206-29133-2-git-send-email-novalazy@gmail.com>
\r
37 User-Agent: Notmuch/0.14+81~g9730584 (http://notmuchmail.org) Emacs/23.4.1
\r
38 (x86_64-pc-linux-gnu)
\r
39 Date: Sun, 25 Nov 2012 16:13:14 +0000
\r
40 Message-ID: <878v9pk6ed.fsf@qmul.ac.uk>
\r
42 Content-Type: text/plain; charset=us-ascii
\r
43 X-Sender-Host-Address: 93.97.24.31
\r
44 X-QM-SPAM-Info: Sender has good ham record. :)
\r
45 X-QM-Body-MD5: 3fe47295da988fc873e6072d710fbab1 (of first 20000 bytes)
\r
46 X-SpamAssassin-Score: -1.8
\r
47 X-SpamAssassin-SpamBar: -
\r
48 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
50 spam. We require at least 5.0 points to mark a message as spam.
\r
51 This message scored -1.8 points.
\r
52 Summary of the scoring:
\r
53 * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,
\r
55 * [138.37.6.40 listed in list.dnswl.org]
\r
56 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
57 provider * (markwalters1009[at]gmail.com)
\r
58 * 0.5 AWL AWL: From: address is in the auto white-list
\r
59 X-QM-Scan-Virus: ClamAV says the message is clean
\r
60 X-BeenThere: notmuch@notmuchmail.org
\r
61 X-Mailman-Version: 2.1.13
\r
63 List-Id: "Use and development of the notmuch mail system."
\r
64 <notmuch.notmuchmail.org>
\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
68 List-Post: <mailto:notmuch@notmuchmail.org>
\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
72 X-List-Received-Date: Sun, 25 Nov 2012 16:13:14 -0000
\r
75 On Sun, 25 Nov 2012, Peter Wang <novalazy@gmail.com> wrote:
\r
76 > Factor out parsing of +tag, -tag operations from argv
\r
77 > into a separate function.
\r
79 > notmuch-tag.c | 66 +++++++++++++++++++++++++++++++++++++----------------------
\r
80 > 1 file changed, 41 insertions(+), 25 deletions(-)
\r
82 > diff --git a/notmuch-tag.c b/notmuch-tag.c
\r
83 > index 88d559b..35a76db 100644
\r
84 > --- a/notmuch-tag.c
\r
85 > +++ b/notmuch-tag.c
\r
86 > @@ -167,11 +167,48 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,
\r
87 > return interrupted;
\r
90 > +/* Parse +tag and -tag operations between argv[i] and argv[argc-1].
\r
91 > + * The array tag_ops must be at least argc - i elements long.
\r
92 > + * Returns the index into argv where parsing stopped, or -1 on error. */
\r
94 Perhaps mention tag_ops_count (as the number of tags parsed or
\r
98 > +parse_tag_operations (int i, int argc, char *argv[],
\r
99 > + tag_operation_t *tag_ops, int *tag_ops_count)
\r
101 > + *tag_ops_count = 0;
\r
103 > + for (; i < argc; i++) {
\r
104 > + if (strcmp (argv[i], "--") == 0) {
\r
108 > + if (argv[i][0] == '+' || argv[i][0] == '-') {
\r
109 > + if (argv[i][0] == '+' && argv[i][1] == '\0') {
\r
110 > + fprintf (stderr, "Error: tag names cannot be empty.\n");
\r
113 > + if (argv[i][0] == '+' && argv[i][1] == '-') {
\r
114 > + /* This disallows adding the non-removable tag "-" and
\r
115 > + * enables notmuch tag to take long options in the
\r
117 > + fprintf (stderr, "Error: tag names must not start with '-'.\n");
\r
120 > + tag_ops[*tag_ops_count].tag = argv[i] + 1;
\r
121 > + tag_ops[*tag_ops_count].remove = (argv[i][0] == '-');
\r
122 > + (*tag_ops_count)++;
\r
132 > notmuch_tag_command (void *ctx, int argc, char *argv[])
\r
134 > tag_operation_t *tag_ops;
\r
135 > - int tag_ops_count = 0;
\r
136 > + int tag_ops_count;
\r
137 > char *query_string;
\r
138 > notmuch_config_t *config;
\r
139 > notmuch_database_t *notmuch;
\r
140 > @@ -197,30 +234,9 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])
\r
144 > - for (i = 0; i < argc; i++) {
\r
145 > - if (strcmp (argv[i], "--") == 0) {
\r
149 > - if (argv[i][0] == '+' || argv[i][0] == '-') {
\r
150 > - if (argv[i][0] == '+' && argv[i][1] == '\0') {
\r
151 > - fprintf (stderr, "Error: tag names cannot be empty.\n");
\r
154 > - if (argv[i][0] == '+' && argv[i][1] == '-') {
\r
155 > - /* This disallows adding the non-removable tag "-" and
\r
156 > - * enables notmuch tag to take long options in the
\r
158 > - fprintf (stderr, "Error: tag names must not start with '-'.\n");
\r
161 > - tag_ops[tag_ops_count].tag = argv[i] + 1;
\r
162 > - tag_ops[tag_ops_count].remove = (argv[i][0] == '-');
\r
163 > - tag_ops_count++;
\r
168 > + i = parse_tag_operations (0, argc, argv, tag_ops, &tag_ops_count);
\r
172 > tag_ops[tag_ops_count].tag = NULL;
\r
177 > _______________________________________________
\r
178 > notmuch mailing list
\r
179 > notmuch@notmuchmail.org
\r
180 > http://notmuchmail.org/mailman/listinfo/notmuch
\r