From: Jani Nikula Date: Sun, 31 Mar 2013 10:00:26 +0000 (+0300) Subject: Re: [PATCH v4 01/12] tag-util: move out 'tag' command-line checks X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=990764869ec8ce35b9c308218f5718db6a94d036;p=notmuch-archives.git Re: [PATCH v4 01/12] tag-util: move out 'tag' command-line checks --- diff --git a/13/1c6493cf34547abfa11ba3a9e965c9456bf613 b/13/1c6493cf34547abfa11ba3a9e965c9456bf613 new file mode 100644 index 000000000..48a2f91c1 --- /dev/null +++ b/13/1c6493cf34547abfa11ba3a9e965c9456bf613 @@ -0,0 +1,135 @@ +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 2525D431FDA + for ; Sun, 31 Mar 2013 03:00:31 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 P7b2-G1xGKvb for ; + Sun, 31 Mar 2013 03:00:30 -0700 (PDT) +Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com + [209.85.217.180]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id DBEC8431FAE + for ; Sun, 31 Mar 2013 03:00:29 -0700 (PDT) +Received: by mail-lb0-f180.google.com with SMTP id t11so1242833lbi.39 + for ; Sun, 31 Mar 2013 03:00:28 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=x-received:from:to:subject:in-reply-to:references:user-agent:date + :message-id:mime-version:content-type:x-gm-message-state; + bh=kWff2rOMrHiSRXbjMZpTdudpKn9kQWlVUXLyWTfiYq8=; + b=g6a+eHcwP4pe+AavxE/AwU3A7308SKbKllKjpnd70Vzk+DK59RZQfzG7ZVuflK2NRp + sFtk1mJ1YFCBCZFhX2HJXvMfCEdTxZfVPp/XOYZiE0M76P1g2mZ/BLhHkqXNwr3YMUHY + J2Lro5x8c6slHiBvpusJxm9NXOmJMYytTziYTi7rnD0JzaR3UpoJJHFAy49QDbVPlz0l + hcEB9rNQ4Y6NopElvC4k9bbgyMk2Z8TxT0XnAPqVErHv2qtdf5Rk2MJRawRwwRTgstM4 + W1YEmGxV6/pFsmj3RyK4VTZjl2pMScRf+vu0qfBrXFPpelJkWkyX6YRRWV68F7s7MZgx + qZdg== +X-Received: by 10.112.134.134 with SMTP id pk6mr357831lbb.78.1364724028483; + Sun, 31 Mar 2013 03:00:28 -0700 (PDT) +Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi. + [80.223.81.27]) + by mx.google.com with ESMTPS id fq10sm3727763lbb.14.2013.03.31.03.00.26 + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sun, 31 Mar 2013 03:00:27 -0700 (PDT) +From: Jani Nikula +To: Peter Wang , notmuch@notmuchmail.org +Subject: Re: [PATCH v4 01/12] tag-util: move out 'tag' command-line checks +In-Reply-To: <1359029288-12132-2-git-send-email-novalazy@gmail.com> +References: <1359029288-12132-1-git-send-email-novalazy@gmail.com> + <1359029288-12132-2-git-send-email-novalazy@gmail.com> +User-Agent: Notmuch/0.15.2+48~gc5630bf (http://notmuchmail.org) Emacs/24.2.1 + (x86_64-pc-linux-gnu) +Date: Sun, 31 Mar 2013 13:00:26 +0300 +Message-ID: <87ip47sxc5.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain +X-Gm-Message-State: + ALoCoQmzGJlWHRynBWPf79RkooRm4t//6i/le/qR0xyZKfFUbIdlQuD6pzvZrRvccO3AZ/Xvpybg +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, 31 Mar 2013 10:00:31 -0000 + +On Thu, 24 Jan 2013, Peter Wang wrote: +> parse_tag_command_line checked for two error conditions which are +> specific to the 'tag' command. It can be reused for the forthcoming +> notmuch 'insert' command if we move the checks out, into notmuch-tag.c. + +FYI, this patch no longer applies to master. + +Jani. + +> --- +> notmuch-tag.c | 10 ++++++++++ +> tag-util.c | 11 +++-------- +> 2 files changed, 13 insertions(+), 8 deletions(-) +> +> diff --git a/notmuch-tag.c b/notmuch-tag.c +> index d9daf8f..a901dad 100644 +> --- a/notmuch-tag.c +> +++ b/notmuch-tag.c +> @@ -234,6 +234,16 @@ notmuch_tag_command (void *ctx, int argc, char *argv[]) +> if (parse_tag_command_line (ctx, argc - opt_index, argv + opt_index, +> &query_string, tag_ops)) +> return 1; +> + +> + if (tag_op_list_size (tag_ops) == 0) { +> + 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; +> + } +> } +> +> config = notmuch_config_open (ctx, NULL, NULL); +> diff --git a/tag-util.c b/tag-util.c +> index 701d329..743d591 100644 +> --- a/tag-util.c +> +++ b/tag-util.c +> @@ -188,16 +188,11 @@ parse_tag_command_line (void *ctx, int argc, char **argv, +> tag_op_list_append (tag_ops, argv[i] + 1, is_remove); +> } +> +> - if (tag_op_list_size (tag_ops) == 0) { +> - fprintf (stderr, "Error: 'notmuch tag' requires at least one tag to add or remove.\n"); +> - return TAG_PARSE_INVALID; +> - } +> - +> *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 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch