[PATCH v2 04/14] cli/reply: unify reply format functions
[notmuch-archives.git] / c4 / ffc6ffb4a4c6a9c2b26fd8134b7c360adcb5a5
1 Return-Path: <jani@nikula.org>\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 90522431FBC\r
6         for <notmuch@notmuchmail.org>; Mon,  3 Dec 2012 14:30:38 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id N-LqrKjawMIW for <notmuch@notmuchmail.org>;\r
16         Mon,  3 Dec 2012 14:30:34 -0800 (PST)\r
17 Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com\r
18         [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id EFF8D431FAE\r
21         for <notmuch@notmuchmail.org>; Mon,  3 Dec 2012 14:30:33 -0800 (PST)\r
22 Received: by mail-lb0-f181.google.com with SMTP id ge1so2953535lbb.26\r
23         for <notmuch@notmuchmail.org>; Mon, 03 Dec 2012 14:30:32 -0800 (PST)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=google.com; s=20120113;\r
26         h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
27         :mime-version:content-type:content-transfer-encoding\r
28         :x-gm-message-state;\r
29         bh=rB/XGdWpozeprmXmqdSHIq2s+Vjg8p0qfI/w7FSSJjU=;\r
30         b=MXGoGuuukJV+4XJLXvSTGNR6DrJBGkSKao98A/SUmZehfgdgefOnQnvGb4Dhe3kTM5\r
31         WzvhP9s+jngptdBvgzXKQNd2QLZjOsPOtnRdloSVzUxTy2DFj7dkz67xTiaJO7kgEKSB\r
32         +sVDaOs6eYMUVMledtvxw7lTOHgjoWlxiz034kuIbODSJPTbwrK0N/NwCXXni+Ha3GkX\r
33         6ZHBuedaGOEuYwUMRO7io0007nO44WxkqOAxluEITHTyx+EB6HvuQPRtPM+hXP3KYN8I\r
34         MD2eJZuepr/8plhFpUMffIIkgMHEYx/aCxnuqp+4e2WfEKZLxJYJ3X1uKdeHzL/ugYqt\r
35         R2bA==\r
36 Received: by 10.112.23.2 with SMTP id i2mr5114898lbf.24.1354573832325;\r
37         Mon, 03 Dec 2012 14:30:32 -0800 (PST)\r
38 Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi.\r
39         [80.223.81.27])\r
40         by mx.google.com with ESMTPS id pw17sm5891143lab.5.2012.12.03.14.30.30\r
41         (version=SSLv3 cipher=OTHER); Mon, 03 Dec 2012 14:30:31 -0800 (PST)\r
42 From: Jani Nikula <jani@nikula.org>\r
43 To: Michal Nazarewicz <mina86@mina86.com>, notmuch@notmuchmail.org\r
44 Subject: Re: [PATCH 1/2] cli: fix notmuch top level argument parsing\r
45 In-Reply-To: <874nk2aigq.fsf@nikula.org>\r
46 References:\r
47  <c4f2a1048763950dd14e13c99a4e7eb333be8c9d.1354568072.git.jani@nikula.org>\r
48         <xa1tpq2qstx7.fsf@mina86.com> <874nk2aigq.fsf@nikula.org>\r
49 User-Agent: Notmuch/0.14+137~g9203c35 (http://notmuchmail.org) Emacs/23.4.1\r
50         (i686-pc-linux-gnu)\r
51 Date: Tue, 04 Dec 2012 00:30:29 +0200\r
52 Message-ID: <871uf6ahve.fsf@nikula.org>\r
53 MIME-Version: 1.0\r
54 Content-Type: text/plain; charset=utf-8\r
55 Content-Transfer-Encoding: quoted-printable\r
56 X-Gm-Message-State:\r
57  ALoCoQlcq0a9O9noX0rHilcPNqJQMHF+K4u0BuZdJGjFMAH0hwyEC8hzs6hCiAoB4Xfk1RmHb3jT\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Mon, 03 Dec 2012 22:30:38 -0000\r
71 \r
72 On Tue, 04 Dec 2012, Jani Nikula <jani@nikula.org> wrote:\r
73 > On Mon, 03 Dec 2012, Michal Nazarewicz <mina86@mina86.com> wrote:\r
74 >> On Mon, Dec 03 2012, Jani Nikula wrote:\r
75 >>> Use strcmp instead of STRNCMP_LITERAL, which matches the prefix\r
76 >>> instead of the whole argument.\r
77 >>\r
78 >> Perhaps add and use this instead:\r
79 >>\r
80 >> #define STRCMP_LITERAL(var, literal) \\r
81 >>     strncmp ((var), (literal), sizeof (literal))\r
82 >\r
83 > That's broken the same way STRNCMP_LITERAL is broken in this use case:\r
84 > it matches if literal is a prefix of var.\r
85 \r
86 Err, that's bollocks. Missed the missing -1 there. ;)\r
87 \r
88 >> Than again, it's argument parsing so hardly a performance critical path,\r
89 >> so maybe readability is more important.\r
90 \r
91 I'll go with this. And I'm not even sure strncmp is faster than strcmp,\r
92 as it has to keep track of count.\r
93 \r
94 \r
95 BR,\r
96 Jani.\r
97 \r
98 \r
99 \r
100 >>\r
101 >>> ---\r
102 >>>  notmuch.c |    4 ++--\r
103 >>>  1 file changed, 2 insertions(+), 2 deletions(-)\r
104 >>>\r
105 >>> diff --git a/notmuch.c b/notmuch.c\r
106 >>> index 477a09c..4ff66e3 100644\r
107 >>> --- a/notmuch.c\r
108 >>> +++ b/notmuch.c\r
109 >>> @@ -245,10 +245,10 @@ main (int argc, char *argv[])\r
110 >>>      if (argc =3D=3D 1)\r
111 >>>     return notmuch (local);\r
112 >>>=20=20\r
113 >>> -    if (STRNCMP_LITERAL (argv[1], "--help") =3D=3D 0)\r
114 >>> +    if (strcmp (argv[1], "--help") =3D=3D 0)\r
115 >>>     return notmuch_help_command (NULL, argc - 1, &argv[1]);\r
116 >>>=20=20\r
117 >>> -    if (STRNCMP_LITERAL (argv[1], "--version") =3D=3D 0) {\r
118 >>> +    if (strcmp (argv[1], "--version") =3D=3D 0) {\r
119 >>>     printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n");\r
120 >>>     return 0;\r
121 >>>      }\r
122 >>\r
123 >> --=20\r
124 >> Best regards,                                         _     _\r
125 >> .o. | Liege of Serenely Enlightened Majesty of      o' \,=3D./ `o\r
126 >> ..o | Computer Science,  Micha=C5=82 =E2=80=9Cmina86=E2=80=9D Nazarewicz=\r
127     (o o)\r
128 >> ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--\r