summaryrefslogtreecommitdiffstats
path: root/external/clucene
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /external/clucene
parentInitial commit. (diff)
downloadlibreoffice-cb75148ebd0135178ff46f89a30139c44f8d2040.tar.xz
libreoffice-cb75148ebd0135178ff46f89a30139c44f8d2040.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'external/clucene')
-rw-r--r--external/clucene/Library_clucene.mk234
-rw-r--r--external/clucene/Makefile7
-rw-r--r--external/clucene/Module_clucene.mk17
-rw-r--r--external/clucene/README4
-rw-r--r--external/clucene/UnpackedTarball_clucene.mk81
-rw-r--r--external/clucene/configs/_clucene-config-LINUX.h114
-rw-r--r--external/clucene/configs/_clucene-config-MSVC.h114
-rw-r--r--external/clucene/configs/_clucene-config-generic.h114
-rw-r--r--external/clucene/configs/clucene-config-GCC-atomic.h150
-rw-r--r--external/clucene/configs/clucene-config-MSVC.h149
-rw-r--r--external/clucene/configs/clucene-config-generic.h150
-rw-r--r--external/clucene/inc/pch/precompiled_clucene.cxx12
-rw-r--r--external/clucene/inc/pch/precompiled_clucene.hxx108
-rw-r--r--external/clucene/patches/binary_function.patch34
-rw-r--r--external/clucene/patches/c++20.patch11
-rw-r--r--external/clucene/patches/clucene-aix.patch40
-rw-r--r--external/clucene/patches/clucene-asan.patch26
-rw-r--r--external/clucene/patches/clucene-debug.patch11
-rw-r--r--external/clucene/patches/clucene-git1-win64.patch45
-rw-r--r--external/clucene/patches/clucene-libcpp.patch42
-rw-r--r--external/clucene/patches/clucene-mixes-uptemplate-parameter-msvc-14.patch53
-rw-r--r--external/clucene/patches/clucene-multimap-put.patch9
-rw-r--r--external/clucene/patches/clucene-mutex.patch13
-rw-r--r--external/clucene/patches/clucene-narrowing-conversions.patch36
-rw-r--r--external/clucene/patches/clucene-nullptr.patch22
-rw-r--r--external/clucene/patches/clucene-ub.patch33
-rw-r--r--external/clucene/patches/clucene-warnings.patch124
-rw-r--r--external/clucene/patches/contribs-lib-makefile.patch23
-rw-r--r--external/clucene/patches/heap-buffer-overflow.patch11
-rw-r--r--external/clucene/patches/nullstring.patch11
-rw-r--r--external/clucene/patches/ostream-wchar_t.patch29
-rw-r--r--external/clucene/patches/write-strings.patch22
32 files changed, 1849 insertions, 0 deletions
diff --git a/external/clucene/Library_clucene.mk b/external/clucene/Library_clucene.mk
new file mode 100644
index 000000000..c6f289550
--- /dev/null
+++ b/external/clucene/Library_clucene.mk
@@ -0,0 +1,234 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Library_Library,clucene))
+
+$(eval $(call gb_Library_use_external,clucene,zlib))
+
+$(eval $(call gb_Library_use_unpacked,clucene,clucene))
+
+$(eval $(call gb_Library_set_warnings_disabled,clucene))
+
+$(eval $(call gb_Library_set_include,clucene,\
+ -I$(call gb_UnpackedTarball_get_dir,clucene)/inc/internal \
+ -I$(call gb_UnpackedTarball_get_dir,clucene)/src/core \
+ -I$(call gb_UnpackedTarball_get_dir,clucene)/src/contribs-lib \
+ -I$(call gb_UnpackedTarball_get_dir,clucene)/src/shared \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_Library_set_precompiled_header,clucene,external/clucene/inc/pch/precompiled_clucene))
+
+$(eval $(call gb_Library_add_defs,clucene,\
+ -Dclucene_shared_EXPORTS \
+ -Dclucene_core_EXPORTS \
+ -Dclucene_contribs_lib_EXPORTS \
+))
+
+# Needed when building against MSVC in C++17 mode, as
+# workdir/UnpackedTarball/clucene/src/core/CLucene/util/Equators.h uses std::binary_function:
+$(eval $(call gb_Library_add_defs,clucene, \
+ -D_HAS_AUTO_PTR_ETC=1 \
+))
+
+ifeq ($(OS),LINUX)
+$(eval $(call gb_Library_add_libs,clucene,\
+ -lm \
+ -ldl \
+ -pthread \
+))
+endif
+
+$(eval $(call gb_Library_set_generated_cxx_suffix,clucene,cpp))
+
+$(eval $(call gb_Library_add_generated_exception_objects,clucene,\
+ UnpackedTarball/clucene/src/shared/CLucene/SharedHeader \
+ UnpackedTarball/clucene/src/shared/CLucene/config/gunichartables \
+ UnpackedTarball/clucene/src/shared/CLucene/config/repl_tcslwr \
+ UnpackedTarball/clucene/src/shared/CLucene/config/repl_tcstoll \
+ UnpackedTarball/clucene/src/shared/CLucene/config/repl_tcscasecmp \
+ UnpackedTarball/clucene/src/shared/CLucene/config/repl_tprintf \
+ UnpackedTarball/clucene/src/shared/CLucene/config/repl_lltot \
+ UnpackedTarball/clucene/src/shared/CLucene/config/repl_tcstod \
+ UnpackedTarball/clucene/src/shared/CLucene/config/utf8 \
+ UnpackedTarball/clucene/src/shared/CLucene/config/threads \
+ UnpackedTarball/clucene/src/shared/CLucene/debug/condition \
+ UnpackedTarball/clucene/src/shared/CLucene/util/StringBuffer \
+ UnpackedTarball/clucene/src/shared/CLucene/util/Misc \
+ UnpackedTarball/clucene/src/shared/CLucene/util/dirent \
+ UnpackedTarball/clucene/src/core/CLucene/StdHeader \
+ UnpackedTarball/clucene/src/core/CLucene/debug/error \
+ UnpackedTarball/clucene/src/core/CLucene/util/ThreadLocal \
+ UnpackedTarball/clucene/src/core/CLucene/util/Reader \
+ UnpackedTarball/clucene/src/core/CLucene/util/Equators \
+ UnpackedTarball/clucene/src/core/CLucene/util/FastCharStream \
+ UnpackedTarball/clucene/src/core/CLucene/util/MD5Digester \
+ UnpackedTarball/clucene/src/core/CLucene/util/StringIntern \
+ UnpackedTarball/clucene/src/core/CLucene/util/BitSet \
+ UnpackedTarball/clucene/src/core/CLucene/queryParser/FastCharStream \
+ UnpackedTarball/clucene/src/core/CLucene/queryParser/MultiFieldQueryParser \
+ UnpackedTarball/clucene/src/core/CLucene/queryParser/QueryParser \
+ UnpackedTarball/clucene/src/core/CLucene/queryParser/QueryParserTokenManager \
+ UnpackedTarball/clucene/src/core/CLucene/queryParser/QueryToken \
+ UnpackedTarball/clucene/src/core/CLucene/queryParser/legacy/Lexer \
+ UnpackedTarball/clucene/src/core/CLucene/queryParser/legacy/MultiFieldQueryParser \
+ UnpackedTarball/clucene/src/core/CLucene/queryParser/legacy/QueryParser \
+ UnpackedTarball/clucene/src/core/CLucene/queryParser/legacy/QueryParserBase \
+ UnpackedTarball/clucene/src/core/CLucene/queryParser/legacy/QueryToken \
+ UnpackedTarball/clucene/src/core/CLucene/queryParser/legacy/TokenList \
+ UnpackedTarball/clucene/src/core/CLucene/analysis/standard/StandardAnalyzer \
+ UnpackedTarball/clucene/src/core/CLucene/analysis/standard/StandardFilter \
+ UnpackedTarball/clucene/src/core/CLucene/analysis/standard/StandardTokenizer \
+ UnpackedTarball/clucene/src/core/CLucene/analysis/Analyzers \
+ UnpackedTarball/clucene/src/core/CLucene/analysis/AnalysisHeader \
+ UnpackedTarball/clucene/src/core/CLucene/store/MMapInput \
+ UnpackedTarball/clucene/src/core/CLucene/store/IndexInput \
+ UnpackedTarball/clucene/src/core/CLucene/store/Lock \
+ UnpackedTarball/clucene/src/core/CLucene/store/LockFactory \
+ UnpackedTarball/clucene/src/core/CLucene/store/IndexOutput \
+ UnpackedTarball/clucene/src/core/CLucene/store/Directory \
+ UnpackedTarball/clucene/src/core/CLucene/store/FSDirectory \
+ UnpackedTarball/clucene/src/core/CLucene/store/RAMDirectory \
+ UnpackedTarball/clucene/src/core/CLucene/document/Document \
+ UnpackedTarball/clucene/src/core/CLucene/document/DateField \
+ UnpackedTarball/clucene/src/core/CLucene/document/DateTools \
+ UnpackedTarball/clucene/src/core/CLucene/document/Field \
+ UnpackedTarball/clucene/src/core/CLucene/document/FieldSelector \
+ UnpackedTarball/clucene/src/core/CLucene/document/NumberTools \
+ UnpackedTarball/clucene/src/core/CLucene/index/IndexFileNames \
+ UnpackedTarball/clucene/src/core/CLucene/index/IndexFileNameFilter \
+ UnpackedTarball/clucene/src/core/CLucene/index/IndexDeletionPolicy \
+ UnpackedTarball/clucene/src/core/CLucene/index/SegmentMergeInfo \
+ UnpackedTarball/clucene/src/core/CLucene/index/SegmentInfos \
+ UnpackedTarball/clucene/src/core/CLucene/index/MergeScheduler \
+ UnpackedTarball/clucene/src/core/CLucene/index/SegmentTermDocs \
+ UnpackedTarball/clucene/src/core/CLucene/index/FieldsWriter \
+ UnpackedTarball/clucene/src/core/CLucene/index/TermInfosWriter \
+ UnpackedTarball/clucene/src/core/CLucene/index/Term \
+ UnpackedTarball/clucene/src/core/CLucene/index/Terms \
+ UnpackedTarball/clucene/src/core/CLucene/index/MergePolicy \
+ UnpackedTarball/clucene/src/core/CLucene/index/DocumentsWriter \
+ UnpackedTarball/clucene/src/core/CLucene/index/DocumentsWriterThreadState \
+ UnpackedTarball/clucene/src/core/CLucene/index/SegmentTermVector \
+ UnpackedTarball/clucene/src/core/CLucene/index/TermVectorReader \
+ UnpackedTarball/clucene/src/core/CLucene/index/FieldInfos \
+ UnpackedTarball/clucene/src/core/CLucene/index/CompoundFile \
+ UnpackedTarball/clucene/src/core/CLucene/index/SkipListReader \
+ UnpackedTarball/clucene/src/core/CLucene/index/SkipListWriter \
+ UnpackedTarball/clucene/src/core/CLucene/index/IndexFileDeleter \
+ UnpackedTarball/clucene/src/core/CLucene/index/SegmentReader \
+ UnpackedTarball/clucene/src/core/CLucene/index/DirectoryIndexReader \
+ UnpackedTarball/clucene/src/core/CLucene/index/TermVectorWriter \
+ UnpackedTarball/clucene/src/core/CLucene/index/IndexReader \
+ UnpackedTarball/clucene/src/core/CLucene/index/SegmentTermPositions \
+ UnpackedTarball/clucene/src/core/CLucene/index/SegmentMerger \
+ UnpackedTarball/clucene/src/core/CLucene/index/IndexWriter \
+ UnpackedTarball/clucene/src/core/CLucene/index/MultiReader \
+ UnpackedTarball/clucene/src/core/CLucene/index/MultiSegmentReader \
+ UnpackedTarball/clucene/src/core/CLucene/index/Payload \
+ UnpackedTarball/clucene/src/core/CLucene/index/SegmentTermEnum \
+ UnpackedTarball/clucene/src/core/CLucene/index/TermInfo \
+ UnpackedTarball/clucene/src/core/CLucene/index/IndexModifier \
+ UnpackedTarball/clucene/src/core/CLucene/index/SegmentMergeQueue \
+ UnpackedTarball/clucene/src/core/CLucene/index/FieldsReader \
+ UnpackedTarball/clucene/src/core/CLucene/index/TermInfosReader \
+ UnpackedTarball/clucene/src/core/CLucene/index/MultipleTermPositions \
+ UnpackedTarball/clucene/src/core/CLucene/search/Compare \
+ UnpackedTarball/clucene/src/core/CLucene/search/Scorer \
+ UnpackedTarball/clucene/src/core/CLucene/search/ScorerDocQueue \
+ UnpackedTarball/clucene/src/core/CLucene/search/PhraseScorer \
+ UnpackedTarball/clucene/src/core/CLucene/search/SloppyPhraseScorer \
+ UnpackedTarball/clucene/src/core/CLucene/search/DisjunctionSumScorer \
+ UnpackedTarball/clucene/src/core/CLucene/search/ConjunctionScorer \
+ UnpackedTarball/clucene/src/core/CLucene/search/PhraseQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/PrefixQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/ExactPhraseScorer \
+ UnpackedTarball/clucene/src/core/CLucene/search/TermScorer \
+ UnpackedTarball/clucene/src/core/CLucene/search/Similarity \
+ UnpackedTarball/clucene/src/core/CLucene/search/BooleanScorer \
+ UnpackedTarball/clucene/src/core/CLucene/search/BooleanScorer2 \
+ UnpackedTarball/clucene/src/core/CLucene/search/HitQueue \
+ UnpackedTarball/clucene/src/core/CLucene/search/FieldCacheImpl \
+ UnpackedTarball/clucene/src/core/CLucene/search/ChainedFilter \
+ UnpackedTarball/clucene/src/core/CLucene/search/RangeFilter \
+ UnpackedTarball/clucene/src/core/CLucene/search/CachingWrapperFilter \
+ UnpackedTarball/clucene/src/core/CLucene/search/QueryFilter \
+ UnpackedTarball/clucene/src/core/CLucene/search/TermQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/FuzzyQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/SearchHeader \
+ UnpackedTarball/clucene/src/core/CLucene/search/RangeQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/IndexSearcher \
+ UnpackedTarball/clucene/src/core/CLucene/search/Sort \
+ UnpackedTarball/clucene/src/core/CLucene/search/PhrasePositions \
+ UnpackedTarball/clucene/src/core/CLucene/search/FieldDocSortedHitQueue \
+ UnpackedTarball/clucene/src/core/CLucene/search/WildcardTermEnum \
+ UnpackedTarball/clucene/src/core/CLucene/search/MultiSearcher \
+ UnpackedTarball/clucene/src/core/CLucene/search/Hits \
+ UnpackedTarball/clucene/src/core/CLucene/search/MultiTermQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/FilteredTermEnum \
+ UnpackedTarball/clucene/src/core/CLucene/search/FieldSortedHitQueue \
+ UnpackedTarball/clucene/src/core/CLucene/search/WildcardQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/Explanation \
+ UnpackedTarball/clucene/src/core/CLucene/search/BooleanQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/FieldCache \
+ UnpackedTarball/clucene/src/core/CLucene/search/DateFilter \
+ UnpackedTarball/clucene/src/core/CLucene/search/MatchAllDocsQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/MultiPhraseQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/ConstantScoreQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/CachingSpanFilter \
+ UnpackedTarball/clucene/src/core/CLucene/search/SpanQueryFilter \
+ UnpackedTarball/clucene/src/core/CLucene/search/spans/NearSpansOrdered \
+ UnpackedTarball/clucene/src/core/CLucene/search/spans/NearSpansUnordered \
+ UnpackedTarball/clucene/src/core/CLucene/search/spans/SpanFirstQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/spans/SpanNearQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/spans/SpanNotQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/spans/SpanOrQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/spans/SpanScorer \
+ UnpackedTarball/clucene/src/core/CLucene/search/spans/SpanTermQuery \
+ UnpackedTarball/clucene/src/core/CLucene/search/spans/SpanWeight \
+ UnpackedTarball/clucene/src/core/CLucene/search/spans/TermSpans \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/analysis/cjk/CJKAnalyzer \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/analysis/LanguageBasedAnalyzer \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/analysis/PorterStemmer \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/Snowball \
+))
+
+$(eval $(call gb_Library_add_generated_cobjects,clucene,\
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/libstemmer/libstemmer \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_ISO_8859_1_danish \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_ISO_8859_1_dutch \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_ISO_8859_1_english \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_ISO_8859_1_finnish \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_ISO_8859_1_french \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_ISO_8859_1_german \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_ISO_8859_1_italian \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_ISO_8859_1_norwegian \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_ISO_8859_1_porter \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_ISO_8859_1_portuguese \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_ISO_8859_1_spanish \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_ISO_8859_1_swedish \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_KOI8_R_russian \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_UTF_8_danish \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_UTF_8_dutch \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_UTF_8_english \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_UTF_8_finnish \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_UTF_8_french \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_UTF_8_german \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_UTF_8_italian \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_UTF_8_norwegian \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_UTF_8_porter \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_UTF_8_portuguese \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_UTF_8_russian \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_UTF_8_spanish \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/src_c/stem_UTF_8_swedish \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/runtime/utilities \
+ UnpackedTarball/clucene/src/contribs-lib/CLucene/snowball/runtime/api \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/clucene/Makefile b/external/clucene/Makefile
new file mode 100644
index 000000000..e4968cf85
--- /dev/null
+++ b/external/clucene/Makefile
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/clucene/Module_clucene.mk b/external/clucene/Module_clucene.mk
new file mode 100644
index 000000000..d74fc441f
--- /dev/null
+++ b/external/clucene/Module_clucene.mk
@@ -0,0 +1,17 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Module_Module,clucene))
+
+$(eval $(call gb_Module_add_targets,clucene,\
+ Library_clucene \
+ UnpackedTarball_clucene \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/clucene/README b/external/clucene/README
new file mode 100644
index 000000000..bedae920f
--- /dev/null
+++ b/external/clucene/README
@@ -0,0 +1,4 @@
+External package containing clucene from [http://clucene.sourceforge.net/].
+
+This is used to index our downloadable help packages, and allow them
+to be searched efficiently at run-time. \ No newline at end of file
diff --git a/external/clucene/UnpackedTarball_clucene.mk b/external/clucene/UnpackedTarball_clucene.mk
new file mode 100644
index 000000000..c3928d335
--- /dev/null
+++ b/external/clucene/UnpackedTarball_clucene.mk
@@ -0,0 +1,81 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_UnpackedTarball_UnpackedTarball,clucene))
+
+$(eval $(call gb_UnpackedTarball_set_tarball,clucene,$(CLUCENE_TARBALL)))
+
+ifneq ($(OS),WNT)
+$(eval $(call gb_UnpackedTarball_set_post_action,clucene,\
+ mkdir -p inc/internal/CLucene/util && \
+ mv src/shared/CLucene/util/dirent.h inc/internal/CLucene/util \
+))
+endif
+
+$(eval $(call gb_UnpackedTarball_set_patchlevel,clucene,0))
+
+# clucene-multimap-put.patch was proposed upstream, see
+# http://sourceforge.net/mailarchive/message.php?msg_id=29143260
+# clucene-mutex.patch was proposed upstream, see
+# http://sourceforge.net/mailarchive/message.php?msg_id=32314782
+# clucene-asan.patch was proposed upstream, see
+# http://sourceforge.net/mailarchive/message.php?msg_id=32367781
+# see msvc14.0 error report on:
+# https://connect.microsoft.com/VisualStudio/feedback/details/1424082/vs2015-rc-c-compiler-mixes-up-template-parameter-with-identical-named-inherited-typedef
+# ostream-wchar_t.patch was proposed upstream, see
+# <https://sourceforge.net/p/clucene/mailman/message/36989348/>
+# heap-buffer-overflow.patch was proposed upstream, see
+# <https://sourceforge.net/p/clucene/mailman/message/36991067/>
+# c++20.patch was proposed upstream, see
+# <https://sourceforge.net/p/clucene/mailman/message/37040362/>
+# nullstring.patch was proposed upstream, see
+# <https://sourceforge.net/p/clucene/mailman/message/37338234/>
+$(eval $(call gb_UnpackedTarball_add_patches,clucene,\
+ external/clucene/patches/clucene-debug.patch \
+ external/clucene/patches/clucene-multimap-put.patch \
+ external/clucene/patches/clucene-narrowing-conversions.patch \
+ external/clucene/patches/clucene-nullptr.patch \
+ external/clucene/patches/clucene-warnings.patch \
+ external/clucene/patches/clucene-aix.patch \
+ external/clucene/patches/clucene-git1-win64.patch \
+ external/clucene/patches/clucene-ub.patch \
+ external/clucene/patches/clucene-mutex.patch \
+ external/clucene/patches/clucene-asan.patch \
+ external/clucene/patches/clucene-mixes-uptemplate-parameter-msvc-14.patch \
+ external/clucene/patches/ostream-wchar_t.patch \
+ external/clucene/patches/heap-buffer-overflow.patch \
+ external/clucene/patches/c++20.patch \
+ external/clucene/patches/write-strings.patch \
+ external/clucene/patches/nullstring.patch \
+ external/clucene/patches/binary_function.patch \
+))
+
+ifneq ($(OS),WNT)
+$(eval $(call gb_UnpackedTarball_add_patches,clucene,\
+ external/clucene/patches/clucene-libcpp.patch \
+))
+endif
+
+ifeq ($(OS),WNT)
+$(eval $(call gb_UnpackedTarball_add_file,clucene,src/shared/CLucene/_clucene-config.h,external/clucene/configs/_clucene-config-MSVC.h))
+$(eval $(call gb_UnpackedTarball_add_file,clucene,src/shared/CLucene/clucene-config.h,external/clucene/configs/clucene-config-MSVC.h))
+else # ! $(OS),WNT
+ifeq ($(HAVE_GCC_BUILTIN_ATOMIC),TRUE)
+$(eval $(call gb_UnpackedTarball_add_file,clucene,src/shared/CLucene/clucene-config.h,external/clucene/configs/clucene-config-GCC-atomic.h))
+else
+$(eval $(call gb_UnpackedTarball_add_file,clucene,src/shared/CLucene/clucene-config.h,external/clucene/configs/clucene-config-generic.h))
+endif
+ifeq ($(OS),LINUX)
+$(eval $(call gb_UnpackedTarball_add_file,clucene,src/shared/CLucene/_clucene-config.h,external/clucene/configs/_clucene-config-LINUX.h))
+else
+$(eval $(call gb_UnpackedTarball_add_file,clucene,src/shared/CLucene/_clucene-config.h,external/clucene/configs/_clucene-config-generic.h))
+endif
+endif # $(OS),WNT
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/clucene/configs/_clucene-config-LINUX.h b/external/clucene/configs/_clucene-config-LINUX.h
new file mode 100644
index 000000000..2b425b6b2
--- /dev/null
+++ b/external/clucene/configs/_clucene-config-LINUX.h
@@ -0,0 +1,114 @@
+#ifndef _SRC_CLUCENE_INTERNAL_CLUCENE_CONFIG_H
+#define _SRC_CLUCENE_INTERNAL_CLUCENE_CONFIG_H 1
+
+/* src/shared/CLucene/_clucene-config.h.
+* Normally generated automatically at end of cmake,
+* but here in LibreOffice this actually is a copy of
+* clucene/configs/_clucene-config-LINUX.h.
+* These are internal definitions, and this file does not need to be distributed
+*/
+
+/* CMake will look for these functions: */
+/* #undef _CL_HAVE_FUNCTION__VSNWPRINTF */
+/* #undef _CL_HAVE_FUNCTION__SNWPRINTF */
+#define _CL_HAVE_FUNCTION_WCSCASECMP
+#define _CL_HAVE_FUNCTION_WCSCAT 1
+#define _CL_HAVE_FUNCTION_WCSCHR 1
+#define _CL_HAVE_FUNCTION_WCSCMP 1
+#define _CL_HAVE_FUNCTION_WCSCPY 1
+#define _CL_HAVE_FUNCTION_WCSCSPN 1
+/* #undef _CL_HAVE_FUNCTION_WCSICMP */
+#define _CL_HAVE_FUNCTION_WCSLEN 1
+#define _CL_HAVE_FUNCTION_WCSNCMP 1
+#define _CL_HAVE_FUNCTION_WCSNCPY 1
+#define _CL_HAVE_FUNCTION_WCSSTR 1
+#define _CL_HAVE_FUNCTION_WCSTOD 1
+#define _CL_HAVE_FUNCTION_WCSDUP 1
+#define _CL_HAVE_FUNCTION_WCSTOLL 1
+/* #undef _CL_HAVE_FUNCTION_WCSUPR */
+#define _CL_HAVE_FUNCTION_GETTIMEOFDAY 1
+/* #undef _CL_HAVE_FUNCTION_MAPVIEWOFFILE */
+
+/* #undef _CL_HAVE_FUNCTION_LLTOA */
+/* #undef _CL_HAVE_FUNCTION_LLTOW */
+#define _CL_HAVE_FUNCTION_PRINTF 1
+#define _CL_HAVE_FUNCTION_SNPRINTF 1
+#define _CL_HAVE_FUNCTION_MMAP 1
+/* #undef _CL_HAVE_FUNCTION_STRLWR */
+#define _CL_HAVE_FUNCTION_STRTOLL 1
+/* #undef _CL_HAVE_FUNCTION_STRUPR */
+/* #undef _CL_HAVE_FUNCTION_GETPAGESIZE */
+#define _CL_HAVE_FUNCTION_USLEEP 1
+/* #undef _CL_HAVE_FUNCTION_SLEEP */
+
+#define CL_MAX_PATH 4096
+//this is the max filename... for now its just the same,
+//but this could change, so we use a different name
+#define CL_MAX_NAME CL_MAX_PATH
+//this used to be CL_MAX_NAME * 32, but as Alex Hudson points out, this could come to be 128kb.
+//the above logic for CL_MAX_NAME should be correct enough to handle all file names
+#define CL_MAX_DIR CL_MAX_PATH
+
+#define _O_RANDOM 0
+#define _O_BINARY 0
+#define _S_IREAD S_IREAD
+#define _S_IWRITE S_IWRITE
+#define _timeb timeb
+
+#define _ILONG(x) x ## L
+#define _ILONGLONG(x) x ## LL
+
+#define fileStat stat64
+#define cl_stat_t stat64
+#define fileSize CL_NS(util)::Misc::filelength
+#define fileSeek lseek64
+#define fileTell(fhandle) fileSeek(fhandle, 0, SEEK_CUR)
+#define fileHandleStat fstat64
+#define _realpath realpath
+#define _rename rename
+#define _close close
+#define _read read
+#define _cl_open open
+#define _write write
+#define _snprintf snprintf
+#define _mkdir(x) mkdir(x,0777)
+#define _unlink unlink
+#define _ftime ftime
+#define SLEEPFUNCTION usleep
+
+/* CMake will determine these specifics. Things like bugs, etc */
+
+/* Does not support new float byte<->float conversions */
+/* #undef _CL_HAVE_NO_FLOAT_BYTE */
+
+/* Define if recursive pthread mutexes are available */
+#define _CL_HAVE_PTHREAD_MUTEX_RECURSIVE 1
+
+/** define if you would like to force clucene to use the internal
+* character functions.
+* Tests may display unpredictable behaviour if this is not defined.
+*/
+#ifndef LUCENE_USE_INTERNAL_CHAR_FUNCTIONS
+ #define LUCENE_USE_INTERNAL_CHAR_FUNCTIONS 1
+#endif
+
+/** fix ansi for loop scope */
+#if 1==0
+ #define for if (0); else for
+#endif
+
+
+/* Compiler oddities */
+
+//not sure why, but cygwin reports _S_IREAD, but doesn't actually work...
+//TODO: make this work properly (this bit shouldn't be necessary)
+#ifdef __CYGWIN__
+ #define _S_IREAD 0333
+ #define _S_IWRITE 0333
+#endif
+
+#ifdef __BORLANDC__ //borland compiler
+ #define O_RANDOM 0
+#endif
+
+#endif
diff --git a/external/clucene/configs/_clucene-config-MSVC.h b/external/clucene/configs/_clucene-config-MSVC.h
new file mode 100644
index 000000000..09ef41cb6
--- /dev/null
+++ b/external/clucene/configs/_clucene-config-MSVC.h
@@ -0,0 +1,114 @@
+#ifndef _SRC_CLUCENE_INTERNAL_CLUCENE_CONFIG_H
+#define _SRC_CLUCENE_INTERNAL_CLUCENE_CONFIG_H 1
+
+/* src/shared/CLucene/_clucene-config.h.
+* Normally generated automatically at end of cmake,
+* but here in LibreOffice this actually is a copy of
+* clucene/configs/_clucene-config-MSVC.h.
+* These are internal definitions, and this file does not need to be distributed
+*/
+
+/* CMake will look for these functions: */
+#define _CL_HAVE_FUNCTION__VSNWPRINTF
+#define _CL_HAVE_FUNCTION__SNWPRINTF
+/* #undef _CL_HAVE_FUNCTION_WCSCASECMP */
+#define _CL_HAVE_FUNCTION_WCSCAT 1
+#define _CL_HAVE_FUNCTION_WCSCHR 1
+#define _CL_HAVE_FUNCTION_WCSCMP 1
+#define _CL_HAVE_FUNCTION_WCSCPY 1
+#define _CL_HAVE_FUNCTION_WCSCSPN 1
+#define _CL_HAVE_FUNCTION_WCSICMP
+#define _CL_HAVE_FUNCTION_WCSLEN 1
+#define _CL_HAVE_FUNCTION_WCSNCMP 1
+#define _CL_HAVE_FUNCTION_WCSNCPY 1
+#define _CL_HAVE_FUNCTION_WCSSTR 1
+#define _CL_HAVE_FUNCTION_WCSTOD 1
+#define _CL_HAVE_FUNCTION_WCSDUP 1
+/* #undef _CL_HAVE_FUNCTION_WCSTOLL */
+#define _CL_HAVE_FUNCTION_WCSUPR 1
+/* #undef _CL_HAVE_FUNCTION_GETTIMEOFDAY */
+#define _CL_HAVE_FUNCTION_MAPVIEWOFFILE 1
+
+/* #undef _CL_HAVE_FUNCTION_LLTOA */
+/* #undef _CL_HAVE_FUNCTION_LLTOW */
+#define _CL_HAVE_FUNCTION_PRINTF 1
+/* #undef _CL_HAVE_FUNCTION_SNPRINTF */
+/* #undef _CL_HAVE_FUNCTION_MMAP */
+#define _CL_HAVE_FUNCTION_STRLWR 1
+/* #undef _CL_HAVE_FUNCTION_STRTOLL */
+#define _CL_HAVE_FUNCTION_STRUPR 1
+/* #undef _CL_HAVE_FUNCTION_GETPAGESIZE */
+/* #undef _CL_HAVE_FUNCTION_USLEEP */
+#define _CL_HAVE_FUNCTION_SLEEP 1
+
+#define CL_MAX_PATH 4096
+//this is the max filename... for now its just the same,
+//but this could change, so we use a different name
+#define CL_MAX_NAME CL_MAX_PATH
+//this used to be CL_MAX_NAME * 32, but as Alex Hudson points out, this could come to be 128kb.
+//the above logic for CL_MAX_NAME should be correct enough to handle all file names
+#define CL_MAX_DIR CL_MAX_PATH
+
+/* undef _O_RANDOM _O_RANDOM */
+/* undef _O_BINARY _O_BINARY */
+/* undef _S_IREAD _S_IREAD */
+/* undef _S_IWRITE _S_IWRITE */
+/* #undef _timeb */
+
+#define _ILONG(x) x ## L
+#define _ILONGLONG(x) x ## LL
+
+#define fileStat _stati64
+#define cl_stat_t _stati64
+#define fileSize _filelengthi64
+#define fileSeek _lseeki64
+#define fileTell _telli64
+#define fileHandleStat _fstati64
+#define _realpath(rel,abs) ::_fullpath(abs,rel,CL_MAX_PATH)
+#define _rename rename
+/* undef _close _close */
+/* undef _read _read */
+#define _cl_open _open
+/* undef _write _write */
+/* undef _snprintf _snprintf */
+/* undef _mkdir _mkdir */
+/* undef _unlink _unlink */
+/* undef _ftime _ftime */
+#define SLEEPFUNCTION Sleep
+
+/* CMake will determine these specifics. Things like bugs, etc */
+
+/* Does not support new float byte<->float conversions */
+/* #undef _CL_HAVE_NO_FLOAT_BYTE */
+
+/* Define if recursive pthread mutexes are available */
+/* #undef _CL_HAVE_PTHREAD_MUTEX_RECURSIVE */
+
+/** define if you would like to force clucene to use the internal
+* character functions.
+* Tests may display unpredictable behaviour if this is not defined.
+*/
+#ifndef LUCENE_USE_INTERNAL_CHAR_FUNCTIONS
+ #define LUCENE_USE_INTERNAL_CHAR_FUNCTIONS 1
+#endif
+
+/** fix ansi for loop scope */
+#if 1==0
+ #define for if (0); else for
+#endif
+
+
+/* Compiler oddities */
+
+//not sure why, but cygwin reports _S_IREAD, but doesn't actually work...
+//TODO: make this work properly (this bit shouldn't be necessary)
+#ifdef __CYGWIN__
+ #define _S_IREAD 0333
+ #define _S_IWRITE 0333
+#endif
+
+#ifdef __BORLANDC__ //borland compiler
+ #define O_RANDOM 0
+#endif
+
+#endif
diff --git a/external/clucene/configs/_clucene-config-generic.h b/external/clucene/configs/_clucene-config-generic.h
new file mode 100644
index 000000000..42cf27c7f
--- /dev/null
+++ b/external/clucene/configs/_clucene-config-generic.h
@@ -0,0 +1,114 @@
+#ifndef _SRC_CLUCENE_INTERNAL_CLUCENE_CONFIG_H
+#define _SRC_CLUCENE_INTERNAL_CLUCENE_CONFIG_H 1
+
+/* src/shared/CLucene/_clucene-config.h.
+* Normally generated automatically at end of cmake,
+* but here in LibreOffice this actually is a copy of
+* clucene/configs/_clucene-config-generic.h.
+* These are internal definitions, and this file does not need to be distributed
+*/
+
+/* CMake will look for these functions: */
+/* #undef _CL_HAVE_FUNCTION__VSNWPRINTF */
+/* #undef _CL_HAVE_FUNCTION__SNWPRINTF */
+#define _CL_HAVE_FUNCTION_WCSCASECMP
+#define _CL_HAVE_FUNCTION_WCSCAT 1
+#define _CL_HAVE_FUNCTION_WCSCHR 1
+#define _CL_HAVE_FUNCTION_WCSCMP 1
+#define _CL_HAVE_FUNCTION_WCSCPY 1
+#define _CL_HAVE_FUNCTION_WCSCSPN 1
+/* #undef _CL_HAVE_FUNCTION_WCSICMP */
+#define _CL_HAVE_FUNCTION_WCSLEN 1
+#define _CL_HAVE_FUNCTION_WCSNCMP 1
+#define _CL_HAVE_FUNCTION_WCSNCPY 1
+#define _CL_HAVE_FUNCTION_WCSSTR 1
+#define _CL_HAVE_FUNCTION_WCSTOD 1
+/* #undef _CL_HAVE_FUNCTION_WCSDUP 1 */
+#define _CL_HAVE_FUNCTION_WCSTOLL 1
+/* #undef _CL_HAVE_FUNCTION_WCSUPR */
+#define _CL_HAVE_FUNCTION_GETTIMEOFDAY 1
+/* #undef _CL_HAVE_FUNCTION_MAPVIEWOFFILE */
+
+/* #undef _CL_HAVE_FUNCTION_LLTOA */
+/* #undef _CL_HAVE_FUNCTION_LLTOW */
+#define _CL_HAVE_FUNCTION_PRINTF 1
+#define _CL_HAVE_FUNCTION_SNPRINTF 1
+#define _CL_HAVE_FUNCTION_MMAP 1
+/* #undef _CL_HAVE_FUNCTION_STRLWR */
+#define _CL_HAVE_FUNCTION_STRTOLL 1
+/* #undef _CL_HAVE_FUNCTION_STRUPR */
+/* #undef _CL_HAVE_FUNCTION_GETPAGESIZE */
+#define _CL_HAVE_FUNCTION_USLEEP 1
+/* #undef _CL_HAVE_FUNCTION_SLEEP */
+
+#define CL_MAX_PATH 4096
+//this is the max filename... for now its just the same,
+//but this could change, so we use a different name
+#define CL_MAX_NAME CL_MAX_PATH
+//this used to be CL_MAX_NAME * 32, but as Alex Hudson points out, this could come to be 128kb.
+//the above logic for CL_MAX_NAME should be correct enough to handle all file names
+#define CL_MAX_DIR CL_MAX_PATH
+
+#define _O_RANDOM 0
+#define _O_BINARY 0
+#define _S_IREAD S_IREAD
+#define _S_IWRITE S_IWRITE
+#define _timeb timeb
+
+#define _ILONG(x) x ## L
+#define _ILONGLONG(x) x ## LL
+
+#define fileStat stat
+#define cl_stat_t stat
+#define fileSize CL_NS(util)::Misc::filelength
+#define fileSeek lseek
+#define fileTell(fhandle) fileSeek(fhandle, 0, SEEK_CUR)
+#define fileHandleStat fstat
+#define _realpath realpath
+#define _rename rename
+#define _close close
+#define _read read
+#define _cl_open open
+#define _write write
+#define _snprintf snprintf
+#define _mkdir(x) mkdir(x,0777)
+#define _unlink unlink
+#define _ftime ftime
+#define SLEEPFUNCTION usleep
+
+/* CMake will determine these specifics. Things like bugs, etc */
+
+/* Does not support new float byte<->float conversions */
+/* #undef _CL_HAVE_NO_FLOAT_BYTE */
+
+/* Define if recursive pthread mutexes are available */
+#define _CL_HAVE_PTHREAD_MUTEX_RECURSIVE 1
+
+/** define if you would like to force clucene to use the internal
+* character functions.
+* Tests may display unpredictable behaviour if this is not defined.
+*/
+#ifndef LUCENE_USE_INTERNAL_CHAR_FUNCTIONS
+ #define LUCENE_USE_INTERNAL_CHAR_FUNCTIONS 1
+#endif
+
+/** fix ansi for loop scope */
+#if 1==0
+ #define for if (0); else for
+#endif
+
+
+/* Compiler oddities */
+
+//not sure why, but cygwin reports _S_IREAD, but doesn't actually work...
+//TODO: make this work properly (this bit shouldn't be necessary)
+#ifdef __CYGWIN__
+ #define _S_IREAD 0333
+ #define _S_IWRITE 0333
+#endif
+
+#ifdef __BORLANDC__ //borland compiler
+ #define O_RANDOM 0
+#endif
+
+#endif
diff --git a/external/clucene/configs/clucene-config-GCC-atomic.h b/external/clucene/configs/clucene-config-GCC-atomic.h
new file mode 100644
index 000000000..3c034a1da
--- /dev/null
+++ b/external/clucene/configs/clucene-config-GCC-atomic.h
@@ -0,0 +1,150 @@
+#ifndef _SRC_CLUCENE_CLUCENE_CONFIG_H
+#define _SRC_CLUCENE_CLUCENE_CONFIG_H 1
+
+/* src/shared/CLucene/clucene-config.h.
+* Normally generated automatically at end of cmake,
+* but here in LibreOffice this actually is a copy of
+* clucene/configs/clucene-config-GCC-atomic.h.
+*/
+
+/* CMake will look for these headers: */
+#define _CL_HAVE_STRING_H 1
+#define _CL_HAVE_MEMORY_H 1
+#define _CL_HAVE_UNISTD_H 1
+/* #undef _CL_HAVE_IO_H */
+/* #undef _CL_HAVE_DIRECT_H */
+#define _CL_HAVE_DIRENT_H 1
+#define _CL_HAVE_SYS_DIR_H
+/* #undef _CL_HAVE_SYS_NDIR_H */
+#define _CL_HAVE_ERRNO_H 1
+#define _CL_HAVE_WCHAR_H 1
+#define _CL_HAVE_WCTYPE_H
+#define _CL_HAVE_CTYPE_H 1
+/* #undef _CL_HAVE_WINDOWS_H */
+/* #undef _CL_HAVE_WINDEF_H */
+#define _CL_HAVE_SYS_TYPES_H 1
+/* #undef _CL_HAVE_DLFCN_H */
+#define _CL_HAVE_EXT_HASH_MAP 1
+/* #undef _CL_HAVE_EXT_HASH_SET */
+#define _CL_HAVE_TR1_UNORDERED_MAP 1
+#define _CL_HAVE_TR1_UNORDERED_SET 1
+#define _CL_HAVE_HASH_MAP
+#define _CL_HAVE_HASH_SET
+/* #undef _CL_HAVE_NDIR_H */
+#define _CL_HAVE_SYS_STAT_H 1
+#define _CL_HAVE_SYS_TIMEB_H 1
+#define _CL_HAVE_SYS_TIME_H 1
+/* #undef _CL_HAVE_TCHAR_H */
+#define _CL_HAVE_SYS_MMAN_H 1
+/* #undef _CL_HAVE_WINERROR_H */
+#define _CL_HAVE_STDINT_H 1
+
+// our needed types
+/* undef int8_t int8_t */
+/* undef uint8_t uint8_t */
+/* undef int16_t int16_t */
+/* undef uint16_t uint16_t */
+/* undef int32_t int32_t */
+/* undef uint32_t uint32_t */
+/* undef int64_t int64_t */
+/* undef uint64_t uint64_t */
+
+/* undef float_t*/
+
+/* undef size_t size_t */
+
+/* tchar & _T definitions... */
+typedef wchar_t TCHAR;
+#define _T(x) L ## x
+
+/* CMake will determine these specifics. Things like bugs, etc */
+
+/* if we can't support the map/set hashing */
+/* #undef LUCENE_DISABLE_HASHING */
+
+/* Define if you have POSIX threads libraries and header files. */
+#define _CL_HAVE_PTHREAD 1
+
+/* Define if you have Win32 threads libraries and header files. */
+/* #undef _CL_HAVE_WIN32_THREADS */
+
+/* Define if we have gcc atomic functions */
+#define _CL_HAVE_GCC_ATOMIC_FUNCTIONS 1
+
+/* Define what eval method is required for float_t to be defined (for GCC). */
+/* #undef _FLT_EVAL_METHOD */
+
+/* If we use hashmaps, which namespace do we use: */
+#define CL_NS_HASHING(func) std::tr1::func
+/* If we use hashmaps, which classes do we use: */
+#define _CL_HASH_MAP unordered_map
+#define _CL_HASH_SET unordered_set
+
+/* define if the compiler implements namespaces */
+#define _CL_HAVE_NAMESPACES
+
+/* Defined if the snprintf overflow test fails */
+/* #undef _CL_HAVE_SNPRINTF_BUG */
+
+/* Defined if the swprintf test fails */
+/* #undef _CL_HAVE_SNWPRINTF_BUG */
+
+/* How to define a static const in a class */
+#define LUCENE_STATIC_CONSTANT(type, assignment) static const type assignment
+
+/* Define to the necessary symbol if this constant uses a non-standard name on
+ your system. */
+//todo: not checked
+/* #undef _CL_PTHREAD_CREATE_JOINABLE */
+
+/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
+//todo: not being checked for...
+/* #undef _CL_STAT_MACROS_BROKEN */
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+//not actually used for anything...
+//#define _CL_TIME_WITH_SYS_TIME 1
+
+/* Define that we will be using -fvisibility=hidden, and
+ * make public classes visible using __attribute__ ((visibility("default")))
+ */
+#define _CL_HAVE_GCCVISIBILITYPATCH 1
+
+
+/* Versions, etc */
+
+/* Name of package */
+#define _CL_PACKAGE "clucene-core"
+
+/* Version number of package */
+#define _CL_VERSION "2.3.3.4"
+
+/* So-Version number of package */
+#define _CL_SOVERSION "1"
+
+/* A comparable version number */
+#define _CL_INT_VERSION 2030304
+
+/* Configured options (from command line) */
+
+/* Forces into Ascii mode */
+/* #undef _ASCII */
+
+/* Conditional Debugging */
+/* #undef _CL__CND_DEBUG */
+
+/* debuging option */
+/* #undef _DEBUG */
+
+/* Disable multithreading */
+/* #undef _CL_DISABLE_MULTITHREADING */
+
+
+#ifdef __BORLANDC__ //borland compiler
+ //todo: bcc incorrectly detects this... fix this in cmake
+ #undef LUCENE_STATIC_CONSTANT
+ #define LUCENE_STATIC_CONSTANT(type, assignment) enum { assignment }
+#endif
+
+
+#endif
diff --git a/external/clucene/configs/clucene-config-MSVC.h b/external/clucene/configs/clucene-config-MSVC.h
new file mode 100644
index 000000000..5e22e7a7e
--- /dev/null
+++ b/external/clucene/configs/clucene-config-MSVC.h
@@ -0,0 +1,149 @@
+#ifndef _SRC_CLUCENE_CLUCENE_CONFIG_H
+#define _SRC_CLUCENE_CLUCENE_CONFIG_H 1
+
+/* src/shared/CLucene/clucene-config.h.
+* Normally generated automatically at end of cmake,
+* but here in LibreOffice this actually is a copy of
+* clucene/configs/clucene-config-MSVC.h.
+*/
+
+/* CMake will look for these headers: */
+#define _CL_HAVE_STRING_H 1
+#define _CL_HAVE_MEMORY_H 1
+/* #undef _CL_HAVE_UNISTD_H */
+#define _CL_HAVE_IO_H 1
+#define _CL_HAVE_DIRECT_H 1
+/* #undef _CL_HAVE_DIRENT_H */
+/* #undef _CL_HAVE_SYS_DIR_H */
+/* #undef _CL_HAVE_SYS_NDIR_H */
+#define _CL_HAVE_ERRNO_H 1
+#define _CL_HAVE_WCHAR_H 1
+#define _CL_HAVE_WCTYPE_H
+#define _CL_HAVE_CTYPE_H 1
+#define _CL_HAVE_WINDOWS_H 1
+/* #undef _CL_HAVE_WINDEF_H */
+#define _CL_HAVE_SYS_TYPES_H 1
+/* #undef _CL_HAVE_DLFCN_H */
+/* #undef _CL_HAVE_EXT_HASH_MAP */
+/* #undef _CL_HAVE_EXT_HASH_SET */
+/* #undef _CL_HAVE_TR1_UNORDERED_MAP */
+/* #undef _CL_HAVE_TR1_UNORDERED_SET */
+/* #undef _CL_HAVE_HASH_MAP */
+/* #undef _CL_HAVE_HASH_SET */
+/* #undef _CL_HAVE_NDIR_H */
+#define _CL_HAVE_SYS_STAT_H 1
+#define _CL_HAVE_SYS_TIMEB_H 1
+/* #undef _CL_HAVE_SYS_TIME_H */
+#define _CL_HAVE_TCHAR_H 1
+/* #undef _CL_HAVE_SYS_MMAN_H */
+#define _CL_HAVE_WINERROR_H 1
+/* #undef _CL_HAVE_STDINT_H */
+
+// our needed types
+typedef signed char int8_t;
+typedef unsigned char uint8_t;
+typedef signed short int16_t;
+typedef unsigned short uint16_t;
+typedef signed int int32_t;
+typedef unsigned int uint32_t;
+typedef signed long long int64_t;
+typedef unsigned long long uint64_t;
+
+typedef unsigned long _cl_dword_t;
+/* undef size_t size_t */
+
+/* tchar & _T definitions... */
+/* undef TCHAR TCHAR */
+/* #undef _T */
+
+/* CMake will determine these specifics. Things like bugs, etc */
+
+/* if we can't support the map/set hashing */
+/* #undef LUCENE_DISABLE_HASHING */
+
+/* Define if you have POSIX threads libraries and header files. */
+/* #undef _CL_HAVE_PTHREAD */
+
+/* Define if you have Win32 threads libraries and header files. */
+#define _CL_HAVE_WIN32_THREADS 1
+
+/* Define if we have gcc atomic functions */
+/* #undef _CL_HAVE_GCC_ATOMIC_FUNCTIONS */
+
+/* Define what eval method is required for float_t to be defined (for GCC). */
+/* #undef _FLT_EVAL_METHOD */
+
+/* If we use hashmaps, which namespace do we use: */
+#define CL_NS_HASHING(func)
+/* If we use hashmaps, which classes do we use: */
+#define _CL_HASH_MAP
+#define _CL_HASH_SET
+
+/* define if the compiler implements namespaces */
+#define _CL_HAVE_NAMESPACES
+
+/* Defined if the snprintf overflow test fails */
+/* #undef _CL_HAVE_SNPRINTF_BUG */
+
+/* Defined if the swprintf test fails */
+/* #undef _CL_HAVE_SNWPRINTF_BUG */
+
+/* How to define a static const in a class */
+#define LUCENE_STATIC_CONSTANT(type, assignment) static const type assignment
+
+/* Define to the necessary symbol if this constant uses a non-standard name on
+ your system. */
+//todo: not checked
+/* #undef _CL_PTHREAD_CREATE_JOINABLE */
+
+/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
+//todo: not being checked for...
+/* #undef _CL_STAT_MACROS_BROKEN */
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+//not actually used for anything...
+/* #undef _CL_TIME_WITH_SYS_TIME */
+
+/* Define that we will be using -fvisibility=hidden, and
+ * make public classes visible using __attribute__ ((visibility("default")))
+ */
+/* #undef _CL_HAVE_GCCVISIBILITYPATCH */
+
+
+/* Versions, etc */
+
+/* Name of package */
+#define _CL_PACKAGE "clucene-core"
+
+/* Version number of package */
+#define _CL_VERSION "2.3.3.4"
+
+/* So-Version number of package */
+#define _CL_SOVERSION "1"
+
+/* A comparable version number */
+#define _CL_INT_VERSION 2030304
+
+/* Configured options (from command line) */
+
+/* Forces into Ascii mode */
+/* #undef _ASCII */
+
+/* Conditional Debugging */
+/* #undef _CL__CND_DEBUG */
+
+/* debuging option */
+/* #undef _DEBUG */
+
+/* Disable multithreading */
+/* #undef _CL_DISABLE_MULTITHREADING */
+
+
+#ifdef __BORLANDC__ //borland compiler
+ //todo: bcc incorrectly detects this... fix this in cmake
+ #undef LUCENE_STATIC_CONSTANT
+ #define LUCENE_STATIC_CONSTANT(type, assignment) enum { assignment }
+#endif
+
+
+#endif
diff --git a/external/clucene/configs/clucene-config-generic.h b/external/clucene/configs/clucene-config-generic.h
new file mode 100644
index 000000000..b84dd4bc0
--- /dev/null
+++ b/external/clucene/configs/clucene-config-generic.h
@@ -0,0 +1,150 @@
+#ifndef _SRC_CLUCENE_CLUCENE_CONFIG_H
+#define _SRC_CLUCENE_CLUCENE_CONFIG_H 1
+
+/* src/shared/CLucene/clucene-config.h.
+* Normally generated automatically at end of cmake,
+* but here in LibreOffice this actually is a copy of
+* clucene/configs/clucene-config-generic.h.
+*/
+
+/* CMake will look for these headers: */
+#define _CL_HAVE_STRING_H 1
+#define _CL_HAVE_MEMORY_H 1
+#define _CL_HAVE_UNISTD_H 1
+/* #undef _CL_HAVE_IO_H */
+/* #undef _CL_HAVE_DIRECT_H */
+#define _CL_HAVE_DIRENT_H 1
+#define _CL_HAVE_SYS_DIR_H
+/* #undef _CL_HAVE_SYS_NDIR_H */
+#define _CL_HAVE_ERRNO_H 1
+#define _CL_HAVE_WCHAR_H 1
+#define _CL_HAVE_WCTYPE_H
+#define _CL_HAVE_CTYPE_H 1
+/* #undef _CL_HAVE_WINDOWS_H */
+/* #undef _CL_HAVE_WINDEF_H */
+#define _CL_HAVE_SYS_TYPES_H 1
+/* #undef _CL_HAVE_DLFCN_H */
+#define _CL_HAVE_EXT_HASH_MAP 1
+/* #undef _CL_HAVE_EXT_HASH_SET */
+#define _CL_HAVE_TR1_UNORDERED_MAP 1
+#define _CL_HAVE_TR1_UNORDERED_SET 1
+#define _CL_HAVE_HASH_MAP
+#define _CL_HAVE_HASH_SET
+/* #undef _CL_HAVE_NDIR_H */
+#define _CL_HAVE_SYS_STAT_H 1
+#define _CL_HAVE_SYS_TIMEB_H 1
+#define _CL_HAVE_SYS_TIME_H 1
+/* #undef _CL_HAVE_TCHAR_H */
+#define _CL_HAVE_SYS_MMAN_H 1
+/* #undef _CL_HAVE_WINERROR_H */
+#define _CL_HAVE_STDINT_H 1
+
+// our needed types
+/* undef int8_t int8_t */
+/* undef uint8_t uint8_t */
+/* undef int16_t int16_t */
+/* undef uint16_t uint16_t */
+/* undef int32_t int32_t */
+/* undef uint32_t uint32_t */
+/* undef int64_t int64_t */
+/* undef uint64_t uint64_t */
+
+/* undef float_t*/
+
+/* undef size_t size_t */
+
+/* tchar & _T definitions... */
+typedef wchar_t TCHAR;
+#define _T(x) L ## x
+
+/* CMake will determine these specifics. Things like bugs, etc */
+
+/* if we can't support the map/set hashing */
+/* #undef LUCENE_DISABLE_HASHING */
+
+/* Define if you have POSIX threads libraries and header files. */
+#define _CL_HAVE_PTHREAD 1
+
+/* Define if you have Win32 threads libraries and header files. */
+/* #undef _CL_HAVE_WIN32_THREADS */
+
+/* Define if we have gcc atomic functions */
+/* #undef _CL_HAVE_GCC_ATOMIC_FUNCTIONS */
+
+/* Define what eval method is required for float_t to be defined (for GCC). */
+/* #undef _FLT_EVAL_METHOD */
+
+/* If we use hashmaps, which namespace do we use: */
+#define CL_NS_HASHING(func) std::tr1::func
+/* If we use hashmaps, which classes do we use: */
+#define _CL_HASH_MAP unordered_map
+#define _CL_HASH_SET unordered_set
+
+/* define if the compiler implements namespaces */
+#define _CL_HAVE_NAMESPACES
+
+/* Defined if the snprintf overflow test fails */
+/* #undef _CL_HAVE_SNPRINTF_BUG */
+
+/* Defined if the swprintf test fails */
+/* #undef _CL_HAVE_SNWPRINTF_BUG */
+
+/* How to define a static const in a class */
+#define LUCENE_STATIC_CONSTANT(type, assignment) static const type assignment
+
+/* Define to the necessary symbol if this constant uses a non-standard name on
+ your system. */
+//todo: not checked
+/* #undef _CL_PTHREAD_CREATE_JOINABLE */
+
+/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
+//todo: not being checked for...
+/* #undef _CL_STAT_MACROS_BROKEN */
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+//not actually used for anything...
+//#define _CL_TIME_WITH_SYS_TIME 1
+
+/* Define that we will be using -fvisibility=hidden, and
+ * make public classes visible using __attribute__ ((visibility("default")))
+ */
+#define _CL_HAVE_GCCVISIBILITYPATCH 1
+
+
+/* Versions, etc */
+
+/* Name of package */
+#define _CL_PACKAGE "clucene-core"
+
+/* Version number of package */
+#define _CL_VERSION "2.3.3.4"
+
+/* So-Version number of package */
+#define _CL_SOVERSION "1"
+
+/* A comparable version number */
+#define _CL_INT_VERSION 2030304
+
+/* Configured options (from command line) */
+
+/* Forces into Ascii mode */
+/* #undef _ASCII */
+
+/* Conditional Debugging */
+/* #undef _CL__CND_DEBUG */
+
+/* debuging option */
+/* #undef _DEBUG */
+
+/* Disable multithreading */
+/* #undef _CL_DISABLE_MULTITHREADING */
+
+
+#ifdef __BORLANDC__ //borland compiler
+ //todo: bcc incorrectly detects this... fix this in cmake
+ #undef LUCENE_STATIC_CONSTANT
+ #define LUCENE_STATIC_CONSTANT(type, assignment) enum { assignment }
+#endif
+
+
+#endif
diff --git a/external/clucene/inc/pch/precompiled_clucene.cxx b/external/clucene/inc/pch/precompiled_clucene.cxx
new file mode 100644
index 000000000..98e81ca8e
--- /dev/null
+++ b/external/clucene/inc/pch/precompiled_clucene.cxx
@@ -0,0 +1,12 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "precompiled_clucene.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/external/clucene/inc/pch/precompiled_clucene.hxx b/external/clucene/inc/pch/precompiled_clucene.hxx
new file mode 100644
index 000000000..f68f71e87
--- /dev/null
+++ b/external/clucene/inc/pch/precompiled_clucene.hxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+/*
+ This file has been autogenerated by update_pch.sh. It is possible to edit it
+ manually (such as when an include file has been moved/renamed/removed). All such
+ manual changes will be rewritten by the next run of update_pch.sh (which presumably
+ also fixes all possible problems, so it's usually better to use it).
+
+ Generated on 2019-10-13 10:16:55 using:
+ ./bin/update_pch external/clucene clucene --cutoff=1 --exclude:system --include:module --include:local
+
+ If after updating build fails, use the following command to locate conflicting headers:
+ ./bin/update_pch_bisect ./external/clucene/inc/pch/precompiled_clucene.hxx "make external/clucene.build" --find-conflicts
+*/
+
+#if PCH_LEVEL >= 1
+#include <algorithm>
+#include <assert.h>
+#include <cctype>
+#include <climits>
+#include <errno.h>
+#include <fcntl.h>
+#include <iostream>
+#include <limits.h>
+#include <map>
+#include <sstream>
+#include <zlib.h>
+#endif // PCH_LEVEL >= 1
+#if PCH_LEVEL >= 2
+#endif // PCH_LEVEL >= 2
+#if PCH_LEVEL >= 3
+#include <CLucene/_ApiHeader.h>
+#include <CLucene/_SharedHeader.h>
+#include <CLucene/analysis/AnalysisHeader.h>
+#include <CLucene/analysis/Analyzers.h>
+#include <CLucene/analysis/cjk/CJKAnalyzer.h>
+#include <CLucene/analysis/standard/StandardFilter.h>
+#include <CLucene/analysis/standard/StandardTokenizer.h>
+#include <CLucene/document/DateField.h>
+#include <CLucene/document/DateTools.h>
+#include <CLucene/document/Document.h>
+#include <CLucene/document/Field.h>
+#include <CLucene/document/FieldSelector.h>
+#include <CLucene/index/IndexReader.h>
+#include <CLucene/index/IndexWriter.h>
+#include <CLucene/index/MergePolicy.h>
+#include <CLucene/index/MultipleTermPositions.h>
+#include <CLucene/index/Term.h>
+#include <CLucene/index/TermVector.h>
+#include <CLucene/index/Terms.h>
+#include <CLucene/index/_IndexFileNameFilter.h>
+#include <CLucene/index/_IndexFileNames.h>
+#include <CLucene/index/_Term.h>
+#include <CLucene/search/BooleanClause.h>
+#include <CLucene/search/BooleanQuery.h>
+#include <CLucene/search/ConstantScoreQuery.h>
+#include <CLucene/search/Explanation.h>
+#include <CLucene/search/FieldCache.h>
+#include <CLucene/search/FieldSortedHitQueue.h>
+#include <CLucene/search/FuzzyQuery.h>
+#include <CLucene/search/IndexSearcher.h>
+#include <CLucene/search/MatchAllDocsQuery.h>
+#include <CLucene/search/MultiPhraseQuery.h>
+#include <CLucene/search/PhraseQuery.h>
+#include <CLucene/search/PrefixQuery.h>
+#include <CLucene/search/Query.h>
+#include <CLucene/search/RangeQuery.h>
+#include <CLucene/search/Scorer.h>
+#include <CLucene/search/SearchHeader.h>
+#include <CLucene/search/Similarity.h>
+#include <CLucene/search/Sort.h>
+#include <CLucene/search/TermQuery.h>
+#include <CLucene/search/WildcardQuery.h>
+#include <CLucene/search/spans/Spans.h>
+#include <CLucene/snowball/SnowballFilter.h>
+#include <CLucene/store/Directory.h>
+#include <CLucene/store/FSDirectory.h>
+#include <CLucene/store/IndexInput.h>
+#include <CLucene/store/IndexOutput.h>
+#include <CLucene/store/Lock.h>
+#include <CLucene/store/LockFactory.h>
+#include <CLucene/store/_Lock.h>
+#include <CLucene/store/_RAMDirectory.h>
+#include <CLucene/util/Array.h>
+#include <CLucene/util/BitSet.h>
+#include <CLucene/util/CLStreams.h>
+#include <CLucene/util/Misc.h>
+#include <CLucene/util/PriorityQueue.h>
+#include <CLucene/util/StringBuffer.h>
+#include <CLucene/util/VoidList.h>
+#include <CLucene/util/_Arrays.h>
+#include <CLucene/util/_FastCharStream.h>
+#include <CLucene/util/_MD5Digester.h>
+#include <CLucene/util/_StringIntern.h>
+#include <CLucene/util/_ThreadLocal.h>
+#include <CLucene/util/dirent.h>
+#endif // PCH_LEVEL >= 3
+#if PCH_LEVEL >= 4
+#endif // PCH_LEVEL >= 4
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/external/clucene/patches/binary_function.patch b/external/clucene/patches/binary_function.patch
new file mode 100644
index 000000000..5b6f8ece9
--- /dev/null
+++ b/external/clucene/patches/binary_function.patch
@@ -0,0 +1,34 @@
+--- src/core/CLucene/util/Equators.h
++++ src/core/CLucene/util/Equators.h
+@@ -22,19 +22,19 @@
+ /** @internal */
+ class CLUCENE_INLINE_EXPORT Equals{
+ public:
+- class CLUCENE_INLINE_EXPORT Int32:public CL_NS_STD(binary_function)<const int32_t*,const int32_t*,bool>
++ class CLUCENE_INLINE_EXPORT Int32
+ {
+ public:
+ bool operator()( const int32_t val1, const int32_t val2 ) const;
+ };
+
+- class CLUCENE_INLINE_EXPORT Char:public CL_NS_STD(binary_function)<const char*,const char*,bool>
++ class CLUCENE_INLINE_EXPORT Char
+ {
+ public:
+ bool operator()( const char* val1, const char* val2 ) const;
+ };
+ #ifdef _UCS2
+- class CLUCENE_INLINE_EXPORT WChar: public CL_NS_STD(binary_function)<const wchar_t*,const wchar_t*,bool>
++ class CLUCENE_INLINE_EXPORT WChar
+ {
+ public:
+ bool operator()( const wchar_t* val1, const wchar_t* val2 ) const;
+@@ -48,7 +48,7 @@
+
+
+ template<typename _cl>
+- class CLUCENE_INLINE_EXPORT Void:public CL_NS_STD(binary_function)<const void*,const void*,bool>
++ class CLUCENE_INLINE_EXPORT Void
+ {
+ public:
+ bool operator()( _cl* val1, _cl* val2 ) const{
diff --git a/external/clucene/patches/c++20.patch b/external/clucene/patches/c++20.patch
new file mode 100644
index 000000000..c982e861e
--- /dev/null
+++ b/external/clucene/patches/c++20.patch
@@ -0,0 +1,11 @@
+--- src/core/CLucene/util/_bufferedstream.h
++++ src/core/CLucene/util/_bufferedstream.h
+@@ -68,7 +68,7 @@
+ void setMinBufSize(int32_t s) {
+ buffer.makeSpace(s);
+ }
+- BufferedStreamImpl<T>();
++ BufferedStreamImpl();
+ public:
+ int32_t read(const T*& start, int32_t min, int32_t max);
+ int64_t reset(int64_t pos);
diff --git a/external/clucene/patches/clucene-aix.patch b/external/clucene/patches/clucene-aix.patch
new file mode 100644
index 000000000..2b796fa45
--- /dev/null
+++ b/external/clucene/patches/clucene-aix.patch
@@ -0,0 +1,40 @@
+diff -rc clucene.orig/src/core/CLucene/store/MMapInput.cpp clucene/src/core/CLucene/store/MMapInput.cpp
+*** src/core/CLucene/store/MMapInput.cpp Wed Apr 10 10:57:37 2013
+--- src/core/CLucene/store/MMapInput.cpp Wed Apr 10 10:58:30 2013
+***************
+*** 115,121 ****
+ {
+ }
+
+! bool MMapIndexInput::open(const char* path, IndexInput*& ret, CLuceneError& error, int32_t __bufferSize ) {
+
+ //Func - Constructor.
+ // Opens the file named path
+--- 115,121 ----
+ {
+ }
+
+! bool MMapIndexInput::Open(const char* path, IndexInput*& ret, CLuceneError& error, int32_t __bufferSize ) {
+
+ //Func - Constructor.
+ // Opens the file named path
+diff -rc clucene.orig/src/core/CLucene/store/_MMapIndexInput.h clucene/src/core/CLucene/store/_MMapIndexInput.h
+*** src/core/CLucene/store/_MMapIndexInput.h Wed Apr 10 10:57:37 2013
+--- src/core/CLucene/store/_MMapIndexInput.h Wed Apr 10 10:58:53 2013
+***************
+*** 18,24 ****
+ MMapIndexInput(const MMapIndexInput& clone);
+ MMapIndexInput(Internal* _internal);
+ public:
+! static bool open(const char* path, IndexInput*& ret, CLuceneError& error, int32_t __bufferSize);
+
+ ~MMapIndexInput();
+ IndexInput* clone() const;
+--- 18,24 ----
+ MMapIndexInput(const MMapIndexInput& clone);
+ MMapIndexInput(Internal* _internal);
+ public:
+! static bool Open(const char* path, IndexInput*& ret, CLuceneError& error, int32_t __bufferSize);
+
+ ~MMapIndexInput();
+ IndexInput* clone() const;
diff --git a/external/clucene/patches/clucene-asan.patch b/external/clucene/patches/clucene-asan.patch
new file mode 100644
index 000000000..51adfad4a
--- /dev/null
+++ b/external/clucene/patches/clucene-asan.patch
@@ -0,0 +1,26 @@
+--- src/core/CLucene/index/IndexWriter.cpp
++++ src/core/CLucene/index/IndexWriter.cpp
+@@ -53,7 +53,6 @@
+
+ DEFINE_MUTEX(IndexWriter::MESSAGE_ID_LOCK)
+ int32_t IndexWriter::MESSAGE_ID = 0;
+-const int32_t IndexWriter::MAX_TERM_LENGTH = DocumentsWriter::MAX_TERM_LENGTH;
+
+ class IndexWriter::Internal{
+ public:
+--- src/core/CLucene/index/IndexWriter.h
++++ src/core/CLucene/index/IndexWriter.h
+@@ -384,13 +384,6 @@
+ */
+ static const int32_t DEFAULT_MAX_MERGE_DOCS;
+
+- /**
+- * Absolute hard maximum length for a term. If a term
+- * arrives from the analyzer longer than this length, it
+- * is skipped and a message is printed to infoStream, if
+- * set (see {@link #setInfoStream}).
+- */
+- static const int32_t MAX_TERM_LENGTH;
+
+
+ /* Determines how often segment indices are merged by addDocument(). With
diff --git a/external/clucene/patches/clucene-debug.patch b/external/clucene/patches/clucene-debug.patch
new file mode 100644
index 000000000..640454e2f
--- /dev/null
+++ b/external/clucene/patches/clucene-debug.patch
@@ -0,0 +1,11 @@
+--- src/core/CLucene/index/TermInfosReader.cpp
++++ src/core/CLucene/index/TermInfosReader.cpp
+@@ -111,7 +111,7 @@
+ //destroy their elements
+ #ifdef _DEBUG
+ for ( int32_t i=0; i<indexTermsLength;++i ){
+- indexTerms[i].__cl_refcount--;
++ indexTerms[i].__cl_decref();
+ }
+ #endif
+ //Delete the arrays
diff --git a/external/clucene/patches/clucene-git1-win64.patch b/external/clucene/patches/clucene-git1-win64.patch
new file mode 100644
index 000000000..dc07d380b
--- /dev/null
+++ b/external/clucene/patches/clucene-git1-win64.patch
@@ -0,0 +1,45 @@
+--- src/shared/CLucene/config/threads.cpp 2013-06-06 16:25:23.014622397 +0200
++++ src/shared/CLucene/config/threads.cpp 2013-06-06 16:33:35.326048842 +0200
+@@ -63,14 +63,14 @@
+ }
+
+ int32_t mutex_thread::atomic_increment(_LUCENE_ATOMIC_INT *theInteger){
+-#ifdef _M_X64
++#ifdef _WIN64
+ return _InterlockedIncrement64(theInteger);
+ #else
+ return InterlockedIncrement(theInteger);
+ #endif
+ }
+ int32_t mutex_thread::atomic_decrement(_LUCENE_ATOMIC_INT *theInteger){
+-#ifdef _M_X64
++#ifdef _WIN64
+ return _InterlockedDecrement64(theInteger);
+ #else
+ return InterlockedDecrement(theInteger);
+--- src/shared/CLucene/config/_threads.h 2013-06-06 16:25:23.013622420 +0200
++++ src/shared/CLucene/config/_threads.h 2013-06-06 16:29:39.152601408 +0200
+@@ -34,9 +34,9 @@
+
+ __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId();
+
+-#ifdef _M_X64
+- __declspec(dllimport) long long __stdcall _InterlockedIncrement64(__inout long long volatile*);
+- __declspec(dllimport) long long __stdcall _InterlockedDecrement64(__inout long long volatile*);
++#ifdef _WIN64
++ long long __stdcall _InterlockedIncrement64(long long volatile*);
++ long long __stdcall _InterlockedDecrement64(long long volatile*);
+ #else
+ __declspec(dllimport) long __stdcall InterlockedIncrement(long volatile*);
+ __declspec(dllimport) long __stdcall InterlockedDecrement(long volatile*);
+--- src/shared/CLucene/LuceneThreads.h 2013-06-06 16:25:23.014622397 +0200
++++ src/shared/CLucene/LuceneThreads.h 2013-06-06 16:37:45.490166481 +0200
+@@ -101,7 +101,7 @@
+
+ #define _LUCENE_ATOMIC_INC(theInteger) CL_NS(util)::mutex_thread::atomic_increment(theInteger)
+ #define _LUCENE_ATOMIC_DEC(theInteger) CL_NS(util)::mutex_thread::atomic_decrement(theInteger)
+-#ifdef _M_X64
++#ifdef _WIN64
+ #define _LUCENE_ATOMIC_INT long long
+ #else
+ #define _LUCENE_ATOMIC_INT long
diff --git a/external/clucene/patches/clucene-libcpp.patch b/external/clucene/patches/clucene-libcpp.patch
new file mode 100644
index 000000000..35235212c
--- /dev/null
+++ b/external/clucene/patches/clucene-libcpp.patch
@@ -0,0 +1,42 @@
+--- src/shared/CLucene/LuceneThreads.h
++++ src/shared/CLucene/LuceneThreads.h
+@@ -7,6 +7,7 @@
+ #ifndef _LuceneThreads_h
+ #define _LuceneThreads_h
+
++#include "CLucene/config/_threads.h"
+
+ CL_NS_DEF(util)
+ class CLuceneThreadIdCompare;
+--- src/core/CLucene/util/VoidMap.h
++++ src/core/CLucene/util/VoidMap.h
+@@ -11,8 +11,13 @@
+ #include "CLucene/LuceneThreads.h"
+
+ #if defined(_CL_HAVE_TR1_UNORDERED_MAP) && defined(_CL_HAVE_TR1_UNORDERED_SET)
++#ifdef _LIBCPP_VERSION
++ #include <unordered_map>
++ #include <unordered_set>
++#else
+ #include <tr1/unordered_map>
+ #include <tr1/unordered_set>
++#endif
+ #elif defined(_CL_HAVE_HASH_MAP) && defined(_CL_HAVE_HASH_SET)
+ //hashing is all or nothing!
+ #include <hash_map>
+--- src/shared/CLucene/config/repl_tchar.h
++++ src/shared/CLucene/config/repl_tchar.h
+@@ -36,8 +36,13 @@
+ #define _tcsncpy wcsncpy //copy a specified amount of one string to another string.
+ #define _tcscat wcscat //copy a string onto the end of the other string
+ #define _tcsncat wcsncat
++#if defined(_LIBCPP_VERSION) && defined(__APPLE__)
++ #define _tcschr ::wcschr //find location of one character
++ #define _tcsstr ::wcsstr //find location of a string
++#else
+ #define _tcschr wcschr //find location of one character
+ #define _tcsstr wcsstr //find location of a string
++#endif
+ #define _tcslen wcslen //get length of a string
+ #define _tcscmp wcscmp //case sensitive compare two strings
+ #define _tcsncmp wcsncmp //case sensitive compare two strings
diff --git a/external/clucene/patches/clucene-mixes-uptemplate-parameter-msvc-14.patch b/external/clucene/patches/clucene-mixes-uptemplate-parameter-msvc-14.patch
new file mode 100644
index 000000000..0c9cd0a1f
--- /dev/null
+++ b/external/clucene/patches/clucene-mixes-uptemplate-parameter-msvc-14.patch
@@ -0,0 +1,53 @@
+diff -ru clucene.org/src/core/CLucene/util/VoidMap.h clucene/src/core/CLucene/util/VoidMap.h
+--- src/core/CLucene/util/VoidMap.h 2015-07-24 20:11:28.892997236 +0200
++++ src/core/CLucene/util/VoidMap.h 2015-07-24 20:21:17.290990623 +0200
+@@ -154,16 +154,16 @@
+
+ //a CLSet with CLHashMap traits
+ template<typename _kt, typename _vt,
+- typename _Compare,
++ typename Compare,
+ typename _EqualDummy,
+ typename _KeyDeletor=CL_NS(util)::Deletor::Dummy,
+ typename _ValueDeletor=CL_NS(util)::Deletor::Dummy>
+ class CLUCENE_INLINE_EXPORT CLHashMap:public __CLMap<_kt,_vt,
+- CL_NS_STD(map)<_kt,_vt, _Compare>,
++ CL_NS_STD(map)<_kt,_vt, Compare>,
+ _KeyDeletor,_ValueDeletor>
+ {
+- typedef typename CL_NS_STD(map)<_kt,_vt,_Compare> _base;
+- typedef __CLMap<_kt, _vt, CL_NS_STD(map)<_kt,_vt, _Compare>,
++ typedef typename CL_NS_STD(map)<_kt,_vt,Compare> _base;
++ typedef __CLMap<_kt, _vt, CL_NS_STD(map)<_kt,_vt, Compare>,
+ _KeyDeletor,_ValueDeletor> _this;
+ public:
+ CLHashMap ( const bool deleteKey=false, const bool deleteValue=false )
+@@ -260,15 +260,15 @@
+ //A collection that contains no duplicates
+ //does not guarantee that the order will remain constant over time
+ template<typename _kt, typename _vt,
+- typename _Compare,
++ typename Compare,
+ typename _KeyDeletor=CL_NS(util)::Deletor::Dummy,
+ typename _ValueDeletor=CL_NS(util)::Deletor::Dummy>
+ class CLUCENE_INLINE_EXPORT CLSet:public __CLMap<_kt,_vt,
+- CL_NS_STD(map)<_kt,_vt, _Compare>,
++ CL_NS_STD(map)<_kt,_vt, Compare>,
+ _KeyDeletor,_ValueDeletor>
+ {
+- typedef typename CL_NS_STD(map)<_kt,_vt,_Compare> _base;
+- typedef __CLMap<_kt, _vt, CL_NS_STD(map)<_kt,_vt, _Compare>,
++ typedef typename CL_NS_STD(map)<_kt,_vt,Compare> _base;
++ typedef __CLMap<_kt, _vt, CL_NS_STD(map)<_kt,_vt, Compare>,
+ _KeyDeletor,_ValueDeletor> _this;
+ public:
+ CLSet ( const bool deleteKey=false, const bool deleteValue=false )
+@@ -294,7 +294,7 @@
+
+ //A collection that can contains duplicates
+ template<typename _kt, typename _vt,
+- typename _Compare,
++ typename Compare,
+ typename _KeyDeletor=CL_NS(util)::Deletor::Dummy,
+ typename _ValueDeletor=CL_NS(util)::Deletor::Dummy>
+ class CLUCENE_INLINE_EXPORT CLMultiMap:public __CLMap<_kt,_vt,
diff --git a/external/clucene/patches/clucene-multimap-put.patch b/external/clucene/patches/clucene-multimap-put.patch
new file mode 100644
index 000000000..bfff31a87
--- /dev/null
+++ b/external/clucene/patches/clucene-multimap-put.patch
@@ -0,0 +1,9 @@
+--- src/core/CLucene/util/VoidMap.h
++++ src/core/CLucene/util/VoidMap.h
+@@ -316,6 +316,7 @@ public:
+ if ( _this::dk || _this::dv )
+ _this::remove(k);
+
++ (*this)[k] = v;
+ }
+ };
diff --git a/external/clucene/patches/clucene-mutex.patch b/external/clucene/patches/clucene-mutex.patch
new file mode 100644
index 000000000..2a6b7d2d3
--- /dev/null
+++ b/external/clucene/patches/clucene-mutex.patch
@@ -0,0 +1,13 @@
+--- src/core/CLucene/store/FSDirectory.cpp
++++ src/core/CLucene/store/FSDirectory.cpp
+@@ -219,9 +219,8 @@
+ _CLDECDELETE(handle);
+
+ //printf("handle=%d\n", handle->__cl_refcount);
+- if ( dounlock ){
+ mutex->unlock();
+- }else{
++ if ( !dounlock ){
+ delete mutex;
+ }
+ }
diff --git a/external/clucene/patches/clucene-narrowing-conversions.patch b/external/clucene/patches/clucene-narrowing-conversions.patch
new file mode 100644
index 000000000..64065acb1
--- /dev/null
+++ b/external/clucene/patches/clucene-narrowing-conversions.patch
@@ -0,0 +1,36 @@
+--- src/core/CLucene/queryParser/QueryParser.cpp.sav 2011-03-17 01:21:07.000000000 +0100
++++ src/core/CLucene/queryParser/QueryParser.cpp 2012-03-09 18:20:58.000000000 +0100
+@@ -79,7 +79,7 @@
+ _T("<RANGEEX_GOOP>")
+ };
+
+-const int32_t QueryParser::jj_la1_0[] = {0x180,0x180,0xe00,0xe00,0x1f69f80,0x48000,0x10000,0x1f69000,0x1348000,0x80000,0x80000,0x10000,0x18000000,0x2000000,0x18000000,0x10000,0x80000000,0x20000000,0x80000000,0x10000,0x80000,0x10000,0x1f68000};
++const int32_t QueryParser::jj_la1_0[] = {0x180,0x180,0xe00,0xe00,0x1f69f80,0x48000,0x10000,0x1f69000,0x1348000,0x80000,0x80000,0x10000,0x18000000,0x2000000,0x18000000,0x10000,int32_t(0x80000000),0x20000000,int32_t(0x80000000),0x10000,0x80000,0x10000,0x1f68000};
+ const int32_t QueryParser::jj_la1_1[] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x1,0x0,0x0,0x0,0x0};
+
+ struct QueryParser::JJCalls {
+--- src/core/CLucene/queryParser/QueryParserTokenManager.cpp.sav 2011-03-17 01:21:07.000000000 +0100
++++ src/core/CLucene/queryParser/QueryParserTokenManager.cpp 2012-03-09 18:20:24.000000000 +0100
+@@ -15,9 +15,9 @@
+
+ CL_NS_DEF(queryParser)
+
+-const int64_t QueryParserTokenManager::jjbitVec2[]={0x0L, 0x0L, _ILONGLONG(0xffffffffffffffff), _ILONGLONG(0xffffffffffffffff)};
++const int64_t QueryParserTokenManager::jjbitVec2[]={0x0L, 0x0L, int64_t(_ILONGLONG(0xffffffffffffffff)), int64_t(_ILONGLONG(0xffffffffffffffff))};
+ const int64_t QueryParserTokenManager::jjbitVec0[] = {
+- _ILONGLONG(0xfffffffffffffffe), _ILONGLONG(0xffffffffffffffff), _ILONGLONG(0xffffffffffffffff), _ILONGLONG(0xffffffffffffffff)
++ int64_t(_ILONGLONG(0xfffffffffffffffe)), int64_t(_ILONGLONG(0xffffffffffffffff)), int64_t(_ILONGLONG(0xffffffffffffffff)), int64_t(_ILONGLONG(0xffffffffffffffff))
+ };
+ const int32_t QueryParserTokenManager::jjnextStates[]={
+ 15, 17, 18, 29, 32, 23, 33, 30, 20, 21, 32, 23, 33, 31, 34, 27,
+--- src/core/CLucene/queryParser/legacy/Lexer.cpp.sav 2013-03-01 09:25:18.000000000 +0100
++++ src/core/CLucene/queryParser/legacy/Lexer.cpp 09:25:12.000000000 +0100
+@@ -117,7 +117,7 @@ bool Lexer::GetNextToken(QueryToken* tok
+ if( _istspace(ch)!=0 ) {
+ continue;
+ }
+- TCHAR buf[2] = {ch,'\0'};
++ TCHAR buf[2] = {TCHAR(ch),'\0'};
+ switch(ch) {
+ case '+':
+ token->set(buf, QueryToken::PLUS);
diff --git a/external/clucene/patches/clucene-nullptr.patch b/external/clucene/patches/clucene-nullptr.patch
new file mode 100644
index 000000000..a32ddb870
--- /dev/null
+++ b/external/clucene/patches/clucene-nullptr.patch
@@ -0,0 +1,22 @@
+--- src/core/CLucene/index/DocumentsWriter.cpp 2011-03-16 20:21:07.000000000 -0400
++++ src/core/CLucene/index/DocumentsWriter.cpp 2012-07-31 18:52:09.000000000 -0400
+@@ -125,7 +125,7 @@
+ if (this->postingsFreeListDW.values){
+ if (this->postingsFreeCountDW < this->postingsFreeListDW.length) {
+ memset(this->postingsFreeListDW.values + this->postingsFreeCountDW
+- , NULL
++ , 0
+ , sizeof(Posting*));
+ }
+ postingsFreeListDW.deleteUntilNULL();
+--- src/core/CLucene/util/VoidMap.h 2012-07-31 18:13:08.000000000 -0400
++++ src/core/CLucene/util/VoidMap.h 2012-07-31 18:42:54.000000000 -0400
+@@ -83,7 +83,7 @@
+ _vt get( _kt k) const {
+ const_iterator itr = base::find(k);
+ if ( itr==base::end() )
+- return (_vt)NULL;
++ return static_cast<_vt>(0);
+ else
+ return itr->second;
+ }
diff --git a/external/clucene/patches/clucene-ub.patch b/external/clucene/patches/clucene-ub.patch
new file mode 100644
index 000000000..e1ca3131f
--- /dev/null
+++ b/external/clucene/patches/clucene-ub.patch
@@ -0,0 +1,33 @@
+--- src/core/CLucene/index/DocumentsWriterThreadState.cpp
++++ src/core/CLucene/index/DocumentsWriterThreadState.cpp
+@@ -994,7 +994,7 @@
+ const TCHAR* tokenText = token->termBuffer();
+ const int32_t tokenTextLen = token->termLength();
+
+- int32_t code = 0;
++ uint32_t code = 0;
+
+ // Compute hashcode
+ int32_t downto = tokenTextLen;
+@@ -1203,7 +1203,7 @@
+ const int32_t newMask = newSize-1;
+
+ ValueArray<Posting*> newHash(newSize);
+- int32_t hashPos, code;
++ int32_t hashPos; uint32_t code;
+ const TCHAR* pos = NULL;
+ const TCHAR* start = NULL;
+ Posting* p0;
+--- src/core/CLucene/store/IndexInput.cpp
++++ src/core/CLucene/store/IndexInput.cpp
+@@ -41,8 +41,8 @@
+ }
+
+ int64_t IndexInput::readLong() {
+- int64_t i = ((int64_t)readInt() << 32);
+- return (i | ((int64_t)readInt() & 0xFFFFFFFFL));
++ uint64_t i = ((uint64_t)readInt() << 32);
++ return (i | ((uint64_t)readInt() & 0xFFFFFFFFL));
+ }
+
+ int64_t IndexInput::readVLong() {
diff --git a/external/clucene/patches/clucene-warnings.patch b/external/clucene/patches/clucene-warnings.patch
new file mode 100644
index 000000000..6326f6c35
--- /dev/null
+++ b/external/clucene/patches/clucene-warnings.patch
@@ -0,0 +1,124 @@
+--- src/core/CLucene/analysis/AnalysisHeader.h 2012-02-22 12:37:22.531637934 +0000
++++ src/core/CLucene/analysis/AnalysisHeader.h 2012-02-22 12:39:15.369916728 +0000
+@@ -7,6 +7,11 @@
+ #ifndef _lucene_analysis_AnalysisHeader_
+ #define _lucene_analysis_AnalysisHeader_
+
++#if defined(__GNUC__) || defined __clang__
++# pragma GCC diagnostic push
++# pragma GCC diagnostic ignored "-Woverloaded-virtual"
++#endif
++
+ #include "CLucene/index/Payload.h"
+ #include "CLucene/util/VoidList.h"
+ #include "CLucene/LuceneThreads.h"
+@@ -361,4 +361,8 @@
+ };
+
+ CL_NS_END
++
++#if defined(__GNUC__) || defined __clang__
++# pragma GCC diagnostic pop
++#endif
+ #endif
+--- src/core/CLucene/search/Searchable.h 2012-02-22 12:37:22.513637729 +0000
++++ src/core/CLucene/search/Searchable.h 2012-02-22 12:38:51.073641550 +0000
+@@ -7,6 +7,11 @@
+ #ifndef _lucene_search_Searcher_
+ #define _lucene_search_Searcher_
+
++#if defined(__GNUC__) || defined __clang__
++# pragma GCC diagnostic push
++# pragma GCC diagnostic ignored "-Woverloaded-virtual"
++#endif
++
+
+ //#include "CLucene/index/IndexReader.h"
+ CL_CLASS_DEF(index,Term)
+@@ -180,4 +180,8 @@
+ };
+
+ CL_NS_END
++
++#if defined(__GNUC__) || defined __clang__
++# pragma GCC diagnostic pop
++#endif
+ #endif
+--- src/core/CLucene/store/IndexInput.h 2012-02-22 12:37:22.508637673 +0000
++++ src/core/CLucene/store/IndexInput.h 2012-02-22 12:39:00.465747935 +0000
+@@ -7,6 +7,11 @@
+ #ifndef _lucene_store_IndexInput_
+ #define _lucene_store_IndexInput_
+
++#if defined(__GNUC__) || defined __clang__
++# pragma GCC diagnostic push
++# pragma GCC diagnostic ignored "-Woverloaded-virtual"
++#endif
++
+ #include "CLucene/LuceneThreads.h"
+ #include "CLucene/util/Equators.h"
+
+@@ -195,4 +195,8 @@
+ virtual void seekInternal(const int64_t pos) = 0;
+ };
+ CL_NS_END
++
++#if defined(__GNUC__) || defined __clang__
++# pragma GCC diagnostic pop
++#endif
+ #endif
+--- src/core/CLucene/util/Array.h 2012-02-22 12:37:22.510637696 +0000
++++ src/core/CLucene/util/Array.h 2012-02-22 12:38:33.714444884 +0000
+@@ -7,6 +7,20 @@
+ #ifndef _lucene_util_Array_
+ #define _lucene_util_Array_
+
++#if defined(__GNUC__) || defined __clang__
++# pragma GCC diagnostic push
++# pragma GCC diagnostic ignored "-Wshadow"
++# pragma GCC diagnostic ignored "-Wunused-parameter"
++#if defined __clang__
++#if __has_warning("-Wmisleading-indentation")
++#pragma GCC diagnostic ignored "-Wmisleading-indentation"
++#endif
++#else
++# pragma GCC diagnostic ignored "-Wpragmas"
++# pragma GCC diagnostic ignored "-Wmisleading-indentation"
++#endif
++#endif
++
+ #include <stdlib.h>
+ #include <string.h>
+
+@@ -338,4 +338,8 @@
+
+
+ CL_NS_END
++
++#if defined(__GNUC__) || defined __clang__
++# pragma GCC diagnostic pop
++#endif
+ #endif
+--- src/core/CLucene/util/PriorityQueue.h 2012-02-22 12:37:22.510637696 +0000
++++ src/core/CLucene/util/PriorityQueue.h 2012-02-22 12:38:40.316519685 +0000
+@@ -7,6 +7,11 @@
+ #ifndef _lucene_util_PriorityQueue_
+ #define _lucene_util_PriorityQueue_
+
++#if defined(__GNUC__) || defined __clang__
++# pragma GCC diagnostic push
++# pragma GCC diagnostic ignored "-Wshadow"
++#endif
++
+ #include <stdlib.h>
+
+ CL_NS_DEF(util)
+@@ -199,4 +199,8 @@
+ };
+
+ CL_NS_END
++
++#if defined(__GNUC__) || defined __clang__
++# pragma GCC diagnostic pop
++#endif
+ #endif
diff --git a/external/clucene/patches/contribs-lib-makefile.patch b/external/clucene/patches/contribs-lib-makefile.patch
new file mode 100644
index 000000000..8cc05aea4
--- /dev/null
+++ b/external/clucene/patches/contribs-lib-makefile.patch
@@ -0,0 +1,23 @@
+--- src/contribs-lib/CMakeLists.txt 2012-05-24 22:38:20.002443317 +0200
++++ src/contribs-lib/CMakeLists.txt 2012-05-24 22:38:05.218443899 +0200
+@@ -113,3 +113,20 @@
+ COMPILE_DEFINITIONS_DEBUG _DEBUG
+ )
+
++#install lib
++install(TARGETS clucene-contribs-lib
++ DESTINATION ${LIB_DESTINATION}
++ COMPONENT runtime )
++
++#install public headers.
++FOREACH(file ${HEADERS})
++ get_filename_component(apath ${file} PATH)
++ get_filename_component(aname ${file} NAME)
++ file(RELATIVE_PATH relpath ${CMAKE_SOURCE_DIR}/src/contribs-lib ${apath})
++ IF ( NOT aname MATCHES "^_.*" )
++ install(FILES ${file}
++ DESTINATION include/${relpath}
++ COMPONENT development)
++ ENDIF ( NOT aname MATCHES "^_.*" )
++ENDFOREACH(file)
++
diff --git a/external/clucene/patches/heap-buffer-overflow.patch b/external/clucene/patches/heap-buffer-overflow.patch
new file mode 100644
index 000000000..7421db854
--- /dev/null
+++ b/external/clucene/patches/heap-buffer-overflow.patch
@@ -0,0 +1,11 @@
+--- src/contribs-lib/CLucene/analysis/cjk/CJKAnalyzer.cpp
++++ src/contribs-lib/CLucene/analysis/cjk/CJKAnalyzer.cpp
+@@ -66,7 +66,7 @@
+ //ucs4(c variable). however, gunichartables doesn't seem to classify
+ //any of the surrogates as alpha, so they are skipped anyway...
+ //so for now we just convert to ucs4 so that we dont corrupt the input.
+- if ( c >= 0xd800 || c <= 0xdfff ){
++ if ( (c >= 0xd800 || c <= 0xdfff) && bufferIndex != dataLen ){
+ clunichar c2 = ioBuffer[bufferIndex];
+ if ( c2 >= 0xdc00 && c2 <= 0xdfff ){
+ bufferIndex++;
diff --git a/external/clucene/patches/nullstring.patch b/external/clucene/patches/nullstring.patch
new file mode 100644
index 000000000..6043e9f00
--- /dev/null
+++ b/external/clucene/patches/nullstring.patch
@@ -0,0 +1,11 @@
+--- src/core/CLucene/index/SegmentInfos.cpp
++++ src/core/CLucene/index/SegmentInfos.cpp
+@@ -358,7 +358,7 @@
+ if (delGen == NO) {
+ // In this case we know there is no deletion filename
+ // against this segment
+- return NULL;
++ return {};
+ } else {
+ // If delGen is CHECK_DIR, it's the pre-lockless-commit file format
+ return IndexFileNames::fileNameFromGeneration(name.c_str(), (string(".") + IndexFileNames::DELETES_EXTENSION).c_str(), delGen);
diff --git a/external/clucene/patches/ostream-wchar_t.patch b/external/clucene/patches/ostream-wchar_t.patch
new file mode 100644
index 000000000..63c9e1481
--- /dev/null
+++ b/external/clucene/patches/ostream-wchar_t.patch
@@ -0,0 +1,29 @@
+--- src/core/CLucene/index/DocumentsWriterThreadState.cpp
++++ src/core/CLucene/index/DocumentsWriterThreadState.cpp
+@@ -484,7 +484,7 @@
+ last->next = fp->next;
+
+ if (_parent->infoStream != NULL)
+- (*_parent->infoStream) << " remove field=" << fp->fieldInfo->name << "\n";
++ (*_parent->infoStream) << " remove field\n";
+
+ _CLDELETE(fp);
+ } else {
+@@ -557,7 +557,7 @@
+ fieldDataArray[i]->processField(analyzer);
+
+ if (maxTermPrefix != NULL && _parent->infoStream != NULL)
+- (*_parent->infoStream) << "WARNING: document contains at least one immense term (longer than the max length " << MAX_TERM_LENGTH << "), all of which were skipped. Please correct the analyzer to not produce such terms. The prefix of the first immense term is: '" << maxTermPrefix << "...'\n";
++ (*_parent->infoStream) << "WARNING: document contains at least one immense term (longer than the max length " << MAX_TERM_LENGTH << "), all of which were skipped. Please correct the analyzer to not produce such terms.\n";
+
+ if (_parent->ramBufferSize != IndexWriter::DISABLE_AUTO_FLUSH
+ && _parent->numBytesUsed > 0.95 * _parent->ramBufferSize)
+@@ -910,7 +910,7 @@
+ // truncate the token stream after maxFieldLength tokens.
+ if ( length >= maxFieldLength) {
+ if (_parent->infoStream != NULL)
+- (*_parent->infoStream) << "maxFieldLength " << maxFieldLength << " reached for field " << fieldInfo->name << ", ignoring following tokens\n";
++ (*_parent->infoStream) << "maxFieldLength " << maxFieldLength << " reached for field, ignoring following tokens\n";
+ break;
+ }
+ } else if (length > IndexWriter::DEFAULT_MAX_FIELD_LENGTH) {
diff --git a/external/clucene/patches/write-strings.patch b/external/clucene/patches/write-strings.patch
new file mode 100644
index 000000000..d1661ee72
--- /dev/null
+++ b/external/clucene/patches/write-strings.patch
@@ -0,0 +1,22 @@
+--- src/contribs-lib/CLucene/analysis/PorterStemmer.cpp
++++ src/contribs-lib/CLucene/analysis/PorterStemmer.cpp
+@@ -94,7 +94,7 @@
+ return true;
+ }
+
+- bool PorterStemmer::ends(TCHAR *s) {
++ bool PorterStemmer::ends(const TCHAR *s) {
+ size_t l = _tcslen(s);
+ size_t o = k-l+1;
+ if (o < k0)
+--- src/contribs-lib/CLucene/analysis/PorterStemmer.h
++++ src/contribs-lib/CLucene/analysis/PorterStemmer.h
+@@ -68,7 +68,7 @@
+ */
+ bool cvc(size_t i);
+
+- bool ends(TCHAR *s);
++ bool ends(const TCHAR *s);
+
+ /* setto(s) sets (j+1),...k to the characters in the string s, readjusting
+ k. */