From 62810d32e13694a64263e8ff86454b05dc00cac7 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Tue, 26 Oct 2021 15:39:47 +0200 Subject: [PATCH] deep_search: fix compilation with old Xapian versions --- libretroshare/src/deep_search/commonutils.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libretroshare/src/deep_search/commonutils.cpp b/libretroshare/src/deep_search/commonutils.cpp index 693bf9924..e8e1e4b59 100644 --- a/libretroshare/src/deep_search/commonutils.cpp +++ b/libretroshare/src/deep_search/commonutils.cpp @@ -26,6 +26,14 @@ #include "util/rsthreads.h" #include "util/rsdebuglevel0.h" +#ifndef XAPIAN_AT_LEAST +/// Added in Xapian 1.4.2. +#define XAPIAN_AT_LEAST(A,B,C) \ + (XAPIAN_MAJOR_VERSION > (A) || \ + (XAPIAN_MAJOR_VERSION == (A) && \ + (XAPIAN_MINOR_VERSION > (B) || \ + (XAPIAN_MINOR_VERSION == (B) && XAPIAN_REVISION >= (C))))) +#endif namespace DeepSearch { @@ -34,8 +42,17 @@ std::unique_ptr openReadOnlyDatabase( { try { +#if XAPIAN_AT_LEAST(1,3,2) std::unique_ptr dbPtr( new Xapian::Database(path, flags) ); +#else + std::unique_ptr dbPtr(new Xapian::Database(path)); + if(flags) + { + RS_WARN( "Xapian DB flags: ", flags, " ignored due to old Xapian " + "library version: ", XAPIAN_VERSION, " < 1.3.2" ); + } +#endif return dbPtr; } catch(Xapian::DatabaseOpeningError& e)