Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / 28 / f3cb32feac74e759be8d2ca44911d61e732b92
1 Return-Path: <sojkam1@fel.cvut.cz>\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 7D4E2429E2E\r
6         for <notmuch@notmuchmail.org>; Mon,  3 Nov 2014 15:51:13 -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: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] 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 7UorYG236elN for <notmuch@notmuchmail.org>;\r
16         Mon,  3 Nov 2014 15:51:07 -0800 (PST)\r
17 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
18         by olra.theworths.org (Postfix) with ESMTP id 90424429E32\r
19         for <notmuch@notmuchmail.org>; Mon,  3 Nov 2014 15:50:51 -0800 (PST)\r
20 Received: from localhost (unknown [192.168.200.7])\r
21         by max.feld.cvut.cz (Postfix) with ESMTP id 124975CD008;\r
22         Tue,  4 Nov 2014 00:50:51 +0100 (CET)\r
23 X-Virus-Scanned: IMAP STYX AMAVIS\r
24 Received: from max.feld.cvut.cz ([192.168.200.1])\r
25         by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new,\r
26         port 10044)\r
27         with ESMTP id TXyKONql-BxH; Tue,  4 Nov 2014 00:50:46 +0100 (CET)\r
28 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
29         by max.feld.cvut.cz (Postfix) with ESMTP id E3BB05CD00C;\r
30         Tue,  4 Nov 2014 00:50:40 +0100 (CET)\r
31 Received: from wsh by steelpick.2x.cz with local (Exim 4.84)\r
32         (envelope-from <sojkam1@fel.cvut.cz>)\r
33         id 1XlROM-0005Wc-4p; Tue, 04 Nov 2014 00:50:34 +0100\r
34 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
35 To: notmuch@notmuchmail.org\r
36 Subject: [PATCH v2 05/10] cli: add support for hierarchical command line\r
37         option arrays\r
38 Date: Tue,  4 Nov 2014 00:50:17 +0100\r
39 Message-Id: <1415058622-21162-6-git-send-email-sojkam1@fel.cvut.cz>\r
40 X-Mailer: git-send-email 2.1.1\r
41 In-Reply-To: <1415058622-21162-1-git-send-email-sojkam1@fel.cvut.cz>\r
42 References: <1415058622-21162-1-git-send-email-sojkam1@fel.cvut.cz>\r
43 X-BeenThere: notmuch@notmuchmail.org\r
44 X-Mailman-Version: 2.1.13\r
45 Precedence: list\r
46 List-Id: "Use and development of the notmuch mail system."\r
47         <notmuch.notmuchmail.org>\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
51 List-Post: <mailto:notmuch@notmuchmail.org>\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
55 X-List-Received-Date: Mon, 03 Nov 2014 23:51:14 -0000\r
56 \r
57 From: Jani Nikula <jani@nikula.org>\r
58 \r
59 NOTMUCH_OPT_INHERIT expects a notmuch_opt_desc_t * pointer in\r
60 output_var.\r
61 \r
62 The "Unrecognized option" message was moved out of parse_option() to\r
63 not be emitted twice or when parsing a non-inherited option.\r
64 ---\r
65  command-line-arguments.c | 16 +++++++++-------\r
66  command-line-arguments.h |  1 +\r
67  2 files changed, 10 insertions(+), 7 deletions(-)\r
68 \r
69 diff --git a/command-line-arguments.c b/command-line-arguments.c\r
70 index c6f7269..de6b453 100644\r
71 --- a/command-line-arguments.c\r
72 +++ b/command-line-arguments.c\r
73 @@ -122,16 +122,18 @@ parse_position_arg (const char *arg_str, int pos_arg_index,\r
74   */\r
75  \r
76  notmuch_bool_t\r
77 -parse_option (const char *arg,\r
78 -             const notmuch_opt_desc_t *options) {\r
79 -\r
80 -    assert(arg);\r
81 +parse_option (const char *_arg, const notmuch_opt_desc_t *options)\r
82 +{\r
83 +    assert(_arg);\r
84      assert(options);\r
85  \r
86 -    arg += 2;\r
87 -\r
88 +    const char *arg = _arg + 2; /* _arg starts with -- */\r
89      const notmuch_opt_desc_t *try;\r
90      for (try = options; try->opt_type != NOTMUCH_OPT_END; try++) {\r
91 +       if (try->opt_type == NOTMUCH_OPT_INHERIT &&\r
92 +           parse_option (_arg, try->output_var))\r
93 +           return TRUE;\r
94 +\r
95         if (! try->name)\r
96             continue;\r
97  \r
98 @@ -170,7 +172,6 @@ parse_option (const char *arg,\r
99             /*UNREACHED*/\r
100         }\r
101      }\r
102 -    fprintf (stderr, "Unrecognized option: --%s\n", arg);\r
103      return FALSE;\r
104  }\r
105  \r
106 @@ -201,6 +202,7 @@ parse_arguments (int argc, char **argv,\r
107             if (more_args) {\r
108                 opt_index++;\r
109             } else {\r
110 +               fprintf (stderr, "Unrecognized option: %s\n", argv[opt_index]);\r
111                 opt_index = -1;\r
112             }\r
113  \r
114 diff --git a/command-line-arguments.h b/command-line-arguments.h\r
115 index 6444129..309aaf2 100644\r
116 --- a/command-line-arguments.h\r
117 +++ b/command-line-arguments.h\r
118 @@ -5,6 +5,7 @@\r
119  \r
120  enum notmuch_opt_type {\r
121      NOTMUCH_OPT_END = 0,\r
122 +    NOTMUCH_OPT_INHERIT,       /* another options table */\r
123      NOTMUCH_OPT_BOOLEAN,       /* --verbose              */\r
124      NOTMUCH_OPT_INT,           /* --frob=8               */\r
125      NOTMUCH_OPT_KEYWORD,       /* --format=raw|json|text */\r
126 -- \r
127 2.1.1\r
128 \r