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 70D44431FD9
\r
6 for <notmuch@notmuchmail.org>; Mon, 24 Feb 2014 13:37:09 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 DVPXWLzJqU6K for <notmuch@notmuchmail.org>;
\r
16 Mon, 24 Feb 2014 13:37:04 -0800 (PST)
\r
17 Received: from mail-ea0-f182.google.com (mail-ea0-f182.google.com
\r
18 [209.85.215.182]) (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 BA332431FCF
\r
21 for <notmuch@notmuchmail.org>; Mon, 24 Feb 2014 13:37:03 -0800 (PST)
\r
22 Received: by mail-ea0-f182.google.com with SMTP id r15so3383638ead.41
\r
23 for <notmuch@notmuchmail.org>; Mon, 24 Feb 2014 13:37:01 -0800 (PST)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=1e100.net; s=20130820;
\r
26 h=x-gm-message-state:from:to:cc:subject:date:message-id;
\r
27 bh=wSbr8duGCT9hvlRony3ddtM4SvxrXYoLxxMQb2NDEGM=;
\r
28 b=GYo+SLt4N7R0d1SqSAd2OIMDo1Y6207azxmY3xfFVlFpBoB3DXh3frTaU6SXCqMWED
\r
29 fnTkDn/lUEAVqZGgFvgzDnYUB6BvDzK1r0eJG8oQK8G1gtVRKdGlJCKmf2u5TMXyNiOa
\r
30 U9+/3BeWDlvWklh8/7aIrjaBaztSf4cnNCbnigdZgi4WUEanDGGWagikhwoU7KQQOv7D
\r
31 QYGmz0r7cJUp6iZkcQqgOlBrvAS0ZLYoTtid/zIwtB+NVT72aE5Qh5cwEFn+EEV+4RUH
\r
32 FD1l68gh/Q3rXKIDznx3ezabAAkC2ZWQbvu5Zws/PwwnUVN1uv6q8TYvEbLFcjKWIE5Y
\r
35 ALoCoQk0tqOcpb3qeXLo+MfPO9M+3FYU+6/xhZ6PbE8T7yIqVx8B1fP8iycUeODBg56o95L+rYW8
\r
36 X-Received: by 10.14.1.68 with SMTP id 44mr27323853eec.0.1393277821014;
\r
37 Mon, 24 Feb 2014 13:37:01 -0800 (PST)
\r
38 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.
\r
40 by mx.google.com with ESMTPSA id n48sm47572595eew.0.2014.02.24.13.36.59
\r
41 for <multiple recipients>
\r
42 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
43 Mon, 24 Feb 2014 13:37:00 -0800 (PST)
\r
44 From: Jani Nikula <jani@nikula.org>
\r
45 To: notmuch@notmuchmail.org
\r
46 Subject: [PATCH] cli: command line option parser cleanup
\r
47 Date: Mon, 24 Feb 2014 23:36:58 +0200
\r
48 Message-Id: <1393277818-8430-1-git-send-email-jani@nikula.org>
\r
49 X-Mailer: git-send-email 1.8.5.3
\r
50 X-BeenThere: notmuch@notmuchmail.org
\r
51 X-Mailman-Version: 2.1.13
\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: Mon, 24 Feb 2014 21:37:09 -0000
\r
64 Reduce the indentation for clarity. No functional changes.
\r
68 I've had this around for a while now, in preparation for something
\r
69 else that was never needed...
\r
71 command-line-arguments.c | 69 ++++++++++++++++++++++++------------------------
\r
72 1 file changed, 35 insertions(+), 34 deletions(-)
\r
74 diff --git a/command-line-arguments.c b/command-line-arguments.c
\r
75 index bf9aecabe869..844d6c3d18bf 100644
\r
76 --- a/command-line-arguments.c
\r
77 +++ b/command-line-arguments.c
\r
78 @@ -129,40 +129,41 @@ parse_option (const char *arg,
\r
80 const notmuch_opt_desc_t *try;
\r
81 for (try = options; try->opt_type != NOTMUCH_OPT_END; try++) {
\r
82 - if (try->name && strncmp (arg, try->name, strlen (try->name)) == 0) {
\r
83 - char next = arg[strlen (try->name)];
\r
84 - const char *value= arg+strlen(try->name)+1;
\r
86 - /* If we have not reached the end of the argument
\r
87 - (i.e. the next character is not a space or delimiter)
\r
88 - then the argument could still match a longer option
\r
89 - name later in the option table.
\r
91 - if (next != '=' && next != ':' && next != '\0')
\r
94 - if (try->output_var == NULL)
\r
95 - INTERNAL_ERROR ("output pointer NULL for option %s", try->name);
\r
97 - switch (try->opt_type) {
\r
98 - case NOTMUCH_OPT_KEYWORD:
\r
99 - return _process_keyword_arg (try, next, value);
\r
101 - case NOTMUCH_OPT_BOOLEAN:
\r
102 - return _process_boolean_arg (try, next, value);
\r
104 - case NOTMUCH_OPT_INT:
\r
105 - return _process_int_arg (try, next, value);
\r
107 - case NOTMUCH_OPT_STRING:
\r
108 - return _process_string_arg (try, next, value);
\r
110 - case NOTMUCH_OPT_POSITION:
\r
111 - case NOTMUCH_OPT_END:
\r
113 - INTERNAL_ERROR ("unknown or unhandled option type %d", try->opt_type);
\r
119 + if (strncmp (arg, try->name, strlen (try->name)) != 0)
\r
122 + char next = arg[strlen (try->name)];
\r
123 + const char *value = arg + strlen(try->name) + 1;
\r
126 + * If we have not reached the end of the argument (i.e. the
\r
127 + * next character is not a space or delimiter) then the
\r
128 + * argument could still match a longer option name later in
\r
129 + * the option table.
\r
131 + if (next != '=' && next != ':' && next != '\0')
\r
134 + if (try->output_var == NULL)
\r
135 + INTERNAL_ERROR ("output pointer NULL for option %s", try->name);
\r
137 + switch (try->opt_type) {
\r
138 + case NOTMUCH_OPT_KEYWORD:
\r
139 + return _process_keyword_arg (try, next, value);
\r
140 + case NOTMUCH_OPT_BOOLEAN:
\r
141 + return _process_boolean_arg (try, next, value);
\r
142 + case NOTMUCH_OPT_INT:
\r
143 + return _process_int_arg (try, next, value);
\r
144 + case NOTMUCH_OPT_STRING:
\r
145 + return _process_string_arg (try, next, value);
\r
146 + case NOTMUCH_OPT_POSITION:
\r
147 + case NOTMUCH_OPT_END:
\r
149 + INTERNAL_ERROR ("unknown or unhandled option type %d", try->opt_type);
\r
153 fprintf (stderr, "Unrecognized option: --%s\n", arg);
\r