Re: [PATCH v2] Omit User-Agent: header by default
[notmuch-archives.git] / ed / 366126b9ffc511d0fffbe9869b562db69020f9
1 Return-Path: <markwalters1009@gmail.com>\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 9D11A431FBD\r
6         for <notmuch@notmuchmail.org>; Sun, 27 May 2012 01:22:33 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id SXX8T2u0axaf for <notmuch@notmuchmail.org>;\r
18         Sun, 27 May 2012 01:22:33 -0700 (PDT)\r
19 Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com\r
20         [209.85.212.179]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id 063E0431FBC\r
23         for <notmuch@notmuchmail.org>; Sun, 27 May 2012 01:22:32 -0700 (PDT)\r
24 Received: by mail-wi0-f179.google.com with SMTP id hr14so647090wib.2\r
25         for <notmuch@notmuchmail.org>; Sun, 27 May 2012 01:22:32 -0700 (PDT)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
28         bh=/kg2Vyq9tuKaceAyamAWHfWEPBsAK9+XZadak2q92+s=;\r
29         b=YaItgOfnfyfGzgPwjQKRl3kqGL6b7PluapsXAdNhg/LnLGOX2cNeYn3c6/YQyvTu4G\r
30         cjUbd/MaDGwyA/73Cjv1WGPXo526kPmIhl7VR13XtxsmkzRfWT7JKPQqjSi8wImA/9pR\r
31         LQFgUV5TqM+hJKHvNVJiMaqI6BFqBkornREUv2JZTWKYX8wh4N2iS6C1zCR135PyzuV0\r
32         mewCg5tZD9nrhs6Y3S1SXEurWOlZ7pZupcYgSJHs2K7KtdonhJfxSV4KX0WzTMya486g\r
33         ey8qa0w+FiCkesax1t1LnKfc8ptDQXlyiPOhwhv9G4t3Px07ln+hmk2TxlpvhB85MKHq\r
34         MahQ==\r
35 Received: by 10.180.99.195 with SMTP id es3mr7662973wib.12.1338106952698;\r
36         Sun, 27 May 2012 01:22:32 -0700 (PDT)\r
37 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
38  [94.192.233.223])      by mx.google.com with ESMTPS id\r
39  gv4sm18143624wib.8.2012.05.27.01.22.31 (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Sun, 27 May 2012 01:22:31 -0700 (PDT)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v6 1/6] cli: command line parsing: allow default for keyword\r
44         options\r
45 Date: Sun, 27 May 2012 09:22:21 +0100\r
46 Message-Id: <1338106946-7611-2-git-send-email-markwalters1009@gmail.com>\r
47 X-Mailer: git-send-email 1.7.9.1\r
48 In-Reply-To: <1338106946-7611-1-git-send-email-markwalters1009@gmail.com>\r
49 References: <1338106946-7611-1-git-send-email-markwalters1009@gmail.com>\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Sun, 27 May 2012 08:22:33 -0000\r
63 \r
64 This changes the parsing for "keyword" options so that if the option\r
65 is specified with no argument the argument is parsed as if it were\r
66 passed an empty string. This make it easier to add options to existing\r
67 boolean arguments (the existing --option can default to TRUE).\r
68 ---\r
69  command-line-arguments.c |   17 +++++++++++++----\r
70  1 files changed, 13 insertions(+), 4 deletions(-)\r
71 \r
72 diff --git a/command-line-arguments.c b/command-line-arguments.c\r
73 index 76b185f..2fb8a1b 100644\r
74 --- a/command-line-arguments.c\r
75 +++ b/command-line-arguments.c\r
76 @@ -11,10 +11,15 @@\r
77  */\r
78  \r
79  static notmuch_bool_t\r
80 -_process_keyword_arg (const notmuch_opt_desc_t *arg_desc, const char *arg_str) {\r
81 +_process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {\r
82  \r
83      const notmuch_keyword_t *keywords = arg_desc->keywords;\r
84  \r
85 +    if (next == 0) {\r
86 +       /* No keyword given */\r
87 +       arg_str="";\r
88 +    }\r
89 +\r
90      while (keywords->name) {\r
91         if (strcmp (arg_str, keywords->name) == 0) {\r
92             if (arg_desc->output_var) {\r
93 @@ -24,7 +29,10 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, const char *arg_str) {\r
94         }\r
95         keywords++;\r
96      }\r
97 -    fprintf (stderr, "unknown keyword: %s\n", arg_str);\r
98 +    if (next!=0)\r
99 +       fprintf (stderr, "unknown keyword: %s\n", arg_str);\r
100 +    else\r
101 +       fprintf (stderr, "option %s needs a keyword\n", arg_desc->name);\r
102      return FALSE;\r
103  }\r
104  \r
105 @@ -99,7 +107,8 @@ parse_option (const char *arg,\r
106              */\r
107             if (next != '=' && next != ':' && next != 0) return FALSE;\r
108             if (next == 0) {\r
109 -               if (try->opt_type != NOTMUCH_OPT_BOOLEAN)\r
110 +               if (try->opt_type != NOTMUCH_OPT_BOOLEAN &&\r
111 +                   try->opt_type != NOTMUCH_OPT_KEYWORD)\r
112                     return FALSE;\r
113             } else {\r
114                 if (value[0] == 0) return FALSE;\r
115 @@ -110,7 +119,7 @@ parse_option (const char *arg,\r
116  \r
117             switch (try->opt_type) {\r
118             case NOTMUCH_OPT_KEYWORD:\r
119 -               return _process_keyword_arg (try, value);\r
120 +               return _process_keyword_arg (try, next, value);\r
121                 break;\r
122             case NOTMUCH_OPT_BOOLEAN:\r
123                 return _process_boolean_arg (try, next, value);\r
124 -- \r
125 1.7.9.1\r
126 \r