summaryrefslogtreecommitdiffstats
path: root/external/clucene/patches
diff options
context:
space:
mode:
Diffstat (limited to 'external/clucene/patches')
-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
19 files changed, 595 insertions, 0 deletions
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. */