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 5D5C7431FD8 for ; Wed, 20 Jun 2012 06:30:23 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 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_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 cfpwXvqcYlTs for ; Wed, 20 Jun 2012 06:30:22 -0700 (PDT) Received: from mail-pb0-f53.google.com (mail-pb0-f53.google.com [209.85.160.53]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D94A2429E35 for ; Wed, 20 Jun 2012 06:30:16 -0700 (PDT) Received: by mail-pb0-f53.google.com with SMTP id rr13so756934pbb.26 for ; Wed, 20 Jun 2012 06:30:16 -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=O2TKTmOLZd/DvpzmkmmNaNX8+pmc5tnjB0DJ20sFRiU=; b=DXTt1kZF6IVrZYY99KNeBRFh0CJpmv5YhHPq1bfT51pwRdyVO/iyF+WTAzeABztrox EV9X7yyS3/9xz/2QlpLvXKXfueHJF4b95LP5nbZTIxUtgUiCN9+N97htrN7qQjInZbfa NlAJUbhDMUDg789/7nIga3P4EeDz9qQYr7lKLGQTP7pCgTgxI+Wtl8lf+ZbH4VQtb+Oq T/pG0LJYUc716hfN7nJFdDQrKNqrAKeTKnth1xZ4GF5TjcYaqGALU17Uh/bi0RmGNt5j bChWAdogv2aNIypSmRDpb8c4h+TfoYmv2UZmRm/AJe8u13hHWM6sJoynhi7jXyfthNrR 3w/Q== Received: by 10.68.224.70 with SMTP id ra6mr76383480pbc.11.1340199016721; Wed, 20 Jun 2012 06:30:16 -0700 (PDT) Received: from localhost (215.42.233.220.static.exetel.com.au. [220.233.42.215]) by mx.google.com with ESMTPS id tj4sm31943519pbc.33.2012.06.20.06.30.14 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Jun 2012 06:30:15 -0700 (PDT) From: Peter Wang To: notmuch@notmuchmail.org Subject: [PATCH 8/8] cli: use notmuch_exclude_t in option parser Date: Wed, 20 Jun 2012 23:29:07 +1000 Message-Id: <1340198947-29370-9-git-send-email-novalazy@gmail.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1340198947-29370-1-git-send-email-novalazy@gmail.com> References: <1340198947-29370-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: Wed, 20 Jun 2012 13:30:23 -0000 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 027923d..23cf342 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -416,13 +416,6 @@ do_search_tags (notmuch_database_t *notmuch, return 0; } -enum { - EXCLUDE_TRUE, - EXCLUDE_FALSE, - EXCLUDE_FLAG, - EXCLUDE_ALL -}; - int notmuch_search_command (void *ctx, int argc, char *argv[]) { @@ -436,7 +429,7 @@ notmuch_search_command (void *ctx, 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 { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT } @@ -459,10 +452,10 @@ notmuch_search_command (void *ctx, 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 }, @@ -510,15 +503,15 @@ notmuch_search_command (void *ctx, 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; @@ -526,10 +519,7 @@ notmuch_search_command (void *ctx, 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.4.4