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 <xapian.h> 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 <xapian.h> 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 <Xapian::WritableDatabase *> (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