have_pkg_config=0
fi
-printf "Checking for Xapian development files... "
+
+
+printf "Checking for Xapian development files (>= 1.4.0)... "
have_xapian=0
-for xapian_config in ${XAPIAN_CONFIG} xapian-config xapian-config-1.3; do
+for xapian_config in ${XAPIAN_CONFIG} xapian-config; do
if ${xapian_config} --version > /dev/null 2>&1; then
xapian_version=$(${xapian_config} --version | sed -e 's/.* //')
- printf "Yes (%s).\n" ${xapian_version}
- have_xapian=1
- xapian_cxxflags=$(${xapian_config} --cxxflags)
- xapian_ldflags=$(${xapian_config} --libs)
+ case $xapian_version in
+ 1.[4-9]* | 1.[1-9][0-9]* | [2-9]* | [1-9][0-9]*)
+ printf "Yes (%s).\n" ${xapian_version}
+ have_xapian=1
+ xapian_cxxflags=$(${xapian_config} --cxxflags)
+ xapian_ldflags=$(${xapian_config} --libs)
+ ;;
+ *) printf "Xapian $xapian_version not supported... "
+ esac
break
fi
done
errors=$((errors + 1))
fi
-have_xapian_compact=0
-have_xapian_field_processor=0
if [ ${have_xapian} = "1" ]; then
- printf "Checking for Xapian compaction support... "
- cat>_compact.cc<<EOF
-#include <xapian.h>
-class TestCompactor : public Xapian::Compactor { };
-EOF
- 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"
- else
- printf "No.\n"
- errors=$((errors + 1))
- fi
-
- rm -f _compact.o _compact.cc
-
- printf "Checking for Xapian FieldProcessor API... "
- cat>_field_processor.cc<<EOF
-#include <xapian.h>
-class TitleFieldProcessor : public Xapian::FieldProcessor { };
-EOF
- 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"
- else
- printf "No. (optional)\n"
- fi
-
- rm -f _field_processor.o _field_processor.cc
-
default_xapian_backend=""
- # DB_RETRY_LOCK is only supported on Xapian > 1.3.2
- have_xapian_db_retry_lock=0
- if [ $WITH_RETRY_LOCK = "1" ]; then
- printf "Checking for Xapian lock retry support... "
- cat>_retry.cc<<EOF
-#include <xapian.h>
-int flag = Xapian::DB_RETRY_LOCK;
-EOF
- if ${CXX} ${CXXFLAGS_for_sh} ${xapian_cxxflags} -c _retry.cc -o _retry.o > /dev/null 2>&1
- then
- have_xapian_db_retry_lock=1
- printf "Yes.\n"
- else
- printf "No. (optional)\n"
- fi
- rm -f _retry.o _retry.cc
- fi
-
printf "Testing default Xapian backend... "
cat >_default_backend.cc <<EOF
#include <xapian.h>
if [ $have_python -eq 0 ]; then
echo " python interpreter"
fi
- if [ $have_xapian -eq 0 -o $have_xapian_compact -eq 0 ]; then
- echo " Xapian library (>= version 1.2.6, including development files such as headers)"
+ if [ $have_xapian -eq 0 ]; then
+ echo " Xapian library (>= version 1.4.0, including development files such as headers)"
echo " https://xapian.org/"
fi
if [ $have_zlib -eq 0 ]; then
# Whether struct dirent has d_type (if not, then notmuch will use stat)
HAVE_D_TYPE = ${have_d_type}
-# Whether the Xapian version in use supports compaction
-HAVE_XAPIAN_COMPACT = ${have_xapian_compact}
-
-# Whether the Xapian version in use supports field processors
-HAVE_XAPIAN_FIELD_PROCESSOR = ${have_xapian_field_processor}
-
-# Whether the Xapian version in use supports DB_RETRY_LOCK
-HAVE_XAPIAN_DB_RETRY_LOCK = ${have_xapian_db_retry_lock}
+# Whether to have Xapian retry lock
+HAVE_XAPIAN_DB_RETRY_LOCK = ${WITH_RETRY_LOCK}
# Whether the getpwuid_r function is standards-compliant
# (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS
XAPIAN_CXXFLAGS = ${xapian_cxxflags}
XAPIAN_LDFLAGS = ${xapian_ldflags}
-# Which backend will Xapian use by default?
-DEFAULT_XAPIAN_BACKEND = ${default_xapian_backend}
-
# Flags needed to compile and link against GMime
GMIME_CFLAGS = ${gmime_cflags}
GMIME_LDFLAGS = ${gmime_ldflags}
-DHAVE_D_TYPE=\$(HAVE_D_TYPE) \\
-DSTD_GETPWUID=\$(STD_GETPWUID) \\
-DSTD_ASCTIME=\$(STD_ASCTIME) \\
- -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT) \\
-DSILENCE_XAPIAN_DEPRECATION_WARNINGS \\
- -DHAVE_XAPIAN_FIELD_PROCESSOR=\$(HAVE_XAPIAN_FIELD_PROCESSOR) \\
-DHAVE_XAPIAN_DB_RETRY_LOCK=\$(HAVE_XAPIAN_DB_RETRY_LOCK)
CONFIGURE_CFLAGS = \$(COMMON_CONFIGURE_CFLAGS)
CONFIGURE_CXXFLAGS = \$(COMMON_CONFIGURE_CFLAGS) \$(XAPIAN_CXXFLAGS)
-CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(ZLIB_LDFLAGS) \$(XAPIAN_LDFLAGS)
+CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(ZLIB_LDFLAGS) \$(XAPIAN_LDFLAGS)
EOF
# construct the sh.config
NOTMUCH_SRCDIR='${NOTMUCH_SRCDIR}'
-# Whether the Xapian version in use supports compaction
-NOTMUCH_HAVE_XAPIAN_COMPACT=${have_xapian_compact}
-
-# Whether the Xapian version in use supports field processors
-NOTMUCH_HAVE_XAPIAN_FIELD_PROCESSOR=${have_xapian_field_processor}
-
-# Whether the Xapian version in use supports lock retry
-NOTMUCH_HAVE_XAPIAN_DB_RETRY_LOCK=${have_xapian_db_retry_lock}
+# Whether to have Xapian retry lock
+NOTMUCH_HAVE_XAPIAN_DB_RETRY_LOCK=${WITH_RETRY_LOCK}
# Which backend will Xapian use by default?
NOTMUCH_DEFAULT_XAPIAN_BACKEND=${default_xapian_backend}
notmuch_built_with (const char *name)
{
if (STRNCMP_LITERAL (name, "compact") == 0) {
- return HAVE_XAPIAN_COMPACT;
+ return true;
} else if (STRNCMP_LITERAL (name, "field_processor") == 0) {
- return HAVE_XAPIAN_FIELD_PROCESSOR;
+ return true;
} else if (STRNCMP_LITERAL (name, "retry_lock") == 0) {
return HAVE_XAPIAN_DB_RETRY_LOCK;
} else if (STRNCMP_LITERAL (name, "session_key") == 0) {
*/
{ "folder", "XFOLDER:", NOTMUCH_FIELD_EXTERNAL |
NOTMUCH_FIELD_PROCESSOR },
-#if HAVE_XAPIAN_FIELD_PROCESSOR
{ "date", NULL, NOTMUCH_FIELD_EXTERNAL |
NOTMUCH_FIELD_PROCESSOR },
{ "query", NULL, NOTMUCH_FIELD_EXTERNAL |
NOTMUCH_FIELD_PROCESSOR },
-#endif
{ "from", "XFROM", NOTMUCH_FIELD_EXTERNAL |
NOTMUCH_FIELD_PROBABILISTIC |
NOTMUCH_FIELD_PROCESSOR },
return NOTMUCH_STATUS_SUCCESS;
}
-#if HAVE_XAPIAN_FIELD_PROCESSOR
static void
_setup_query_field (const prefix_t *prefix, notmuch_database_t *notmuch)
{
_setup_query_field_default (prefix, notmuch);
}
}
-#else
-static inline void
-_setup_query_field (const prefix_t *prefix, notmuch_database_t *notmuch)
-{
- _setup_query_field_default (prefix, notmuch);
-}
-#endif
const char *
_find_prefix (const char *name)
return valno;
}
-#if HAVE_XAPIAN_FIELD_PROCESSOR
/* XXX TODO: is throwing an exception the right thing to do here? */
Xapian::Query
DateFieldProcessor::operator() (const std::string & str)
Xapian::Query (Xapian::Query::OP_VALUE_GE, 0, Xapian::sortable_serialise ((double) from)),
Xapian::Query (Xapian::Query::OP_VALUE_LE, 0, Xapian::sortable_serialise ((double) to)));
}
-#endif
Xapian::valueno operator() (std::string &begin, std::string &end);
};
-#if HAVE_XAPIAN_FIELD_PROCESSOR
class DateFieldProcessor : public Xapian::FieldProcessor {
Xapian::Query operator() (const std::string & str);
};
-#endif
+
#endif /* NOTMUCH_PARSE_TIME_VRP_H */
#include "query-fp.h"
#include <iostream>
-#if HAVE_XAPIAN_FIELD_PROCESSOR
-
Xapian::Query
QueryFieldProcessor::operator() (const std::string & name)
{
return parser.parse_query (expansion, NOTMUCH_QUERY_PARSER_FLAGS);
}
-#endif
#include <xapian.h>
#include "notmuch.h"
-#if HAVE_XAPIAN_FIELD_PROCESSOR
class QueryFieldProcessor : public Xapian::FieldProcessor {
protected:
Xapian::QueryParser &parser;
Xapian::Query operator() (const std::string & str);
};
-#endif
+
#endif /* NOTMUCH_QUERY_FP_H */
#include "notmuch-private.h"
#include "database-private.h"
-#if HAVE_XAPIAN_FIELD_PROCESSOR
static void
compile_regex (regex_t ®exp, const char *str)
{
}
}
}
-#endif
#ifndef NOTMUCH_REGEXP_FIELDS_H
#define NOTMUCH_REGEXP_FIELDS_H
-#if HAVE_XAPIAN_FIELD_PROCESSOR
+
#include <sys/types.h>
#include <regex.h>
#include "database-private.h"
Xapian::Query operator() (const std::string & str);
};
-#endif
+
#endif /* NOTMUCH_REGEXP_FIELDS_H */
#include "thread-fp.h"
#include <iostream>
-#if HAVE_XAPIAN_FIELD_PROCESSOR
-
Xapian::Query
ThreadFieldProcessor::operator() (const std::string & str)
{
}
}
-#endif
#include <xapian.h>
#include "notmuch.h"
-#if HAVE_XAPIAN_FIELD_PROCESSOR
class ThreadFieldProcessor : public Xapian::FieldProcessor {
protected:
Xapian::QueryParser &parser;
Xapian::Query operator() (const std::string & str);
};
-#endif
+
#endif /* NOTMUCH_THREAD_FP_H */
notmuch tag +tag2 subject:Two
notmuch tag -tag1 +tag3 subject:Three
-if [ $NOTMUCH_HAVE_XAPIAN_COMPACT -eq 0 ]; then
- test_begin_subtest "Compact unsupported: error message"
- output=$(notmuch compact --quiet 2>&1)
- test_expect_equal "$output" "notmuch was compiled against a xapian version lacking compaction support.
-Compaction failed: Unsupported operation"
-
- test_begin_subtest "Compact unsupported: status code"
- test_expect_code 1 "notmuch compact"
-
- test_done
-fi
-
test_begin_subtest "Running compact"
test_expect_success "notmuch compact --backup=${TEST_DIRECTORY}/xapian.old"
test_begin_subtest "Absolute date field"
output=$(notmuch search date:2010-12-16 | notmuch_search_sanitize)
-if [ $NOTMUCH_HAVE_XAPIAN_FIELD_PROCESSOR -ne 1 ]; then
- test_subtest_known_broken
-fi
test_expect_equal "$output" "thread:XXX 2010-12-16 [1/1] Olivier Berger; Essai accentué (inbox unread)"
test_begin_subtest "Absolute time range with TZ"
test_expect_equal 0 "$count"
test_begin_subtest "Same query against threads"
-if [ $NOTMUCH_HAVE_XAPIAN_FIELD_PROCESSOR -eq 0 ]; then
- test_subtest_known_broken
-fi
notmuch search thread:{from:keithp} and thread:{to:keithp} | notmuch_search_sanitize > OUTPUT
cat<<EOF > EXPECTED
thread:XXX 2009-11-18 [7/7] Lars Kellogg-Stedman, Mikhail Gusarov, Keith Packard, Carl Worth; [notmuch] Working with Maildir storage? (inbox signed unread)
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Mix thread and non-threads query"
-if [ $NOTMUCH_HAVE_XAPIAN_FIELD_PROCESSOR -eq 0 ]; then
- test_subtest_known_broken
-fi
notmuch search thread:{from:keithp} and to:keithp | notmuch_search_sanitize > OUTPUT
cat<<EOF > EXPECTED
thread:XXX 2009-11-18 [1/7] Lars Kellogg-Stedman| Mikhail Gusarov, Keith Packard, Carl Worth; [notmuch] Working with Maildir storage? (inbox signed unread)
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Compound subquery"
-if [ $NOTMUCH_HAVE_XAPIAN_FIELD_PROCESSOR -eq 0 ]; then
- test_subtest_known_broken
-fi
notmuch search 'thread:"{from:keithp and date:2009}" and thread:{to:keithp}' | notmuch_search_sanitize > OUTPUT
cat<<EOF > EXPECTED
thread:XXX 2009-11-18 [7/7] Lars Kellogg-Stedman, Mikhail Gusarov, Keith Packard, Carl Worth; [notmuch] Working with Maildir storage? (inbox signed unread)
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Syntax/quoting error in subquery"
-if [ $NOTMUCH_HAVE_XAPIAN_FIELD_PROCESSOR -eq 0 ]; then
- test_subtest_known_broken
-fi
notmuch search 'thread:{from:keithp and date:2009} and thread:{to:keithp}' 1>OUTPUT 2>&1
cat<<EOF > EXPECTED
notmuch search: A Xapian exception occurred
test_begin_subtest "search named query"
notmuch search query:test > OUTPUT
notmuch search $QUERYSTR > EXPECTED
-if [ $NOTMUCH_HAVE_XAPIAN_FIELD_PROCESSOR -ne 1 ]; then
- test_subtest_known_broken
-fi
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "search named query with other terms"
notmuch search query:test and subject:Maildir > OUTPUT
notmuch search $QUERYSTR and subject:Maildir > EXPECTED
-if [ $NOTMUCH_HAVE_XAPIAN_FIELD_PROCESSOR -ne 1 ]; then
- test_subtest_known_broken
-fi
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "search nested named query"
test_description='regular expression searches'
. $(dirname "$0")/test-lib.sh || exit 1
-if [ $NOTMUCH_HAVE_XAPIAN_FIELD_PROCESSOR -eq 0 ]; then
- test_done
-fi
-
add_message '[dir]=bad' '[subject]="To the bone"'
add_message '[dir]=.' '[subject]="Top level"'
add_message '[dir]=bad/news' '[subject]="Bears"'
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest 'Regexp search for second subject'
-# Note that missing field processor support really means the test
-# doesn't make sense, but it happens to pass.
-if [ $NOTMUCH_HAVE_XAPIAN_FIELD_PROCESSOR -eq 1 ]; then
- test_subtest_known_broken
-fi
+test_subtest_known_broken
cat <<EOF >EXPECTED
MAIL_DIR/copy0
MAIL_DIR/copy1