From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 84911431FAE for ; Sat, 11 May 2013 12:51:05 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, 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 j0boS9StpVLU for ; Sat, 11 May 2013 12:51:01 -0700 (PDT) Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 7E687431FB6 for ; Sat, 11 May 2013 12:50:33 -0700 (PDT) Received: by mail-wi0-f174.google.com with SMTP id m6so1665855wiv.13 for ; Sat, 11 May 2013 12:50:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=WhkSakuUpmVWKTAeP5Lf7/ylkSaMYytH53P0lW8xkg4=; b=0xiJbZMk99ZgZCzbiq6DsuhFSpnjKdSUc2AqkOW3N4UehniU6M1bYeJd5Oe0YHnzVo yFLLGjomNZv638ZuGDZiXn5cN6CRn7Oott3ZBU7Lc/uhJdj9F4rtXEFR9PUBzrYdx8a/ o8FdO3LOurFZ5cPmiK9/+MSbLJpuOAVvoUoxNKyHPa55m7nXcBXCTMt4Ub6PaS5tdkv6 RVod5KPAPl//ZuDuAUhlL07nSCTbNpUAwlWp8gDuJYzooRx8oHit+a5/87SYRNOfefaA 2LR2U1p+G9RTNKues1QUbp/PQFZQQ97/lqROfUlsMf2RNXQngeFw2Dt5g2tsi0CDRC5C 5RWg== X-Received: by 10.194.133.232 with SMTP id pf8mr9741120wjb.40.1368301832459; Sat, 11 May 2013 12:50:32 -0700 (PDT) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPSA id bs20sm5729767wib.0.2013.05.11.12.50.31 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 11 May 2013 12:50:32 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH v2 8/8] cli: use notmuch_exclude_t in option parser Date: Sat, 11 May 2013 20:50:09 +0100 Message-Id: <1368301809-12532-9-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1368301809-12532-1-git-send-email-markwalters1009@gmail.com> References: <1368301809-12532-1-git-send-email-markwalters1009@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: Sat, 11 May 2013 19:51:05 -0000 From: Peter Wang Use notmuch_exclude_t constants directly instead of a redundant enumeration while parsing search --exclude keyword arguments. --- notmuch-search.c | 28 +++++++++------------------- 1 files changed, 9 insertions(+), 19 deletions(-) diff --git a/notmuch-search.c b/notmuch-search.c index a20791a..a96f07d 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -283,13 +283,6 @@ do_search_tags (notmuch_database_t *notmuch, return 0; } -enum { - EXCLUDE_TRUE, - EXCLUDE_FALSE, - EXCLUDE_FLAG, - EXCLUDE_ALL -}; - int notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) { @@ -302,7 +295,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) output_t output = OUTPUT_SUMMARY; int offset = 0; int limit = -1; /* unlimited */ - int exclude = EXCLUDE_TRUE; + notmuch_exclude_t exclude = NOTMUCH_EXCLUDE_TRUE; unsigned int i; enum { @@ -332,10 +325,10 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) { "tags", OUTPUT_TAGS }, { 0, 0 } } }, { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x', - (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE }, - { "false", EXCLUDE_FALSE }, - { "flag", EXCLUDE_FLAG }, - { "all", EXCLUDE_ALL }, + (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE }, + { "false", NOTMUCH_EXCLUDE_FALSE }, + { "flag", NOTMUCH_EXCLUDE_FLAG }, + { "all", NOTMUCH_EXCLUDE_ALL }, { 0, 0 } } }, { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 }, { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0 }, @@ -394,15 +387,15 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) notmuch_query_set_sort (query, sort); - if (exclude == EXCLUDE_FLAG && output != OUTPUT_SUMMARY) { + if (exclude == NOTMUCH_EXCLUDE_FLAG && output != OUTPUT_SUMMARY) { /* If we are not doing summary output there is nowhere to * print the excluded flag so fall back on including the * excluded messages. */ fprintf (stderr, "Warning: this output format cannot flag excluded messages.\n"); - exclude = EXCLUDE_FALSE; + exclude = NOTMUCH_EXCLUDE_FALSE; } - if (exclude != EXCLUDE_FALSE) { + if (exclude != NOTMUCH_EXCLUDE_FALSE) { const char **search_exclude_tags; size_t search_exclude_tags_length; @@ -410,10 +403,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) (config, &search_exclude_tags_length); for (i = 0; i < search_exclude_tags_length; i++) notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); - if (exclude == EXCLUDE_FLAG) - notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FLAG); - if (exclude == EXCLUDE_ALL) - notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL); + notmuch_query_set_omit_excluded (query, exclude); } switch (output) { -- 1.7.9.1