[PATCH v5 01/12] tag-util: move out 'tag' command-line checks
[notmuch-archives.git] / 82 / e2122f49b55f1e829fb81b44bbc25536b08c19
1 Return-Path: <novalazy@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 03FE5431FBD\r
6         for <notmuch@notmuchmail.org>; Tue,  2 Apr 2013 15:42:16 -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.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id QZArOm1NNRng for <notmuch@notmuchmail.org>;\r
17         Tue,  2 Apr 2013 15:42:15 -0700 (PDT)\r
18 Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com\r
19         [209.85.220.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 9D085431FC2\r
22         for <notmuch@notmuchmail.org>; Tue,  2 Apr 2013 15:42:13 -0700 (PDT)\r
23 Received: by mail-pa0-f46.google.com with SMTP id lb1so530179pab.5\r
24         for <notmuch@notmuchmail.org>; Tue, 02 Apr 2013 15:42:12 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26         h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
27         :references; bh=ooGzRAw3WlQ1H9Bfy5Sd5QgRpxwLuzpkeSE1GT2LMuU=;\r
28         b=ryRsqe30gDLwvKlIOVaJHdVmVCZVebxczsAYm5b8w2FLf1c97jxt27RVlnZsiQ/yhN\r
29         +wl2P3N0uu0pSn8d+WKuuV7Tle4h5UzY6Tr6XVn11W+2eYd7SARwx25rxAw/x/ICnumF\r
30         gOBCh7W9v6TrfnjgbjptHQYD6eaa11mex3ArY68Lfl7w4py3nLJBWzwhGDF96ofFoNcH\r
31         MXhJ8coFTxEG0hQDAUmVq0kUGYNTHfzJ9nDe/qWEwQPMVe5PT0ODNRq70ZTW3Re3iMuE\r
32         gMVq+gD47QvhNoZDBCeKZlXaguFPnMZ3XR9lmVXlE1if3LTtideg+hUxjN1cR4b60QtT\r
33         fgww==\r
34 X-Received: by 10.68.241.102 with SMTP id wh6mr27372608pbc.150.1364942532792; \r
35         Tue, 02 Apr 2013 15:42:12 -0700 (PDT)\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.\r
37         [220.233.42.215])\r
38         by mx.google.com with ESMTPS id tm1sm3281326pbc.11.2013.04.02.15.42.10\r
39         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
40         Tue, 02 Apr 2013 15:42:12 -0700 (PDT)\r
41 From: Peter Wang <novalazy@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v5 01/12] tag-util: move out 'tag' command-line checks\r
44 Date: Wed,  3 Apr 2013 09:41:46 +1100\r
45 Message-Id: <1364942517-6982-2-git-send-email-novalazy@gmail.com>\r
46 X-Mailer: git-send-email 1.7.12.1\r
47 In-Reply-To: <1364942517-6982-1-git-send-email-novalazy@gmail.com>\r
48 References: <1364942517-6982-1-git-send-email-novalazy@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Tue, 02 Apr 2013 22:42:16 -0000\r
62 \r
63 parse_tag_command_line checked for two error conditions which are\r
64 specific to the 'tag' command.  It can be reused for the forthcoming\r
65 notmuch 'insert' command if we move the checks out, into notmuch-tag.c.\r
66 ---\r
67  notmuch-tag.c | 5 +++++\r
68  tag-util.c    | 6 +++---\r
69  2 files changed, 8 insertions(+), 3 deletions(-)\r
70 \r
71 diff --git a/notmuch-tag.c b/notmuch-tag.c\r
72 index 9a5d3e7..3b09df9 100644\r
73 --- a/notmuch-tag.c\r
74 +++ b/notmuch-tag.c\r
75 @@ -247,6 +247,11 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[])\r
76             fprintf (stderr, "Error: 'notmuch tag' requires at least one tag to add or remove.\n");\r
77             return 1;\r
78         }\r
79 +\r
80 +       if (*query_string == '\0') {\r
81 +           fprintf (stderr, "Error: notmuch tag requires at least one search term.\n");\r
82 +           return 1;\r
83 +       }\r
84      }\r
85  \r
86      if (notmuch_database_open (notmuch_config_get_database_path (config),\r
87 diff --git a/tag-util.c b/tag-util.c\r
88 index c5f5859..92e08a1 100644\r
89 --- a/tag-util.c\r
90 +++ b/tag-util.c\r
91 @@ -190,9 +190,9 @@ parse_tag_command_line (void *ctx, int argc, char **argv,\r
92  \r
93      *query_str = query_string_from_args (ctx, argc - i, &argv[i]);\r
94  \r
95 -    if (*query_str == NULL || **query_str == '\0') {\r
96 -       fprintf (stderr, "Error: notmuch tag requires at least one search term.\n");\r
97 -       return TAG_PARSE_INVALID;\r
98 +    if (*query_str == NULL) {\r
99 +       fprintf (stderr, "Out of memory.\n");\r
100 +       return TAG_PARSE_OUT_OF_MEMORY;\r
101      }\r
102  \r
103      return TAG_PARSE_SUCCESS;\r
104 -- \r
105 1.7.12.1\r
106 \r