From 25c4da8b97e4687e7b76218ec30db416193607c9 Mon Sep 17 00:00:00 2001 From: Peter Wang Date: Sun, 23 Jun 2013 14:23:54 +1000 Subject: [PATCH] [PATCH v7 01/12] tag-util: move out 'tag' command-line check --- dc/21f5bbb5195c4c57886255ffad120e85fcba37 | 106 ++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 dc/21f5bbb5195c4c57886255ffad120e85fcba37 diff --git a/dc/21f5bbb5195c4c57886255ffad120e85fcba37 b/dc/21f5bbb5195c4c57886255ffad120e85fcba37 new file mode 100644 index 000000000..735dad9f5 --- /dev/null +++ b/dc/21f5bbb5195c4c57886255ffad120e85fcba37 @@ -0,0 +1,106 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 7309D431FAE + for ; Sat, 22 Jun 2013 21:24:08 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.099 +X-Spam-Level: +X-Spam-Status: No, score=-0.099 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id rtW5lIGrtrea for ; + Sat, 22 Jun 2013 21:24:00 -0700 (PDT) +Received: from mail-pd0-f171.google.com (mail-pd0-f171.google.com + [209.85.192.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id BAA1A431FB6 + for ; Sat, 22 Jun 2013 21:24:00 -0700 (PDT) +Received: by mail-pd0-f171.google.com with SMTP id y14so195434pdi.16 + for ; Sat, 22 Jun 2013 21:24:00 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=66Vd2nPB29AX4mZnRZ1lIeg1mcEHnjPgcEBgNCewqx0=; + b=BKInLUn/2ZH6x0flHvrF8XTXzIPO+jntxNyuON7DqIHErtUogwkC6XoEXmS8YdRTor + J3wmXASDZ+G/SG0XM+WpLJxaHgdLBerqiRnjmnwrJf9UOQc0uyLGx/5nHcg2IfomNbFW + 7yTP5Ck+TjspKNmlV/2yyzP48pCD0PykhoYjn7ToP3lVziDNxgoHuY7h3dLiEmLmGUXO + vsKeS5YadtIhapfp9th5BjU699kvMrCMF8ETVxkcHa086MhhCwzsOwmaKFKgDP2/4GOU + s3xhIRRJn/WWujaz/bMovViqGtV8iC25aWRgFBOvzgwcHPlejhL0I4Y0S4b+3YvXUvKY + OG3w== +X-Received: by 10.66.150.168 with SMTP id uj8mr22586746pab.34.1371961440010; + Sat, 22 Jun 2013 21:24:00 -0700 (PDT) +Received: from localhost (215.42.233.220.static.exetel.com.au. + [220.233.42.215]) by mx.google.com with ESMTPSA id + z19sm13166783paf.12.2013.06.22.21.23.57 for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sat, 22 Jun 2013 21:23:59 -0700 (PDT) +From: Peter Wang +To: notmuch@notmuchmail.org +Subject: [PATCH v7 01/12] tag-util: move out 'tag' command-line check +Date: Sun, 23 Jun 2013 14:23:54 +1000 +Message-Id: <1371961445-15182-2-git-send-email-novalazy@gmail.com> +X-Mailer: git-send-email 1.7.12.1 +In-Reply-To: <1371961445-15182-1-git-send-email-novalazy@gmail.com> +References: <1371961445-15182-1-git-send-email-novalazy@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 23 Jun 2013 04:24:08 -0000 + +Move an error condition specific to the 'tag' command out of +parse_tag_command_line so that parse_tag_command_line can be used for +the forthcoming 'insert' command. +--- + notmuch-tag.c | 5 +++++ + tag-util.c | 6 +++--- + 2 files changed, 8 insertions(+), 3 deletions(-) + +diff --git a/notmuch-tag.c b/notmuch-tag.c +index 9a5d3e7..3b09df9 100644 +--- a/notmuch-tag.c ++++ b/notmuch-tag.c +@@ -247,6 +247,11 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[]) + fprintf (stderr, "Error: 'notmuch tag' requires at least one tag to add or remove.\n"); + return 1; + } ++ ++ if (*query_string == '\0') { ++ fprintf (stderr, "Error: notmuch tag requires at least one search term.\n"); ++ return 1; ++ } + } + + if (notmuch_database_open (notmuch_config_get_database_path (config), +diff --git a/tag-util.c b/tag-util.c +index c5f5859..92e08a1 100644 +--- a/tag-util.c ++++ b/tag-util.c +@@ -190,9 +190,9 @@ parse_tag_command_line (void *ctx, int argc, char **argv, + + *query_str = query_string_from_args (ctx, argc - i, &argv[i]); + +- if (*query_str == NULL || **query_str == '\0') { +- fprintf (stderr, "Error: notmuch tag requires at least one search term.\n"); +- return TAG_PARSE_INVALID; ++ if (*query_str == NULL) { ++ fprintf (stderr, "Out of memory.\n"); ++ return TAG_PARSE_OUT_OF_MEMORY; + } + + return TAG_PARSE_SUCCESS; +-- +1.7.12.1 + -- 2.26.2