From: David Bremner Date: Sun, 8 May 2016 00:04:37 +0000 (+2100) Subject: v4 of libconfig / single argument date / named query patches X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=771829e3689535faf434001f7c2b2ed8115e844c;p=notmuch-archives.git v4 of libconfig / single argument date / named query patches --- diff --git a/45/b71031e28e7ea8706f6fd39509eb7d776a8845 b/45/b71031e28e7ea8706f6fd39509eb7d776a8845 new file mode 100644 index 000000000..ea386105b --- /dev/null +++ b/45/b71031e28e7ea8706f6fd39509eb7d776a8845 @@ -0,0 +1,305 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 756886DE0350 + for ; Sat, 7 May 2016 17:05:05 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.013 +X-Spam-Level: +X-Spam-Status: No, score=-0.013 tagged_above=-999 required=5 + tests=[AWL=-0.002, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id hr39QgHBqtdM for ; + Sat, 7 May 2016 17:04:57 -0700 (PDT) +Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) + by arlo.cworth.org (Postfix) with ESMTPS id CDC846DE00EB + for ; Sat, 7 May 2016 17:04:56 -0700 (PDT) +Received: from remotemail by fethera.tethera.net with local (Exim 4.84) + (envelope-from ) id 1azCDJ-00013V-FG + for notmuch@notmuchmail.org; Sat, 07 May 2016 20:04:49 -0400 +Received: (nullmailer pid 17178 invoked by uid 1000); + Sun, 08 May 2016 00:04:53 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: v4 of libconfig / single argument date / named query patches +Date: Sat, 7 May 2016 21:04:37 -0300 +Message-Id: <1462665889-17121-1-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.8.1 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +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, 08 May 2016 00:05:05 -0000 + +This obsoletes + + id:1462065879-29860-1-git-send-email-david@tethera.net + +This is rebased against master, and hopefully fixes most of Tomi's comments. + +Here is a diff against the last version + +diff --git a/configure b/configure +index 378c3dd..f94f7c7 100755 +--- a/configure ++++ b/configure +@@ -366,7 +366,7 @@ if [ ${have_xapian} = "1" ]; then + #include + class TestCompactor : public Xapian::Compactor { }; + EOF +- if ${CXX} ${CXXLAGS} ${xapian_cxxflags} -c _compact.cc -o _compact.o > /dev/null 2>&1 ++ if ${CXX} ${CXXFLAGS_for_sh} ${xapian_cxxflags} -c _compact.cc -o _compact.o > /dev/null 2>&1 + then + have_xapian_compact=1 + printf "Yes.\n" +@@ -379,7 +379,7 @@ EOF + #include + class TitleFieldProcessor : public Xapian::FieldProcessor { }; + EOF +- if ${CXX} ${CXXLAGS} ${xapian_cxxflags} -c _field_processor.cc -o _field_processor.o > /dev/null 2>&1 ++ if ${CXX} ${CXXFLAGS_for_sh} ${xapian_cxxflags} -c _field_processor.cc -o _field_processor.o > /dev/null 2>&1 + then + have_xapian_field_processor=1 + printf "Yes.\n" +diff --git a/lib/Makefile.local b/lib/Makefile.local +index 35caa3e..beb9635 100644 +--- a/lib/Makefile.local ++++ b/lib/Makefile.local +@@ -49,7 +49,7 @@ libnotmuch_cxx_srcs = \ + $(dir)/index.cc \ + $(dir)/message.cc \ + $(dir)/query.cc \ +- $(dir)/query-fp.cc \ ++ $(dir)/query-fp.cc \ + $(dir)/config.cc \ + $(dir)/thread.cc + +diff --git a/lib/config.cc b/lib/config.cc +index e581f32..35c917b 100644 +--- a/lib/config.cc ++++ b/lib/config.cc +@@ -1,6 +1,6 @@ +-/* metadata.cc - API for database metadata ++/* config.cc - API for database metadata + * +- * Copyright © 2015 David Bremner ++ * Copyright © 2016 David Bremner + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by +@@ -22,7 +22,7 @@ + #include "notmuch-private.h" + #include "database-private.h" + +-static const std::string CONFIG_PREFIX="C"; ++static const std::string CONFIG_PREFIX = "C"; + + struct _notmuch_config_list { + notmuch_database_t *notmuch; +@@ -32,7 +32,8 @@ struct _notmuch_config_list { + }; + + static int +-_notmuch_config_list_destroy (notmuch_config_list_t *list) { ++_notmuch_config_list_destroy (notmuch_config_list_t *list) ++{ + delete list->iterator; + return 0; + } +@@ -51,7 +52,7 @@ notmuch_database_set_config (notmuch_database_t *notmuch, + + try { + db = static_cast (notmuch->xapian_db); +- db->set_metadata (CONFIG_PREFIX+key, value); ++ db->set_metadata (CONFIG_PREFIX + key, value); + } catch (const Xapian::Error &error) { + status = NOTMUCH_STATUS_XAPIAN_EXCEPTION; + notmuch->exception_reported = TRUE; +@@ -71,7 +72,7 @@ _metadata_value (notmuch_database_t *notmuch, + notmuch_status_t status = NOTMUCH_STATUS_SUCCESS; + + try { +- value = notmuch->xapian_db->get_metadata (CONFIG_PREFIX+key); ++ value = notmuch->xapian_db->get_metadata (CONFIG_PREFIX + key); + } catch (const Xapian::Error &error) { + status = NOTMUCH_STATUS_XAPIAN_EXCEPTION; + notmuch->exception_reported = TRUE; +@@ -86,11 +87,12 @@ _metadata_value (notmuch_database_t *notmuch, + notmuch_status_t + notmuch_database_get_config (notmuch_database_t *notmuch, + const char *key, +- char **value) { ++ char **value) ++{ + std::string strval; + notmuch_status_t status; + +- if (!value) ++ if (! value) + return NOTMUCH_STATUS_NULL_POINTER; + + status = _metadata_value (notmuch, key, strval); +@@ -104,14 +106,14 @@ notmuch_database_get_config (notmuch_database_t *notmuch, + + notmuch_status_t + notmuch_database_get_config_list (notmuch_database_t *notmuch, +- const char *prefix, +- notmuch_config_list_t **out) ++ const char *prefix, ++ notmuch_config_list_t **out) + { + notmuch_config_list_t *list = NULL; + notmuch_status_t status = NOTMUCH_STATUS_SUCCESS; + + list = talloc (notmuch, notmuch_config_list_t); +- if (!list) { ++ if (! list) { + status = NOTMUCH_STATUS_OUT_OF_MEMORY; + goto DONE; + } +@@ -135,7 +137,7 @@ notmuch_database_get_config_list (notmuch_database_t *notmuch, + + *out = list; + +- DONE: ++ DONE: + if (status && list) + talloc_free (list); + +@@ -145,7 +147,7 @@ notmuch_database_get_config_list (notmuch_database_t *notmuch, + notmuch_bool_t + notmuch_config_list_valid (notmuch_config_list_t *metadata) + { +- if (*(metadata->iterator) == metadata->notmuch->xapian_db->metadata_keys_end()) ++ if (*(metadata->iterator) == metadata->notmuch->xapian_db->metadata_keys_end ()) + return FALSE; + + return TRUE; +@@ -159,7 +161,7 @@ notmuch_config_list_key (notmuch_config_list_t *list) + + list->current_key = talloc_strdup (list, (**(list->iterator)).c_str () + CONFIG_PREFIX.length ()); + +- return list->current_key; ++ return list->current_key; + } + + const char * +@@ -175,9 +177,9 @@ notmuch_config_list_value (notmuch_config_list_t *list) + return NULL; + + if (list->current_val) +- talloc_free(list->current_val); ++ talloc_free (list->current_val); + +- list->current_val = talloc_strdup(list, strval.c_str ()); ++ list->current_val = talloc_strdup (list, strval.c_str ()); + return list->current_val; + } + +diff --git a/lib/database-private.h b/lib/database-private.h +index 5ab4001..1a78b60 100644 +--- a/lib/database-private.h ++++ b/lib/database-private.h +@@ -144,9 +144,12 @@ operator&=(_notmuch_features &a, _notmuch_features b) + return a; + } + +-#define NOTMUCH_QUERY_PARSER_FLAGS (Xapian::QueryParser::FLAG_BOOLEAN | Xapian::QueryParser::FLAG_PHRASE | \ +- Xapian::QueryParser::FLAG_LOVEHATE | Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE | \ +- Xapian::QueryParser::FLAG_WILDCARD | Xapian::QueryParser::FLAG_PURE_NOT) ++#define NOTMUCH_QUERY_PARSER_FLAGS (Xapian::QueryParser::FLAG_BOOLEAN | \ ++ Xapian::QueryParser::FLAG_PHRASE | \ ++ Xapian::QueryParser::FLAG_LOVEHATE | \ ++ Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE | \ ++ Xapian::QueryParser::FLAG_WILDCARD | \ ++ Xapian::QueryParser::FLAG_PURE_NOT) + + struct _notmuch_database { + notmuch_bool_t exception_reported; +diff --git a/lib/query-fp.cc b/lib/query-fp.cc +index ee5a306..dab78d2 100644 +--- a/lib/query-fp.cc ++++ b/lib/query-fp.cc +@@ -26,14 +26,16 @@ + + #if HAVE_XAPIAN_FIELD_PROCESSOR + +-Xapian::Query QueryFieldProcessor::operator()(const std::string & name) { ++Xapian::Query ++QueryFieldProcessor::operator() (const std::string & name) ++{ + std::string key = "query." + name; + char *expansion; + notmuch_status_t status; + +- status = notmuch_database_get_config (notmuch, key.c_str(), &expansion); ++ status = notmuch_database_get_config (notmuch, key.c_str (), &expansion); + if (status) { +- throw Xapian::QueryParserError("error looking up key" + name); ++ throw Xapian::QueryParserError ("error looking up key" + name); + + } + +diff --git a/notmuch-config.c b/notmuch-config.c +index e4f47e4..f8636d5 100644 +--- a/notmuch-config.c ++++ b/notmuch-config.c +@@ -903,7 +903,7 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char + + static + void +-_notmuch_config_list_options () { ++_notmuch_config_list_built_with () { + printf("%scompact=%s\n", + BUILT_WITH_PREFIX, + notmuch_built_with ("compact") ? "true" : "false"); +@@ -972,7 +972,7 @@ notmuch_config_command_list (notmuch_config_t *config) + + g_strfreev (groups); + +- _notmuch_config_list_options (); ++ _notmuch_config_list_built_with (); + return _list_db_config (config); + } + +diff --git a/test/T240-dump-restore.sh b/test/T240-dump-restore.sh +index 758d355..bbfb09b 100755 +--- a/test/T240-dump-restore.sh ++++ b/test/T240-dump-restore.sh +@@ -97,7 +97,7 @@ test_expect_equal_file dump.expected dump.actual + # Note, we assume all messages from cworth have a message-id + # containing cworth.org + +-(head -1 dump.expected ; grep 'cworth[.]org' dump.expected) > dump-cworth.expected ++{ head -1 dump.expected ; grep 'cworth[.]org' dump.expected; } > dump-cworth.expected + + test_begin_subtest "dump -- from:cworth" + notmuch dump -- from:cworth > dump-dash-cworth.actual +diff --git a/test/test-lib.sh b/test/test-lib.sh +index e96c184..8fef275 100644 +--- a/test/test-lib.sh ++++ b/test/test-lib.sh +@@ -747,7 +747,7 @@ notmuch_built_with_sanitize () + + notmuch_config_sanitize () + { +- notmuch_dir_sanitize | notmuch_options_sanitize ++ notmuch_dir_sanitize | notmuch_built_with_sanitize + } + + # End of notmuch helper functions