From: Jani Nikula Date: Mon, 21 Jan 2013 18:05:00 +0000 (+0100) Subject: Re: [PATCH v3 08/20] tag-util: move out 'tag' command-line checks X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=1e22855c8a734ecee18bf42030abba9b69768e5b;p=notmuch-archives.git Re: [PATCH v3 08/20] tag-util: move out 'tag' command-line checks --- diff --git a/2f/05f2358993d6987cad376b8f8d60c90bcb020c b/2f/05f2358993d6987cad376b8f8d60c90bcb020c new file mode 100644 index 000000000..c7599e1e4 --- /dev/null +++ b/2f/05f2358993d6987cad376b8f8d60c90bcb020c @@ -0,0 +1,139 @@ +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 B6EBD431FAF + for ; Mon, 21 Jan 2013 10:05:13 -0800 (PST) +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 RESPAjkmFLY2 for ; + Mon, 21 Jan 2013 10:05:13 -0800 (PST) +Received: from mail-bk0-f41.google.com (mail-bk0-f41.google.com + [209.85.214.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 00162431FAE + for ; Mon, 21 Jan 2013 10:05:12 -0800 (PST) +Received: by mail-bk0-f41.google.com with SMTP id jg9so3315307bkc.0 + for ; Mon, 21 Jan 2013 10:05:11 -0800 (PST) +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=jzonoBlp3g+vjyOZ8KS0Kae3836LIfhhJIAtrrPxomM=; + b=H8M5mcZqg/4wVcFRD+EX0hkn4ja7L+Ng9mmx4oO0ve92BE1V9v5drgSw4OXlgzU/WK + EuOfY/e9U8bqSabXro0b5PlliHqB8YvRKwvMFb/V8Kfr77D7MIidACSwcQ/nEWW129ea + Ja6Um8XJV/GPX3ZdcH6Gsx2mSrpJMCMJs+OIkbpOyo+JNDLReZZNwwO7sKYjcxlW4uiy + q3pPxTPur7dSjOw89R9GGhdNJmLph3NbU9rcbVeNQfMOaYSMxQXzztWpr95cwsPFty4a + X5t0zZCMqZDarR5Vy/ffgh1/6gj2fiwuXQBOoEE4aDyygUUBr9DNrystAo/fCbMrGwnM + AMzA== +X-Received: by 10.204.3.206 with SMTP id 14mr5093578bko.120.1358791510116; + Mon, 21 Jan 2013 10:05:10 -0800 (PST) +Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3]) + by mx.google.com with ESMTPS id q22sm9254720bkv.16.2013.01.21.10.05.07 + (version=TLSv1.1 cipher=RC4-SHA bits=128/128); + Mon, 21 Jan 2013 10:05:08 -0800 (PST) +From: Jani Nikula +To: Peter Wang , notmuch@notmuchmail.org +Subject: Re: [PATCH v3 08/20] tag-util: move out 'tag' command-line checks +In-Reply-To: <1358643004-14522-9-git-send-email-novalazy@gmail.com> +References: <1358643004-14522-1-git-send-email-novalazy@gmail.com> + <1358643004-14522-9-git-send-email-novalazy@gmail.com> +User-Agent: Notmuch/0.14+259~gdee88db (http://notmuchmail.org) Emacs/23.2.1 + (x86_64-pc-linux-gnu) +Date: Mon, 21 Jan 2013 19:05:00 +0100 +Message-ID: <87boci2z03.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Gm-Message-State: + ALoCoQnCtVWcgeCNxuHsycdsooJhSilZdoY8glHuz8nRH1R6sSBDxN1QDIbQQRWxffieHpgOj6D5 +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: Mon, 21 Jan 2013 18:05:13 -0000 + +On Sun, 20 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 notmuch +> 'insert' command if we move the checks out, into notmuch-tag.c. + +*three* error conditions, two of which are specific to notmuch tag. See + below. + +> --- +> notmuch-tag.c | 10 ++++++++++ +> tag-util.c | 10 ---------- +> 2 files changed, 10 insertions(+), 10 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 3f9da05..41f2c09 100644 +> --- a/tag-util.c +> +++ b/tag-util.c +> @@ -186,18 +186,8 @@ 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') { + +You must leave *query_str == NULL check intact here. Fix the error +message to be about allocation failure and drop the reference to notmuch +tag while at it. + +Otherwise LGTM. + +> - fprintf (stderr, "Error: notmuch tag requires at least one search term.\n"); +> - return TAG_PARSE_INVALID; +> - } +> - +> return TAG_PARSE_SUCCESS; +> } +> +> -- +> 1.7.12.1 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch