Re: Hi all
[notmuch-archives.git] / a3 / b391007c6f6d51fbb0407f27b3e911025a4544
1 Return-Path: <tomi.ollila@iki.fi>\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 1940F429E49\r
6         for <notmuch@notmuchmail.org>; Tue, 25 Feb 2014 11:25:15 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         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 a3gJ5zM1S6h4 for <notmuch@notmuchmail.org>;\r
16         Tue, 25 Feb 2014 11:25:07 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id CACFA429E43\r
19         for <notmuch@notmuchmail.org>; Tue, 25 Feb 2014 11:25:06 -0800 (PST)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id 5F985100064;\r
22         Tue, 25 Feb 2014 21:24:59 +0200 (EET)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
25 Subject: Re: [PATCH] cli: command line option parser cleanup\r
26 In-Reply-To: <1393277818-8430-1-git-send-email-jani@nikula.org>\r
27 References: <1393277818-8430-1-git-send-email-jani@nikula.org>\r
28 User-Agent: Notmuch/0.17+108~gb327c11 (http://notmuchmail.org) Emacs/24.3.1\r
29         (x86_64-unknown-linux-gnu)\r
30 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
31         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
32         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
33 Date: Tue, 25 Feb 2014 21:24:58 +0200\r
34 Message-ID: <m2sir7hu5x.fsf@guru.guru-group.fi>\r
35 MIME-Version: 1.0\r
36 Content-Type: text/plain\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.13\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41         <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Tue, 25 Feb 2014 19:25:15 -0000\r
50 \r
51 On Mon, Feb 24 2014, Jani Nikula <jani@nikula.org> wrote:\r
52 \r
53 > Reduce the indentation for clarity. No functional changes.\r
54 >\r
55 > ---\r
56 \r
57 LGTM. I like the style.\r
58 \r
59 Tomi\r
60 \r
61 \r
62 >\r
63 > I've had this around for a while now, in preparation for something\r
64 > else that was never needed...\r
65 > ---\r
66 >  command-line-arguments.c | 69 ++++++++++++++++++++++++------------------------\r
67 >  1 file changed, 35 insertions(+), 34 deletions(-)\r
68 >\r
69 > diff --git a/command-line-arguments.c b/command-line-arguments.c\r
70 > index bf9aecabe869..844d6c3d18bf 100644\r
71 > --- a/command-line-arguments.c\r
72 > +++ b/command-line-arguments.c\r
73 > @@ -129,40 +129,41 @@ parse_option (const char *arg,\r
74 >  \r
75 >      const notmuch_opt_desc_t *try;\r
76 >      for (try = options; try->opt_type != NOTMUCH_OPT_END; try++) {\r
77 > -     if (try->name && strncmp (arg, try->name, strlen (try->name)) == 0) {\r
78 > -         char next = arg[strlen (try->name)];\r
79 > -         const char *value= arg+strlen(try->name)+1;\r
80 > -\r
81 > -         /* If we have not reached the end of the argument\r
82 > -            (i.e. the next character is not a space or delimiter)\r
83 > -            then the argument could still match a longer option\r
84 > -            name later in the option table.\r
85 > -         */\r
86 > -         if (next != '=' && next != ':' && next != '\0')\r
87 > -             continue;\r
88 > -\r
89 > -         if (try->output_var == NULL)\r
90 > -             INTERNAL_ERROR ("output pointer NULL for option %s", try->name);\r
91 > -\r
92 > -         switch (try->opt_type) {\r
93 > -         case NOTMUCH_OPT_KEYWORD:\r
94 > -             return _process_keyword_arg (try, next, value);\r
95 > -             break;\r
96 > -         case NOTMUCH_OPT_BOOLEAN:\r
97 > -             return _process_boolean_arg (try, next, value);\r
98 > -             break;\r
99 > -         case NOTMUCH_OPT_INT:\r
100 > -             return _process_int_arg (try, next, value);\r
101 > -             break;\r
102 > -         case NOTMUCH_OPT_STRING:\r
103 > -             return _process_string_arg (try, next, value);\r
104 > -             break;\r
105 > -         case NOTMUCH_OPT_POSITION:\r
106 > -         case NOTMUCH_OPT_END:\r
107 > -         default:\r
108 > -             INTERNAL_ERROR ("unknown or unhandled option type %d", try->opt_type);\r
109 > -             /*UNREACHED*/\r
110 > -         }\r
111 > +     if (! try->name)\r
112 > +         continue;\r
113 > +\r
114 > +     if (strncmp (arg, try->name, strlen (try->name)) != 0)\r
115 > +         continue;\r
116 > +\r
117 > +     char next = arg[strlen (try->name)];\r
118 > +     const char *value = arg + strlen(try->name) + 1;\r
119 > +\r
120 > +     /*\r
121 > +      * If we have not reached the end of the argument (i.e. the\r
122 > +      * next character is not a space or delimiter) then the\r
123 > +      * argument could still match a longer option name later in\r
124 > +      * the option table.\r
125 > +      */\r
126 > +     if (next != '=' && next != ':' && next != '\0')\r
127 > +         continue;\r
128 > +\r
129 > +     if (try->output_var == NULL)\r
130 > +         INTERNAL_ERROR ("output pointer NULL for option %s", try->name);\r
131 > +\r
132 > +     switch (try->opt_type) {\r
133 > +     case NOTMUCH_OPT_KEYWORD:\r
134 > +         return _process_keyword_arg (try, next, value);\r
135 > +     case NOTMUCH_OPT_BOOLEAN:\r
136 > +         return _process_boolean_arg (try, next, value);\r
137 > +     case NOTMUCH_OPT_INT:\r
138 > +         return _process_int_arg (try, next, value);\r
139 > +     case NOTMUCH_OPT_STRING:\r
140 > +         return _process_string_arg (try, next, value);\r
141 > +     case NOTMUCH_OPT_POSITION:\r
142 > +     case NOTMUCH_OPT_END:\r
143 > +     default:\r
144 > +         INTERNAL_ERROR ("unknown or unhandled option type %d", try->opt_type);\r
145 > +         /*UNREACHED*/\r
146 >       }\r
147 >      }\r
148 >      fprintf (stderr, "Unrecognized option: --%s\n", arg);\r
149 > -- \r
150 > 1.8.5.3\r
151 >\r
152 > _______________________________________________\r
153 > notmuch mailing list\r
154 > notmuch@notmuchmail.org\r
155 > http://notmuchmail.org/mailman/listinfo/notmuch\r