[sword-svn] r428 - in trunk: . clucene clucene/src clucene/src/CLucene clucene/src/CLucene/analysis clucene/src/CLucene/analysis/standard clucene/src/CLucene/config clucene/src/CLucene/debug clucene/src/CLucene/document clucene/src/CLucene/index clucene/src/CLucene/queryParser clucene/src/CLucene/search clucene/src/CLucene/store clucene/src/CLucene/util stage

scribe at crosswire.org scribe at crosswire.org
Sun Jun 25 17:40:05 MST 2006


Author: scribe
Date: 2006-06-25 17:39:24 -0700 (Sun, 25 Jun 2006)
New Revision: 428

Modified:
   trunk/clucene/clucene.bpr
   trunk/clucene/src/CLucene.h
   trunk/clucene/src/CLucene/CLBackwards.h
   trunk/clucene/src/CLucene/CLConfig.h
   trunk/clucene/src/CLucene/CLMonolithic.cpp
   trunk/clucene/src/CLucene/LuceneThreads.h
   trunk/clucene/src/CLucene/StdHeader.cpp
   trunk/clucene/src/CLucene/StdHeader.h
   trunk/clucene/src/CLucene/analysis/AnalysisHeader.cpp
   trunk/clucene/src/CLucene/analysis/AnalysisHeader.h
   trunk/clucene/src/CLucene/analysis/Analyzers.cpp
   trunk/clucene/src/CLucene/analysis/Analyzers.h
   trunk/clucene/src/CLucene/analysis/standard/StandardAnalyzer.cpp
   trunk/clucene/src/CLucene/analysis/standard/StandardAnalyzer.h
   trunk/clucene/src/CLucene/analysis/standard/StandardFilter.cpp
   trunk/clucene/src/CLucene/analysis/standard/StandardFilter.h
   trunk/clucene/src/CLucene/analysis/standard/StandardTokenizer.cpp
   trunk/clucene/src/CLucene/analysis/standard/StandardTokenizer.h
   trunk/clucene/src/CLucene/analysis/standard/StandardTokenizerConstants.h
   trunk/clucene/src/CLucene/config/CompilerBcb.h
   trunk/clucene/src/CLucene/config/CompilerGcc.h
   trunk/clucene/src/CLucene/config/CompilerMsvc.h
   trunk/clucene/src/CLucene/config/PlatformMac.h
   trunk/clucene/src/CLucene/config/PlatformUnix.h
   trunk/clucene/src/CLucene/config/PlatformWin32.h
   trunk/clucene/src/CLucene/config/compiler.h
   trunk/clucene/src/CLucene/config/define_std.h
   trunk/clucene/src/CLucene/config/gunichartables.cpp
   trunk/clucene/src/CLucene/config/repl_lltot.cpp
   trunk/clucene/src/CLucene/config/repl_tchar.h
   trunk/clucene/src/CLucene/config/repl_tcscasecmp.cpp
   trunk/clucene/src/CLucene/config/repl_tcslwr.cpp
   trunk/clucene/src/CLucene/config/repl_tcstod.cpp
   trunk/clucene/src/CLucene/config/repl_tcstoll.cpp
   trunk/clucene/src/CLucene/config/repl_tprintf.cpp
   trunk/clucene/src/CLucene/config/repl_wchar.h
   trunk/clucene/src/CLucene/config/utf8.cpp
   trunk/clucene/src/CLucene/debug/condition.cpp
   trunk/clucene/src/CLucene/debug/condition.h
   trunk/clucene/src/CLucene/debug/error.cpp
   trunk/clucene/src/CLucene/debug/error.h
   trunk/clucene/src/CLucene/debug/lucenebase.h
   trunk/clucene/src/CLucene/debug/mem.h
   trunk/clucene/src/CLucene/debug/mempool.cpp
   trunk/clucene/src/CLucene/debug/memtracking.cpp
   trunk/clucene/src/CLucene/debug/pool.h
   trunk/clucene/src/CLucene/document/DateField.cpp
   trunk/clucene/src/CLucene/document/DateField.h
   trunk/clucene/src/CLucene/document/Document.cpp
   trunk/clucene/src/CLucene/document/Document.h
   trunk/clucene/src/CLucene/document/Field.cpp
   trunk/clucene/src/CLucene/document/Field.h
   trunk/clucene/src/CLucene/index/CompoundFile.cpp
   trunk/clucene/src/CLucene/index/CompoundFile.h
   trunk/clucene/src/CLucene/index/DocumentWriter.cpp
   trunk/clucene/src/CLucene/index/DocumentWriter.h
   trunk/clucene/src/CLucene/index/FieldInfo.h
   trunk/clucene/src/CLucene/index/FieldInfos.cpp
   trunk/clucene/src/CLucene/index/FieldInfos.h
   trunk/clucene/src/CLucene/index/FieldsReader.cpp
   trunk/clucene/src/CLucene/index/FieldsReader.h
   trunk/clucene/src/CLucene/index/FieldsWriter.cpp
   trunk/clucene/src/CLucene/index/FieldsWriter.h
   trunk/clucene/src/CLucene/index/IndexModifier.cpp
   trunk/clucene/src/CLucene/index/IndexModifier.h
   trunk/clucene/src/CLucene/index/IndexReader.cpp
   trunk/clucene/src/CLucene/index/IndexReader.h
   trunk/clucene/src/CLucene/index/IndexWriter.cpp
   trunk/clucene/src/CLucene/index/IndexWriter.h
   trunk/clucene/src/CLucene/index/MultiReader.cpp
   trunk/clucene/src/CLucene/index/MultiReader.h
   trunk/clucene/src/CLucene/index/SegmentHeader.h
   trunk/clucene/src/CLucene/index/SegmentInfos.cpp
   trunk/clucene/src/CLucene/index/SegmentInfos.h
   trunk/clucene/src/CLucene/index/SegmentMergeInfo.cpp
   trunk/clucene/src/CLucene/index/SegmentMergeInfo.h
   trunk/clucene/src/CLucene/index/SegmentMergeQueue.cpp
   trunk/clucene/src/CLucene/index/SegmentMergeQueue.h
   trunk/clucene/src/CLucene/index/SegmentMerger.cpp
   trunk/clucene/src/CLucene/index/SegmentMerger.h
   trunk/clucene/src/CLucene/index/SegmentReader.cpp
   trunk/clucene/src/CLucene/index/SegmentTermDocs.cpp
   trunk/clucene/src/CLucene/index/SegmentTermEnum.cpp
   trunk/clucene/src/CLucene/index/SegmentTermEnum.h
   trunk/clucene/src/CLucene/index/SegmentTermPositions.cpp
   trunk/clucene/src/CLucene/index/SegmentTermVector.cpp
   trunk/clucene/src/CLucene/index/Term.cpp
   trunk/clucene/src/CLucene/index/Term.h
   trunk/clucene/src/CLucene/index/TermInfo.cpp
   trunk/clucene/src/CLucene/index/TermInfo.h
   trunk/clucene/src/CLucene/index/TermInfosReader.cpp
   trunk/clucene/src/CLucene/index/TermInfosReader.h
   trunk/clucene/src/CLucene/index/TermInfosWriter.cpp
   trunk/clucene/src/CLucene/index/TermInfosWriter.h
   trunk/clucene/src/CLucene/index/TermVector.h
   trunk/clucene/src/CLucene/index/TermVectorReader.cpp
   trunk/clucene/src/CLucene/index/TermVectorWriter.cpp
   trunk/clucene/src/CLucene/index/Terms.h
   trunk/clucene/src/CLucene/queryParser/Lexer.cpp
   trunk/clucene/src/CLucene/queryParser/Lexer.h
   trunk/clucene/src/CLucene/queryParser/MultiFieldQueryParser.cpp
   trunk/clucene/src/CLucene/queryParser/MultiFieldQueryParser.h
   trunk/clucene/src/CLucene/queryParser/QueryParser.cpp
   trunk/clucene/src/CLucene/queryParser/QueryParser.h
   trunk/clucene/src/CLucene/queryParser/QueryParserBase.cpp
   trunk/clucene/src/CLucene/queryParser/QueryParserBase.h
   trunk/clucene/src/CLucene/queryParser/QueryParserConstants.h
   trunk/clucene/src/CLucene/queryParser/QueryToken.cpp
   trunk/clucene/src/CLucene/queryParser/QueryToken.h
   trunk/clucene/src/CLucene/queryParser/TokenList.cpp
   trunk/clucene/src/CLucene/queryParser/TokenList.h
   trunk/clucene/src/CLucene/search/BooleanClause.h
   trunk/clucene/src/CLucene/search/BooleanQuery.cpp
   trunk/clucene/src/CLucene/search/BooleanQuery.h
   trunk/clucene/src/CLucene/search/BooleanScorer.cpp
   trunk/clucene/src/CLucene/search/BooleanScorer.h
   trunk/clucene/src/CLucene/search/CachingWrapperFilter.cpp
   trunk/clucene/src/CLucene/search/CachingWrapperFilter.h
   trunk/clucene/src/CLucene/search/ChainedFilter.cpp
   trunk/clucene/src/CLucene/search/ChainedFilter.h
   trunk/clucene/src/CLucene/search/Compare.h
   trunk/clucene/src/CLucene/search/ConjunctionScorer.cpp
   trunk/clucene/src/CLucene/search/ConjunctionScorer.h
   trunk/clucene/src/CLucene/search/DateFilter.cpp
   trunk/clucene/src/CLucene/search/DateFilter.h
   trunk/clucene/src/CLucene/search/ExactPhraseScorer.cpp
   trunk/clucene/src/CLucene/search/ExactPhraseScorer.h
   trunk/clucene/src/CLucene/search/Explanation.cpp
   trunk/clucene/src/CLucene/search/Explanation.h
   trunk/clucene/src/CLucene/search/FieldCache.cpp
   trunk/clucene/src/CLucene/search/FieldCache.h
   trunk/clucene/src/CLucene/search/FieldCacheImpl.cpp
   trunk/clucene/src/CLucene/search/FieldCacheImpl.h
   trunk/clucene/src/CLucene/search/FieldDoc.h
   trunk/clucene/src/CLucene/search/FieldDocSortedHitQueue.cpp
   trunk/clucene/src/CLucene/search/FieldDocSortedHitQueue.h
   trunk/clucene/src/CLucene/search/FieldSortedHitQueue.cpp
   trunk/clucene/src/CLucene/search/FieldSortedHitQueue.h
   trunk/clucene/src/CLucene/search/Filter.h
   trunk/clucene/src/CLucene/search/FilteredTermEnum.cpp
   trunk/clucene/src/CLucene/search/FilteredTermEnum.h
   trunk/clucene/src/CLucene/search/FuzzyQuery.cpp
   trunk/clucene/src/CLucene/search/FuzzyQuery.h
   trunk/clucene/src/CLucene/search/HitQueue.cpp
   trunk/clucene/src/CLucene/search/HitQueue.h
   trunk/clucene/src/CLucene/search/Hits.cpp
   trunk/clucene/src/CLucene/search/IndexSearcher.cpp
   trunk/clucene/src/CLucene/search/IndexSearcher.h
   trunk/clucene/src/CLucene/search/MultiSearcher.cpp
   trunk/clucene/src/CLucene/search/MultiSearcher.h
   trunk/clucene/src/CLucene/search/MultiTermQuery.cpp
   trunk/clucene/src/CLucene/search/MultiTermQuery.h
   trunk/clucene/src/CLucene/search/PhrasePositions.cpp
   trunk/clucene/src/CLucene/search/PhrasePositions.h
   trunk/clucene/src/CLucene/search/PhraseQuery.cpp
   trunk/clucene/src/CLucene/search/PhraseQuery.h
   trunk/clucene/src/CLucene/search/PhraseQueue.h
   trunk/clucene/src/CLucene/search/PhraseScorer.cpp
   trunk/clucene/src/CLucene/search/PhraseScorer.h
   trunk/clucene/src/CLucene/search/PrefixQuery.cpp
   trunk/clucene/src/CLucene/search/PrefixQuery.h
   trunk/clucene/src/CLucene/search/QueryFilter.cpp
   trunk/clucene/src/CLucene/search/QueryFilter.h
   trunk/clucene/src/CLucene/search/RangeFilter.cpp
   trunk/clucene/src/CLucene/search/RangeFilter.h
   trunk/clucene/src/CLucene/search/RangeQuery.cpp
   trunk/clucene/src/CLucene/search/RangeQuery.h
   trunk/clucene/src/CLucene/search/ScoreDoc.h
   trunk/clucene/src/CLucene/search/Scorer.h
   trunk/clucene/src/CLucene/search/SearchHeader.cpp
   trunk/clucene/src/CLucene/search/SearchHeader.h
   trunk/clucene/src/CLucene/search/Similarity.cpp
   trunk/clucene/src/CLucene/search/Similarity.h
   trunk/clucene/src/CLucene/search/SloppyPhraseScorer.cpp
   trunk/clucene/src/CLucene/search/SloppyPhraseScorer.h
   trunk/clucene/src/CLucene/search/Sort.cpp
   trunk/clucene/src/CLucene/search/Sort.h
   trunk/clucene/src/CLucene/search/TermQuery.cpp
   trunk/clucene/src/CLucene/search/TermQuery.h
   trunk/clucene/src/CLucene/search/TermScorer.cpp
   trunk/clucene/src/CLucene/search/TermScorer.h
   trunk/clucene/src/CLucene/search/WildcardQuery.cpp
   trunk/clucene/src/CLucene/search/WildcardQuery.h
   trunk/clucene/src/CLucene/search/WildcardTermEnum.cpp
   trunk/clucene/src/CLucene/search/WildcardTermEnum.h
   trunk/clucene/src/CLucene/store/Directory.h
   trunk/clucene/src/CLucene/store/FSDirectory.cpp
   trunk/clucene/src/CLucene/store/FSDirectory.h
   trunk/clucene/src/CLucene/store/IndexInput.cpp
   trunk/clucene/src/CLucene/store/IndexInput.h
   trunk/clucene/src/CLucene/store/IndexOutput.cpp
   trunk/clucene/src/CLucene/store/IndexOutput.h
   trunk/clucene/src/CLucene/store/InputStream.h
   trunk/clucene/src/CLucene/store/Lock.cpp
   trunk/clucene/src/CLucene/store/Lock.h
   trunk/clucene/src/CLucene/store/MMapInput.cpp
   trunk/clucene/src/CLucene/store/OutputStream.h
   trunk/clucene/src/CLucene/store/RAMDirectory.cpp
   trunk/clucene/src/CLucene/store/RAMDirectory.h
   trunk/clucene/src/CLucene/store/TransactionalRAMDirectory.cpp
   trunk/clucene/src/CLucene/store/TransactionalRAMDirectory.h
   trunk/clucene/src/CLucene/util/Arrays.h
   trunk/clucene/src/CLucene/util/BitSet.h
   trunk/clucene/src/CLucene/util/Equators.cpp
   trunk/clucene/src/CLucene/util/Equators.h
   trunk/clucene/src/CLucene/util/FastCharStream.cpp
   trunk/clucene/src/CLucene/util/FastCharStream.h
   trunk/clucene/src/CLucene/util/MD5Digester.cpp
   trunk/clucene/src/CLucene/util/MD5Digester.h
   trunk/clucene/src/CLucene/util/Misc.cpp
   trunk/clucene/src/CLucene/util/Misc.h
   trunk/clucene/src/CLucene/util/PriorityQueue.h
   trunk/clucene/src/CLucene/util/Reader.cpp
   trunk/clucene/src/CLucene/util/Reader.h
   trunk/clucene/src/CLucene/util/StringBuffer.cpp
   trunk/clucene/src/CLucene/util/StringBuffer.h
   trunk/clucene/src/CLucene/util/StringIntern.cpp
   trunk/clucene/src/CLucene/util/StringIntern.h
   trunk/clucene/src/CLucene/util/VoidList.h
   trunk/clucene/src/CLucene/util/VoidMap.h
   trunk/clucene/src/CLucene/util/dirent.cpp
   trunk/clucene/src/CLucene/util/dirent.h
   trunk/clucene/src/CLucene/util/jstreamsconfig.h
   trunk/clucene/src/CLucene/util/streambase.h
   trunk/clucene/src/CLucene/util/stringreader.h
   trunk/stage/layout.conf
   trunk/sword.bpr
   trunk/sword.res
Log:
updated to current svn of clucene, as of this log date

Modified: trunk/clucene/clucene.bpr
===================================================================
--- trunk/clucene/clucene.bpr	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/clucene.bpr	2006-06-26 00:39:24 UTC (rev 428)
@@ -18,7 +18,7 @@
     <PATHRC value=".;"/>
     <PATHASM value=".;"/>
     <LINKER value="TLib"/>
-    <USERDEFINES value="UNICODE;_WIN32;_CL_DISABLE_MULTITHREADING"/>
+    <USERDEFINES value="MAX_PATH=256;UNICODE;_WIN32;_CL_DISABLE_MULTITHREADING;_DEBUG"/>
     <SYSDEFINES value="_RTLDLL;NO_STRICT"/>
     <MAINSOURCE value="clucene.bpf"/>
     <INCLUDEPATH value="src\CLucene;src;$(BCB)\include;$(BCB)\include\vcl"/>
@@ -29,9 +29,9 @@
   <OPTIONS>
     <IDLCFLAGS value="-Isrc\CLucene -Isrc -I$(BCB)\include -I$(BCB)\include\vcl -src_suffix cpp 
       -DUNICODE -D_WIN32 -D_CL_DISABLE_MULTITHREADING -boa"/>
-    <CFLAG1 value="-O2 -Q -w- -Vx -VF -X- -a8 -b- -k- -vi -c -tW -tWM"/>
-    <PFLAGS value="-$Y- -$L- -$D- -v -JPHNE -M"/>
-    <AFLAGS value="/mx /w2 /zn"/>
+    <CFLAG1 value="-vGc -vGt -vGd -Od -Q -w- -Vx -VF -X- -r- -a8 -b- -k -y -v -vi- -c -tW -tWM"/>
+    <PFLAGS value="-$Y+ -$W -$O- -v -JPHNE -M"/>
+    <AFLAGS value="/mx /w2 /zi"/>
     <LFLAGS value="/P256"/>
   </OPTIONS>
   <LINKER>
@@ -94,20 +94,22 @@
 Item0=$(BCB)\source\vcl
 
 [HistoryLists\hlConditionals]
-Count=13
-Item0=UNICODE;_WIN32;_CL_DISABLE_MULTITHREADING
-Item1=_WIN32;_CL_DISABLE_MULTITHREADING
-Item2=_WIN32;HAVE_DIRENT;_CL_DISABLE_MULTITHREADING
-Item3=LUCENE_DISABLE_MULTITHREADING;_WIN32;HAVE_DIRENT
-Item4=LUCENE_DISABLE_MULTITHREADING;_WIN32;HAVE_DIRENT;_DEBUG
-Item5=_DEBUG;LUCENE_DISABLE_MULTITHREADING;_WIN32;HAVE_DIRENT
-Item6=_DEBUG;LUCENE_DISABLE_MULTITHREADING;_WIN32
-Item7=_DEBUG;LUCENE_DISABLE_MULTITHREADING;HAVE_DIRENT;_WIN32
-Item8=_DEBUG;LUCENE_DISABLE_MULTITHREADING;HAVE_DIRENT_H;_WIN32
-Item9=_DEBUG;LUCENE_DISABLE_MULTITHREADING;HAVE_DIRENT_H;_WIN32;UTF8
-Item10=_DEBUG;LUCENE_DISABLE_MULTITHREADING;HAVE_DIRENT_H
-Item11=_DEBUG;LUCENE_DISABLE_MULTITHREADING
-Item12=_DEBUG
+Count=15
+Item0=MAX_PATH=256;UNICODE;_WIN32;_CL_DISABLE_MULTITHREADING;_DEBUG
+Item1=MAX_PATH=256;UNICODE;_WIN32;_CL_DISABLE_MULTITHREADING
+Item2=UNICODE;_WIN32;_CL_DISABLE_MULTITHREADING
+Item3=_WIN32;_CL_DISABLE_MULTITHREADING
+Item4=_WIN32;HAVE_DIRENT;_CL_DISABLE_MULTITHREADING
+Item5=LUCENE_DISABLE_MULTITHREADING;_WIN32;HAVE_DIRENT
+Item6=LUCENE_DISABLE_MULTITHREADING;_WIN32;HAVE_DIRENT;_DEBUG
+Item7=_DEBUG;LUCENE_DISABLE_MULTITHREADING;_WIN32;HAVE_DIRENT
+Item8=_DEBUG;LUCENE_DISABLE_MULTITHREADING;_WIN32
+Item9=_DEBUG;LUCENE_DISABLE_MULTITHREADING;HAVE_DIRENT;_WIN32
+Item10=_DEBUG;LUCENE_DISABLE_MULTITHREADING;HAVE_DIRENT_H;_WIN32
+Item11=_DEBUG;LUCENE_DISABLE_MULTITHREADING;HAVE_DIRENT_H;_WIN32;UTF8
+Item12=_DEBUG;LUCENE_DISABLE_MULTITHREADING;HAVE_DIRENT_H
+Item13=_DEBUG;LUCENE_DISABLE_MULTITHREADING
+Item14=_DEBUG
 
 [HistoryLists\hlTlibPageSize]
 Count=8
@@ -133,13 +135,8 @@
 [Compiler]
 ShowInfoMsgs=1
 LinkDebugVcl=0
-LinkCGLIB=0
+LinkCGLIB=1
 
-[CORBA]
-AddServerUnit=1
-AddClientUnit=1
-PrecompiledHeaders=1
-
 [Language]
 ActiveLang=
 ProjectLang=

Modified: trunk/clucene/src/CLucene/CLBackwards.h
===================================================================
--- trunk/clucene/src/CLucene/CLBackwards.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/CLBackwards.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _clucene_backwards_h
 #define _clucene_backwards_h
 
@@ -73,7 +64,7 @@
 
 //file naming stuff - remember we have changed all names to file naming lower case
 #define fileRename _rename
-#define fileFullName _fullpath
+#define fileFullName(abs,rel) _realpath(rel,abs)
 #define makeDirectory _tmkdir
 #define unlinkFile _unlink
 

Modified: trunk/clucene/src/CLucene/CLConfig.h
===================================================================
--- trunk/clucene/src/CLucene/CLConfig.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/CLConfig.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,19 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-                                                                                                                                                                                                                                                               
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_Config_
 #define _lucene_Config_
 
@@ -53,26 +43,26 @@
 //
 //if a wide character is being converted to a ascii character and it
 //cannot fit, this character is used instead. Required.
-#define LUCENE_OOR_CHAR '?'
+#define LUCENE_OOR_CHAR(c) ((char)(((unsigned short)c)&0xFF))
 //
 //define if you would like to force clucene to use the internal
 //character functions.
 //Tests may display unpredictable behaviour if this is not defined.
 #define LUCENE_USE_INTERNAL_CHAR_FUNCTIONS
 //
-//thread locking implementation: define to use the timer based mutex hack...
-//this is NOT threadsafe, it is just a hack to help solve threading problems
-//and for temporary use by compilers which don't have windows or pthread libraries
-//#define LUCENE_THREAD_HACK
-//
 //define this to enable mmap support in the fsdirectory IndexInput
 //todo: only available for windows so far...need to add MMapInput.cpp to project
 //EXPERIMENTAL
 //#define LUCENE_FS_MMAP
 //
 //LOCK_DIR implementation:
-//define this to set an exact directory for the lock dir (not recommended)
+//define this to set an exact directory for the lock dir
 //all other methods of getting the temporary directory will be ignored
+//you could use this to define the lock to a safe directory like /var/lock/clucene.
+//note that all lucene libraries need to use the same directory otherwise you
+//will most likely corrupt your index.
+//If your index is on a network drive, then you will need to set the lock
+//dir to the same directory on each system that access the index.
 //#define LUCENE_LOCK_DIR "/tmp"
 //
 //define this to try and load the lock dir from this specified environment variable
@@ -154,7 +144,7 @@
 //todo: currently cant be used with mempool...
 #if defined(_DEBUG) && !defined(LUCENE_ENABLE_MEMORY_POOL) 
 	#if !defined(LUCENE_DISABLE_MEMTRACKING) && !defined(LUCENE_ENABLE_MEMLEAKTRACKING)
-		//#define LUCENE_ENABLE_MEMLEAKTRACKING
+		#define LUCENE_ENABLE_MEMLEAKTRACKING
 	#endif
 #endif 
 //
@@ -242,6 +232,7 @@
 //
 //some defaults, wouldn't usually need to be changed
 //Buffer size for input/output streams. Required.
+//todo: change this to BufferedIndexOutput::BUFFER_SIZE
 #define LUCENE_STREAM_BUFFER_SIZE 1024
 //
 // DSR:2004.08.19:

Modified: trunk/clucene/src/CLucene/CLMonolithic.cpp
===================================================================
--- trunk/clucene/src/CLucene/CLMonolithic.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/CLMonolithic.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 /*
 * this is a monolithic file that can be used to compile clucene using one source file.
 * it simplifies some build processes by avoiding static & dynamic compalation pitfalls.
@@ -32,6 +23,7 @@
 #include "CLucene/config/repl_lltot.cpp"
 #include "CLucene/config/repl_tcstoll.cpp"
 #include "CLucene/config/repl_tprintf.cpp"
+#include "CLucene/config/threads.cpp"
 #include "CLucene/config/utf8.cpp"
 #include "CLucene/debug/condition.cpp"
 #include "CLucene/debug/error.cpp"
@@ -110,9 +102,10 @@
 #include "CLucene/store/IndexOutput.cpp"
 #include "CLucene/store/RAMDirectory.cpp"
 #include "CLucene/store/TransactionalRAMDirectory.cpp"
-#include "CLucene/util/BitVector.cpp"
+#include "CLucene/util/BitSet.cpp"
 #include "CLucene/util/Equators.cpp"
 #include "CLucene/util/FastCharStream.cpp"
+#include "CLucene/util/fileinputstream.cpp"
 #include "CLucene/util/MD5Digester.cpp"
 #include "CLucene/util/Misc.cpp"
 #include "CLucene/util/Reader.cpp"

Modified: trunk/clucene/src/CLucene/LuceneThreads.h
===================================================================
--- trunk/clucene/src/CLucene/LuceneThreads.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/LuceneThreads.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,242 +1,50 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _LuceneThreads_h
 #define  _LuceneThreads_h
 #if defined(_LUCENE_PRAGMA_ONCE)
 # pragma once
 #endif
 
-CL_NS_DEF(util)
 #if defined(_CL_DISABLE_MULTITHREADING)
-  #define SCOPED_LOCK_MUTEX(theMutex)
-  #define SCOPED_LOCK_MUTEX_EX(theMutex,mutexname,dummy)
+	#define SCOPED_LOCK_MUTEX(theMutex)
+	#define SCOPED_LOCK_MUTEX_EX(theMutex,mutexname,dummy)
+	#define DEFINE_MUTEX(x)
+	#define STATIC_DEFINE_MUTEX(x)
+#else
 
-  #define DEFINE_MUTEX(x)
-  #define STATIC_DEFINE_MUTEX(x)
-#else //_CL_DISABLE_MULTITHREADING
-
-#if defined(_LUCENE_THREADMUTEX)
-   //do nothing
-
-#elif defined(LUCENE_THREAD_HACK) //LUCENE_THREAD_HACK
-   ///a lock mutex hack
-   class mutex_default{
+	#if defined(_LUCENE_DONTIMPLEMENT_THREADMUTEX)
+		//do nothing
+	#elif defined(_CL_HAVE_PTHREAD)
+		#include "CLucene/config/threadPthread.h"
+	#elif defined(_CLCOMPILER_MSVC) || defined(__MINGW32__) //note that mingw32 could have pthreads, so put this after.
+		#include "CLucene/config/threadCSection.h"
+	#else
+		#error A valid thread library was not found
+	#endif //mutex types
+	
+	CL_NS_DEF(util)
+	class mutexGuard
+	{
 	private:
-		int locked;
-		_LUCENE_THREADID_TYPE threadId;
+		_LUCENE_THREADMUTEX* mrMutex;
+		mutexGuard(const mutexGuard& clone);
 	public:
-	  mutex_default(const mutex_default& clone){
-         locked=0; 
-		 threadId=0;
-	  }
-      mutex_default(){	
-         locked=0; 
-		 threadId=0;
-      }
-      ~mutex_default(){
-      }
-      void lock(){
-		  _LUCENE_THREADID_TYPE id = _LUCENE_CURRTHREADID;
-		  if ( this->threadId == id ){
-			locked++;
-		  }else{
-			while ( locked>0 )
-				_sleep(1);
-			this->threadId = id;
-			locked=1; //wait till unlocked, then lock
-		  }
-      }
-      void unlock(){
-#if defined(_DEBUG)
-         if ( locked > 0 ){
-			if ( locked == 1 )
-				this->threadId = 0;
-            locked--;
-         } else
-            _CLTHROWA(CL_ERR_Runtime, "Mutex wasn't locked");
-# else
-			if ( locked == 1 )
-				this->threadId = 0;
-            locked--;
-# endif // _DEBUG
-      }
-   };
-   #define _LUCENE_THREADMUTEX CL_NS(util)::mutex_default
-   #define _LUCENE_THREADMUTEX_USINGDEFAULT
-   
-#elif defined(_CLCOMPILER_MSVC) || defined(__MINGW32__)
-   #if !defined(LUCENE_USE_WINDOWS_H) && !defined(_WINDOWS_)
-      //we have not explicity included windows.h and windows.h has
-      //not been included (check _WINDOWS_), then we must define
-      //our own definitions to the thread locking functions:
-      struct CRITICAL_SECTION
-      {
-         struct critical_section_debug * DebugInfo;
-         long LockCount;
-         long RecursionCount;
-         void * OwningThread;
-         void * LockSemaphore;
-      #if defined(_WIN64)
-         unsigned __int64 SpinCount;
-      #else
-         unsigned long SpinCount;
-      #endif
-      };
+		mutexGuard( _LUCENE_THREADMUTEX& rMutex );
+		~mutexGuard();
+	};
+	CL_NS_END
+	
+	#define SCOPED_LOCK_MUTEX(theMutex) 	CL_NS(util)::mutexGuard theMutexGuard(theMutex);
+	#define DEFINE_MUTEX(theMutex) 			_LUCENE_THREADMUTEX theMutex;
+	#define STATIC_DEFINE_MUTEX(theMutex) 	static _LUCENE_THREADMUTEX theMutex;
 
-      extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(CRITICAL_SECTION *);
-      extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(CRITICAL_SECTION *);
-      extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(CRITICAL_SECTION *);
-      extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(CRITICAL_SECTION *);
-	  extern "C" __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId();
-   #endif
-
-   ///a windows implementation of the lock mutex
-   ///todo: boost has a InterlockedExchange way of locking too. More backwards compatible/faster???
-   class mutex_win32
-   {
-   private:
-      CRITICAL_SECTION mtx;
-   public:
-	  mutex_win32(const mutex_win32& clone){
-		  InitializeCriticalSection(&mtx); 
-	  }
-      mutex_win32()
-      { InitializeCriticalSection(&mtx); }
-
-      ~mutex_win32()
-      { DeleteCriticalSection(&mtx); }
-
-      void lock()
-      { EnterCriticalSection(&mtx); }
-
-      void unlock()
-      { LeaveCriticalSection(&mtx); }
-   };
-   #define _LUCENE_THREADMUTEX CL_NS(util)::mutex_win32
-
-#elif defined(_CL_HAVE_PTHREAD) && defined(_POSIX_THREADS)
-   #include <pthread.h>
-   ///a posix implementation of the lock mutex
-   ///todo: we need a spinlock implemenation for usage in reference counting
-   class mutex_pthread
-   {
-   private:
-		pthread_mutex_t mtx;
-		
-#ifndef _CL_HAVE_PTHREAD_MUTEX_RECURSIVE
-		pthread_t lockOwner;
-		unsigned int lockCount;
-#endif
-   public:
-   	#ifdef _CL__CND_DEBUG
-   	  #define PTHREAD_CHECK(c,m) CND_PRECONDITION(c==0,m)
-   	#else
-   	  #define PTHREAD_CHECK(c,m) c;
-   	#endif
-	  mutex_pthread(const mutex_pthread& clone){
-      	#if defined(__hpux) && defined(_DECTHREADS_)
-			PTHREAD_CHECK(pthread_mutex_init(&mtx, pthread_mutexattr_default), "mutex_pthread(clone) constructor failed")
-		#else
-			PTHREAD_CHECK(pthread_mutex_init(&mtx, 0), "mutex_pthread(clone) constructor failed")
-		#endif
-
-#ifndef _CL_HAVE_PTHREAD_MUTEX_RECURSIVE
-		lockCount=0;
-		lockOwner=0;
-#endif
-	  }
-      mutex_pthread()
-      { 
-      	#if defined(__hpux) && defined(_DECTHREADS_)
-			PTHREAD_CHECK(pthread_mutex_init(&mtx, pthread_mutexattr_default), "mutex_pthread() constructor failed")
-		#else
-			PTHREAD_CHECK(pthread_mutex_init(&mtx, 0), "mutex_pthread() constructor failed")
-		#endif
-
-#ifndef _CL_HAVE_PTHREAD_MUTEX_RECURSIVE
-		lockCount=0;
-		lockOwner=0;
-#endif
-	  }
-
-      ~mutex_pthread()
-      { PTHREAD_CHECK(pthread_mutex_destroy(&mtx), "~mutex_pthread destructor failed") }
-
-      void lock()
-      { 
-#ifndef _CL_HAVE_PTHREAD_MUTEX_RECURSIVE
-      	pthread_t currentThread = pthread_self();
-      	if( pthread_equal( lockOwner, currentThread ) ) {
-			++lockCount;
-		} else {
-	    	PTHREAD_CHECK(pthread_mutex_lock(&mtx), "mutex_pthread::lock")
-			lockOwner = currentThread;
-			lockCount = 1;
-		}
-#else
-	    PTHREAD_CHECK(pthread_mutex_lock(&mtx), "mutex_pthread::lock")
-#endif
-      }
-
-      void unlock()
-      { 
-#ifndef _CL_HAVE_PTHREAD_MUTEX_RECURSIVE
-		--lockCount;
-		if( lockCount == 0 )
-		{
-			lockOwner = 0;
-			PTHREAD_CHECK(pthread_mutex_unlock(&mtx), "mutex_pthread::unlock") }
-		}
-#else
-		PTHREAD_CHECK(pthread_mutex_unlock(&mtx), "mutex_pthread::unlock") }
-#endif
-   };
-   #define _LUCENE_THREADMUTEX CL_NS(util)::mutex_pthread
-
-#else
-	#error Cannot implements threads... cannot continue
-#endif //mutex types
-
-class mutexGuard
-{
-private:
-    _LUCENE_THREADMUTEX* mrMutex;
-  mutexGuard(const mutexGuard& clone){
-  	//no autoclone
-  	mrMutex = NULL;
-  }
-public:
-  mutexGuard( _LUCENE_THREADMUTEX& rMutex ) :
-    mrMutex(&rMutex)
-  {
-	  mrMutex->lock();
-  }
-  ~mutexGuard()
-  {
-    mrMutex->unlock();
-  }
-};
-
-# define SCOPED_LOCK_MUTEX(theMutex) CL_NS(util)::mutexGuard theMutexGuard(theMutex);
-# define DEFINE_MUTEX(theMutex) _LUCENE_THREADMUTEX theMutex;
-# define STATIC_DEFINE_MUTEX(theMutex) static _LUCENE_THREADMUTEX theMutex;
-
 #endif //_CL_DISABLE_MULTITHREADING
 
 
-CL_NS_END
 
 #endif

Modified: trunk/clucene/src/CLucene/StdHeader.cpp
===================================================================
--- trunk/clucene/src/CLucene/StdHeader.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/StdHeader.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "CLucene/util/Misc.h"
 
@@ -115,9 +106,6 @@
 #endif //ucs2
 
 
-
-
-
 //ok, these are the exceptions, but these never
 //exist on non-msvc platform, so lets put it here
 #ifndef _CL_HAVE_FILELENGTH
@@ -125,7 +113,7 @@
 {
     struct fileStat info;
     if (fileHandleStat(filehandle, &info) == -1)
- 	 _CLTHROWA( CL_ERR_IO,"fileStat error in StdHeader/fileSize" );
+ 	 _CLTHROWA( CL_ERR_IO,"fileStat error" );
     return info.st_size;
 }
 #endif

Modified: trunk/clucene/src/CLucene/StdHeader.h
===================================================================
--- trunk/clucene/src/CLucene/StdHeader.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/StdHeader.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef lucene_stdheader_h
 #define lucene_stdheader_h
 
@@ -168,6 +159,7 @@
  #include <wctype.h>
 #elif defined(_ASCII) && defined(_CL_HAVE_CTYPE_H)
  #include <ctype.h>
+ #undef  LUCENE_USE_INTERNAL_CHAR_FUNCTIONS
 #elif defined(_UCS2)
  //must be in _UCS2 to use internal char functions
  #undef  LUCENE_USE_INTERNAL_CHAR_FUNCTIONS
@@ -212,6 +204,7 @@
 ////////////////////////////////////////////////////////
 #if defined(LUCENE_USE_INTERNAL_CHAR_FUNCTIONS)
     #define stringCaseFold cl_tcscasefold
+	#define stringCaseFoldCmp cl_tcscasefoldcmp
     
 	#undef _istspace
 	#undef _istdigit
@@ -225,20 +218,7 @@
     #define _istdigit cl_isdigit
     #define _totlower cl_tolower
     #define _totupper cl_toupper
-    
-    //the methods contained in rep_wctype.h
-    bool cl_isletter(TCHAR c);
-    bool cl_isalnum(TCHAR c);
-    bool cl_isdigit(TCHAR c);
-    bool cl_isspace (TCHAR c);
-    TCHAR cl_tolower (TCHAR c);
-    TCHAR cl_toupper (TCHAR c);
 
-    #define stringCaseFold cl_tcscasefold
-	#define stringCaseFoldCmp cl_tcscasefoldcmp
-	int cl_tcscasefoldcmp(const TCHAR * dst, const TCHAR * src);
-    TCHAR* cl_tcscasefold( TCHAR * str, int len=-1 );
-
     //here are some functions to help deal with utf8/ucs2 conversions
     //lets let the user decide what mb functions to use... we provide pure utf8 ones no matter what.
     /*#undef _mbtowc
@@ -258,34 +238,40 @@
 	#define _wcstombs wcstombs*/
 
     //we are using native character functions
-    //if we are using ascii, native functions (msvc mainly)
-    //can crash if passed an out of range character.
-    //here we fix that...
     #if defined(_ASCII)
-    	//fix functions that deal with characters, because
-    	//mostly if they recieve an out of range character they will cause a segfault
-    	#undef _istspace
-    	#undef _istdigit
-    	#undef _istalnum
-    	#undef _istalpha
-    	#undef _totlower
-    	#undef _totupper
-    	#define _istspace(x) (((unsigned)x) < 0x100?isspace(x):0)
-    	#define _istdigit(x) (((unsigned)x) < 0x100?isdigit(x):0)
-    	#define _istalnum(x) (((unsigned)x) < 0x100?isalnum(x):0)
-    	#define _istalpha(x) (((unsigned)x) < 0x100?isalpha(x):0)
-    	//if the character being passed is out of ascii range, we 
-    	//use the LUCENE_OOR_CHAR character as a return
-    	#define _totlower(x) (((unsigned)x) < 0x80?tolower(x):LUCENE_OOR_CHAR)
-    	#define _totupper(x) (((unsigned)x) < 0x80?toupper(x):LUCENE_OOR_CHAR)
+        #undef _istspace
+        #undef _istdigit
+        #undef _istalnum
+        #undef _istalpha
+        #undef _totlower
+        #undef _totupper
+        #define _istspace(x) isspace((unsigned char)x)
+        #define _istdigit(x) isdigit((unsigned char)x)
+        #define _istalnum(x) isalnum((unsigned char)x)
+        #define _istalpha(x) isalpha((unsigned char)x)
+        #define _totlower(x) tolower((unsigned char)x)
+        #define _totupper(x) toupper((unsigned char)x)
     #endif
 #endif
 
+//the methods contained in gunichartables.h
+typedef unsigned long  clunichar;
+bool cl_isletter(clunichar c);
+bool cl_isalnum(clunichar c);
+bool cl_isdigit(clunichar c);
+bool cl_isspace (clunichar c);
+TCHAR cl_tolower (TCHAR c);
+TCHAR cl_toupper (TCHAR c);
+
+int cl_tcscasefoldcmp(const TCHAR * dst, const TCHAR * src);
+TCHAR* cl_tcscasefold( TCHAR * str, int len=-1 );
+
 //we provide utf8 conversion functions
 size_t lucene_utf8towc  (wchar_t *ret, const char *s, size_t n);
 size_t lucene_utf8towcs(wchar_t *,    const char *,  size_t maxslen);
 size_t lucene_wctoutf8  (char * ret,   const wchar_t  str);
 size_t lucene_wcstoutf8 (char *,       const wchar_t *, size_t maxslen);
+size_t lucene_utf8charlen(const char *p);
 
 ///a blank string...
 extern TCHAR* _LUCENE_BLANK_STRING;
@@ -428,13 +414,6 @@
   #define _T(x)       x
 #endif
 
-//#if 0 //todo: figure out which compilers cant assign static constants
-// #define LUCENE_STATIC_CONSTANT(type, assignment) enum { assignment }
-//#else
-#ifndef LUCENE_STATIC_CONSTANT
- #define LUCENE_STATIC_CONSTANT(type, assignment) static const type assignment
-#endif
-
 //third inclusion of compiler.h
 //this gives CompilerXXX.h a chance to fix any of the
 //default settings

Modified: trunk/clucene/src/CLucene/analysis/AnalysisHeader.cpp
===================================================================
--- trunk/clucene/src/CLucene/analysis/AnalysisHeader.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/analysis/AnalysisHeader.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "AnalysisHeader.h"
 
@@ -49,21 +40,15 @@
 	_type ( typ ),
 	positionIncrement (1)
 {
-    termTextLen = _tcslen(text);
+    termTextLen = 0;
 #ifndef LUCENE_TOKEN_WORD_LENGTH
-    _termText = _CL_NEWARRAY(TCHAR,termTextLen+1);
-    _tcsncpy(_termText,text,termTextLen+1);
-		bufferTextLen = termTextLen+1;
+    _termText = NULL;
+	bufferTextLen = 0;
 #else
-    if ( termTextLen > LUCENE_TOKEN_WORD_LENGTH ){
-    	//in the case where this occurs, we will leave the endOffset as it is
-    	//since the actual word still occupies that space.
-    	termTextLen=LUCENE_TOKEN_WORD_LENGTH;
-    }
-	_tcsncpy(_termText,text,termTextLen+1);
-	_termText[termTextLen] = 0; //make sure null terminated
+    _termText[0] = 0; //make sure null terminated
 	bufferTextLen = LUCENE_TOKEN_WORD_LENGTH+1;
 #endif
+	setText(text);
 }
 
 void Token::set(const TCHAR* text, const int32_t start, const int32_t end, const TCHAR* typ){
@@ -71,7 +56,11 @@
 	_endOffset   = end;
 	_type        = typ;
 	positionIncrement = 1;
+	setText(text);
 	
+}
+
+void Token::setText(const TCHAR* text){
 	int32_t oldlen = termTextLen;
 	termTextLen = _tcslen(text);
 	
@@ -113,10 +102,10 @@
 	positionIncrement = posIncr;
 }
 
-int32_t Token::getPositionIncrement() { return positionIncrement; }
+int32_t Token::getPositionIncrement() const { return positionIncrement; }
 
 // Returns the Token's term text. 
-const TCHAR* Token::termText() {
+const TCHAR* Token::termText() const{
 	return (const TCHAR*) _termText; 
 }
 size_t Token::termTextLength() { 
@@ -127,8 +116,21 @@
 void Token::resetTermTextLen(){
 	termTextLen=-1;
 }
+bool Token::OrderCompare::operator()( Token* t1, Token* t2 ) const{
+	if(t1->startOffset()>t2->startOffset())
+        return false;
+    if(t1->startOffset()<t2->startOffset())
+        return true;
+	return true;
+}
 
 
+Token* TokenStream::next(){
+	Token* t = _CLNEW Token;
+	if ( !next(t) )
+		_CLDELETE(t);
+	return t;
+}
 
 
 TokenFilter::TokenFilter(TokenStream* in, bool deleteTS):

Modified: trunk/clucene/src/CLucene/analysis/AnalysisHeader.h
===================================================================
--- trunk/clucene/src/CLucene/analysis/AnalysisHeader.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/analysis/AnalysisHeader.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_analysis_AnalysisHeader_
 #define _lucene_analysis_AnalysisHeader_
 
@@ -49,8 +40,8 @@
 		int32_t termTextLen;
 		size_t bufferTextLen;
 
-  	static const TCHAR* defaultType;
 	public:
+		static const TCHAR* defaultType;
 #ifndef LUCENE_HIDE_INTERNAL
 		#ifndef LUCENE_TOKEN_WORD_LENGTH
 		TCHAR* _termText;				  // the text of the term
@@ -59,7 +50,6 @@
 		#endif
 #endif
 
-  
 		Token();
 		~Token();
 		// Constructs a Token with the given text, start and end offsets, & type. 
@@ -92,10 +82,11 @@
 		* occur with no intervening stop words.
 		*/
 		void setPositionIncrement(int32_t posIncr);
-		int32_t getPositionIncrement();
-		const TCHAR* termText();
+		int32_t getPositionIncrement() const;
+		const TCHAR* termText() const;
 		size_t termTextLength();
 		void resetTermTextLen();
+		void setText(const TCHAR* txt);
 
 		// Returns this Token's starting offset, the position of the first character
 		//	corresponding to this token in the source text.
@@ -120,13 +111,7 @@
 		class OrderCompare:LUCENE_BASE, public CL_NS(util)::Compare::_base //<Token*>
 		{
 		public:
-			bool operator()( Token* t1, Token* t2 ) const{
-				if(t1->startOffset()>t2->startOffset())
-                    return false;
-                if(t1->startOffset()<t2->startOffset())
-                    return true;
-				return true;
-			}
+			bool operator()( Token* t1, Token* t2 ) const;
 		};
 	};
 
@@ -147,12 +132,7 @@
 		 * to next(), this will save a lot of object construction and destructions.
 		 *  @deprecated Kept only to avoid breaking existing code.
 		 */
-		Token* next(){
-			Token* t = _CLNEW Token;
-			if ( !next(t) )
-				_CLDELETE(t);
-			return t;
-		}
+		Token* next();
 	};
 
 

Modified: trunk/clucene/src/CLucene/analysis/Analyzers.cpp
===================================================================
--- trunk/clucene/src/CLucene/analysis/Analyzers.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/analysis/Analyzers.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,32 +1,24 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "Analyzers.h"
+#include "CLucene/util/StringBuffer.h"
 
 CL_NS_USE(util)
 CL_NS_DEF(analysis)
 		
 CharTokenizer::CharTokenizer(Reader* in) :
-			//input(in), ; input is in tokenizer base class (bug fix thanks to Andy Osipienko)
-			offset(0),
-			bufferIndex(0),
-			dataLen(0)
-
+	Tokenizer(in),
+	offset(0),
+	bufferIndex(0),
+	dataLen(0),
+	ioBuffer(NULL)
 {
-	input = in;
+	buffer[0]=0;
 }
 
 TCHAR CharTokenizer::normalize(const TCHAR c) const 
@@ -99,15 +91,15 @@
 	return true;
 }
 
-StopFilter::StopFilter(TokenStream* in, bool deleteTokenStream, TCHAR** stopWords):
+StopFilter::StopFilter(TokenStream* in, bool deleteTokenStream, const TCHAR** stopWords):
 	TokenFilter(in, deleteTokenStream),
-	table(_CLNEW CLSetList<TCHAR*>(false))
+	table(_CLNEW CLSetList<const TCHAR*>(false))
 {
 	fillStopTable( table,stopWords );
 }
 
-void StopFilter::fillStopTable(CLSetList<TCHAR*>* stopTable,
-								  TCHAR** stopWords) {
+void StopFilter::fillStopTable(CLSetList<const TCHAR*>* stopTable,
+								  const TCHAR** stopWords) {
 	for (int32_t i = 0; stopWords[i]!=NULL; i++)
 		stopTable->insert(stopWords[i]);
 }
@@ -131,14 +123,14 @@
 StopAnalyzer::~StopAnalyzer()
 {
 }
-StopAnalyzer::StopAnalyzer( TCHAR** stopWords) {
+StopAnalyzer::StopAnalyzer( const TCHAR** stopWords) {
 	StopFilter::fillStopTable(&stopTable,stopWords);
 }
 TokenStream* StopAnalyzer::tokenStream(const TCHAR* fieldName, Reader* reader) {
 	return _CLNEW StopFilter(_CLNEW LowerCaseTokenizer(reader),true, &stopTable);
 }
 
-TCHAR* StopAnalyzer::ENGLISH_STOP_WORDS[]  = 
+const TCHAR* StopAnalyzer::ENGLISH_STOP_WORDS[]  = 
 {
 	_T("a"), _T("an"), _T("and"), _T("are"), _T("as"), _T("at"), _T("be"), _T("but"), _T("by"),
 	_T("for"), _T("if"), _T("in"), _T("into"), _T("is"), _T("it"),
@@ -170,4 +162,149 @@
     return analyzer->tokenStream(fieldName, reader);
 }
 
+
+
+bool ISOLatin1AccentFilter::next(Token* token){
+	if ( input->next(token) ){
+		StringBuffer output;
+		int32_t l = token->termTextLength();
+		const TCHAR* chars = token->termText();
+		for (int32_t i = 0; i < l; i++) {
+			#ifdef _UCS2
+			TCHAR c = chars[i];
+			#else
+			unsigned char c = chars[i];
+			#endif
+			switch (c) {
+				case 0xC0 : // À
+				case 0xC1 : // Á
+				case 0xC2 : // Â
+				case 0xC3 : // Ã
+				case 0xC4 : // Ä
+				case 0xC5 : // Å
+					output.appendChar('A');
+					break;
+				case 0xC6 : // Æ
+					output.append(_T("AE"));
+					break;
+				case 0xC7 : // Ç
+					output.appendChar('C');
+					break;
+				case 0xC8 : // È
+				case 0xC9 : // É
+				case 0xCA : // Ê
+				case 0xCB : // Ë
+					output.appendChar('E');
+					break;
+				case 0xCC : // Ì
+				case 0xCD : // Í
+				case 0xCE : // Î
+				case 0xCF : // Ï
+					output.appendChar('I');
+					break;
+				case 0xD0 : // Ð
+					output.appendChar('D');
+					break;
+				case 0xD1 : // Ñ
+					output.appendChar('N');
+					break;
+				case 0xD2 : // Ò
+				case 0xD3 : // Ó
+				case 0xD4 : // Ô
+				case 0xD5 : // Õ
+				case 0xD6 : // Ö
+				case 0xD8 : // Ø
+					output.appendChar('O');
+					break;
+				case 0xDE : // Þ
+					output.append(_T("TH"));
+					break;
+				case 0xD9 : // Ù
+				case 0xDA : // Ú
+				case 0xDB : // Û
+				case 0xDC : // Ü
+					output.appendChar('U');
+					break;
+				case 0xDD : // Ý
+					output.appendChar('Y');
+					break;
+				case 0xE0 : // à
+				case 0xE1 : // á
+				case 0xE2 : // â
+				case 0xE3 : // ã
+				case 0xE4 : // ä
+				case 0xE5 : // å
+					output.appendChar('a');
+					break;
+				case 0xE6 : // æ
+					output.append(_T("ae"));
+					break;
+				case 0xE7 : // ç
+					output.appendChar('c');
+					break;
+				case 0xE8 : // è
+				case 0xE9 : // é
+				case 0xEA : // ê
+				case 0xEB : // ë
+					output.appendChar('e');
+					break;
+				case 0xEC : // ì
+				case 0xED : // í
+				case 0xEE : // î
+				case 0xEF : // ï
+					output.appendChar('i');
+					break;
+				case 0xF0 : // ð
+					output.appendChar('d');
+					break;
+				case 0xF1 : // ñ
+					output.appendChar('n');
+					break;
+				case 0xF2 : // ò
+				case 0xF3 : // ó
+				case 0xF4 : // ô
+				case 0xF5 : // õ
+				case 0xF6 : // ö
+				case 0xF8 : // ø
+					output.appendChar('o');
+					break;
+				case 0xDF : // ß
+					output.append(_T("ss"));
+					break;
+				case 0xFE : // þ
+					output.append(_T("th"));
+					break;
+				case 0xF9 : // ù
+				case 0xFA : // ú
+				case 0xFB : // û
+				case 0xFC : // ü
+					output.appendChar('u');
+					break;
+				case 0xFD : // ý
+				case 0xFF : // ÿ
+					output.appendChar('y');
+					break;
+
+				#ifdef _UCS2
+				case 0x152 : // Œ
+					output.append(_T("OE"));
+					break;
+				case 0x153 : // œ
+					output.append(_T("oe"));
+					break;
+				case 0x178 : // Ÿ
+					output.appendChar('Y');
+					break;
+				#endif
+				default :
+					output.appendChar(chars[i]);
+					break;
+			}
+		}
+		token->setText(output.getBuffer());
+		return true;
+	}
+	return false;
+}
+
 CL_NS_END

Modified: trunk/clucene/src/CLucene/analysis/Analyzers.h
===================================================================
--- trunk/clucene/src/CLucene/analysis/Analyzers.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/analysis/Analyzers.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_analysis_Analyzers_
 #define _lucene_analysis_Analyzers_
 
@@ -44,10 +35,10 @@
 	
 	public:
 		CharTokenizer(CL_NS(util)::Reader* in);
-
-      virtual ~CharTokenizer(){
-      }
-    
+		
+		virtual ~CharTokenizer(){
+		}
+		
 		// Returns the next token in the stream, or null at EOS. 
 		// *** This is not a pointer. Use of it must deleted.
 		bool next(Token* token);
@@ -124,7 +115,7 @@
    /**
    * Normalizes token text to lower case.
    *
-   * @version $Id: Analyzers.h 2014 2006-04-27 08:17:24Z ustramooner $
+   * @version $Id: Analyzers.h 2209 2006-06-15 14:12:41Z ustramooner $
    */
 	class LowerCaseFilter: public TokenFilter {
 	public:
@@ -140,17 +131,17 @@
 	private:
 		//bvk: i found this to work faster with a non-hash table. the number of items
 		//in the stop table is not like to make it worth having hashing.
-		CL_NS(util)::CLSetList<TCHAR*>* table;
+		CL_NS(util)::CLSetList<const TCHAR*>* table;
 	public:
 		// Constructs a filter which removes words from the input
 		//	TokenStream that are named in the array of words. 
-		StopFilter(TokenStream* in, bool deleteTokenStream, TCHAR* stopWords[]);
+		StopFilter(TokenStream* in, bool deleteTokenStream, const TCHAR** stopWords);
 
 		~StopFilter(){}
 
 		// Constructs a filter which removes words from the input
 		//	TokenStream that are named in the Hashtable.
-		StopFilter(TokenStream* in, bool deleteTokenStream, CL_NS(util)::CLSetList<TCHAR*>* stopTable):
+		StopFilter(TokenStream* in, bool deleteTokenStream, CL_NS(util)::CLSetList<const TCHAR*>* stopTable):
 			TokenFilter(in, deleteTokenStream),
 			table(stopTable)
 		{} 
@@ -164,8 +155,8 @@
 		*
 		* @swig stopWords
 		*/
-		static void fillStopTable(CL_NS(util)::CLSetList<TCHAR*>* stopTable,
-                                          TCHAR** stopWords);
+		static void fillStopTable(CL_NS(util)::CLSetList<const TCHAR*>* stopTable,
+                                          const TCHAR** stopWords);
 
 		/**
 		* Returns the next input Token whose termText() is not a stop word.
@@ -183,7 +174,7 @@
 	
     // Filters LetterTokenizer with LowerCaseFilter and StopFilter. 
     class StopAnalyzer: public Analyzer {
-        CL_NS(util)::CLSetList<TCHAR*> stopTable;
+        CL_NS(util)::CLSetList<const TCHAR*> stopTable;
     
     public:
         // Builds an analyzer which removes words in ENGLISH_STOP_WORDS. 
@@ -191,11 +182,11 @@
         ~StopAnalyzer();
         
         // Builds an analyzer which removes words in the provided array. 
-        StopAnalyzer( TCHAR** stopWords );
+        StopAnalyzer( const TCHAR** stopWords );
         // Filters LowerCaseTokenizer with StopFilter. 
         TokenStream* tokenStream(const TCHAR* fieldName, CL_NS(util)::Reader* reader);
 		
-        static TCHAR* ENGLISH_STOP_WORDS[];
+        static const TCHAR* ENGLISH_STOP_WORDS[];
     };
     
     
@@ -245,5 +236,26 @@
       TokenStream* tokenStream(const TCHAR* fieldName, CL_NS(util)::Reader* reader);
 };
 
+
+/**
+ * A filter that replaces accented characters in the ISO Latin 1 character set 
+ * (ISO-8859-1) by their unaccented equivalent. The case will not be altered.
+ * <p>
+ * For instance, '&agrave;' will be replaced by 'a'.
+ * <p>
+ */
+class ISOLatin1AccentFilter: public TokenFilter {
+public:
+	ISOLatin1AccentFilter(TokenStream* input, bool deleteTs):
+		TokenFilter(input,deleteTs)
+	{
+	}
+	
+	/**
+	 * To replace accented characters in a String by unaccented equivalents.
+	 */
+	bool next(Token* token);
+};
+
 CL_NS_END
 #endif

Modified: trunk/clucene/src/CLucene/analysis/standard/StandardAnalyzer.cpp
===================================================================
--- trunk/clucene/src/CLucene/analysis/standard/StandardAnalyzer.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/analysis/standard/StandardAnalyzer.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "StandardAnalyzer.h"
 
@@ -34,7 +25,7 @@
       StopFilter::fillStopTable( &stopSet,CL_NS(analysis)::StopAnalyzer::ENGLISH_STOP_WORDS);
 	}
 
-	StandardAnalyzer::StandardAnalyzer( TCHAR** stopWords):
+	StandardAnalyzer::StandardAnalyzer( const TCHAR** stopWords):
 		stopSet(false)
 	{
 		StopFilter::fillStopTable( &stopSet,stopWords );

Modified: trunk/clucene/src/CLucene/analysis/standard/StandardAnalyzer.h
===================================================================
--- trunk/clucene/src/CLucene/analysis/standard/StandardAnalyzer.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/analysis/standard/StandardAnalyzer.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_analysis_standard_StandardAnalyzer
 #define _lucene_analysis_standard_StandardAnalyzer
 
@@ -22,8 +13,8 @@
 
 #include "CLucene/util/VoidMap.h"
 #include "CLucene/util/Reader.h"
-#include "../AnalysisHeader.h"
-#include "../Analyzers.h"
+#include "CLucene/analysis/AnalysisHeader.h"
+#include "CLucene/analysis/Analyzers.h"
 #include "StandardFilter.h"
 #include "StandardTokenizer.h"
 
@@ -34,13 +25,13 @@
 	class StandardAnalyzer : public Analyzer 
 	{
 	private:
-		CL_NS(util)::CLSetList<TCHAR*> stopSet;
+		CL_NS(util)::CLSetList<const TCHAR*> stopSet;
 	public:
 		// <summary> Builds an analyzer. </summary>
 		StandardAnalyzer();
 
 		//<summary> Builds an analyzer with the given stop words. </summary>
-		StandardAnalyzer( TCHAR** stopWords);
+		StandardAnalyzer( const TCHAR** stopWords);
 
 		~StandardAnalyzer();
 

Modified: trunk/clucene/src/CLucene/analysis/standard/StandardFilter.cpp
===================================================================
--- trunk/clucene/src/CLucene/analysis/standard/StandardFilter.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/analysis/standard/StandardFilter.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "StandardFilter.h"
 

Modified: trunk/clucene/src/CLucene/analysis/standard/StandardFilter.h
===================================================================
--- trunk/clucene/src/CLucene/analysis/standard/StandardFilter.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/analysis/standard/StandardFilter.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_analysis_standard_StandardFilter
 #define _lucene_analysis_standard_StandardFilter
 

Modified: trunk/clucene/src/CLucene/analysis/standard/StandardTokenizer.cpp
===================================================================
--- trunk/clucene/src/CLucene/analysis/standard/StandardTokenizer.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/analysis/standard/StandardTokenizer.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "StandardTokenizer.h"
 
@@ -31,8 +22,8 @@
 
   #define DASH          (ch == '-')
   #define NEGATIVE_SIGN_ DASH
-  #define POSITIVE_SIGN_ (ch == '+')
-  #define SIGN          (NEGATIVE_SIGN_ || POSITIVE_SIGN_)
+  //#define POSITIVE_SIGN_ (ch == '+')
+  //#define SIGN          (NEGATIVE_SIGN_ || POSITIVE_SIGN_)
 
   #define DOT             (ch == '.')
   #define DECIMAL         DOT
@@ -49,7 +40,7 @@
   ** that's not an ALNUM or UNDERSCORE can be considered not to break the
   ** span.  Callers should pass false if only ALNUM/UNDERSCORE are acceptable. */
   #define CONSUME_WORD                  _CONSUME_AS_LONG_AS(ALNUM || UNDERSCORE)
-  #define CONSUME_WORD_OR(otherMatches) _CONSUME_AS_LONG_AS(ALNUM || UNDERSCORE || (otherMatches))
+  //#define CONSUME_WORD_OR(otherMatches) _CONSUME_AS_LONG_AS(ALNUM || UNDERSCORE || (otherMatches))
 
 
   /* It is considered that "nothing of value" has been read if:
@@ -66,7 +57,7 @@
   ** length indicator and move the terminator back by one character. */
   #define SHAVE_RIGHTMOST(sb) (sb.getBuffer()[--sb.len] = '\0')
 
-  #define REMOVE_TRAILING_CHARS(sb, charMatchesCondition) { TCHAR* sbBuf = sb.getBuffer(); for (int32_t i = sb.len-1; i >= 0; i--) { TCHAR c = sbBuf[i]; if (charMatchesCondition) { sbBuf[--sb.len] = '\0'; } else {break;}}}
+  //#define REMOVE_TRAILING_CHARS(sb, charMatchesCondition) { TCHAR* sbBuf = sb.getBuffer(); for (int32_t i = sb.len-1; i >= 0; i--) { TCHAR c = sbBuf[i]; if (charMatchesCondition) { sbBuf[--sb.len] = '\0'; } else {break;}}}
 
   /* Does StringBuffer sb contain any of the characters in string ofThese? */
   #define CONTAINS_ANY(sb, ofThese) (_tcscspn(sb.getBuffer(), _T(ofThese)) != static_cast<size_t>(sb.len))

Modified: trunk/clucene/src/CLucene/analysis/standard/StandardTokenizer.h
===================================================================
--- trunk/clucene/src/CLucene/analysis/standard/StandardTokenizer.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/analysis/standard/StandardTokenizer.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_analysis_standard_StandardTokenizer
 #define _lucene_analysis_standard_StandardTokenizer
 

Modified: trunk/clucene/src/CLucene/analysis/standard/StandardTokenizerConstants.h
===================================================================
--- trunk/clucene/src/CLucene/analysis/standard/StandardTokenizerConstants.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/analysis/standard/StandardTokenizerConstants.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_analysis_standard_StandardTokenizerConstants
 #define _lucene_analysis_standard_StandardTokenizerConstants
 

Modified: trunk/clucene/src/CLucene/config/CompilerBcb.h
===================================================================
--- trunk/clucene/src/CLucene/config/CompilerBcb.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/CompilerBcb.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #if !defined(_lucene_COMPILER_BCB)
 #define _lucene_COMPILER_BCB
 
@@ -22,11 +13,6 @@
 #undef _CL_HAVE_STRTOLL
 #undef _CL_HAVE_WCSTOLL
 
-#ifndef _CL_HAVE_TCHAR_H
-#define _CL_HAVE_TCHAR_H  1
-#endif
-
-#define _BASE_THROW_TYPE CL_NS_STD(runtime_error)
 #define _LUCENE_PRAGMA_ONCE
 #define _LUCENE_PRAGMA_WARNINGS //tell lucene to display warnings using pragmas instead of #warning
 #define LUCENE_DISABLE_HASHING
@@ -76,6 +62,8 @@
    #define _ftime ::ftime
    #define _rename rename
    
+   #define _realpath(rel,abs) _fullpath(abs,rel,CL_MAX_PATH)
+   
 #elif !defined(_lucene_COMPILER_BCB3)
 #define _lucene_COMPILER_BCB3
   //third inclusion

Modified: trunk/clucene/src/CLucene/config/CompilerGcc.h
===================================================================
--- trunk/clucene/src/CLucene/config/CompilerGcc.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/CompilerGcc.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #if !defined(_lucene_COMPILER_GCC)
 #define _lucene_COMPILER_GCC
 
@@ -21,34 +12,6 @@
    #include "CLucene/clucene-config.h" //make clucene-config.h file
 #endif
 
-//re-define some of the _CL prefixes...
-#if defined(_CL__ASCII) && !defined(_ASCII)
- #define _ASCII _CL__ASCII
-#endif
-#if defined(_CL__UCS2) && !defined(_UCS2)
- #define _UCS2 _CL__UCS2
-#endif
-#if defined(_CL__DEBUG) && !defined(_DEBUG)
- #define _DEBUG _CL__DEBUG
-#endif
-#if defined(_CL__FILE_OFFSET_BITS) && !defined(_FILE_OFFSET_BITS)
- #define _FILE_OFFSET_BITS _CL__FILE_OFFSET_BITS
-#endif
-#if defined(_CL__LARGE_FILES) && !defined(_LARGE_FILES)
- #define _LARGE_FILES _CL__LARGE_FILES
-#endif
-#if defined(__cl_uint32_t) && !defined(uint32_t)
- #define uint32_t __cl_uint32_t
-#endif
-#if defined(__cl_uint64_t) && !defined(uint64_t)
- #define uint64_t __cl_uint64_t
-#endif
-#if defined(__cl_uint8_t) && !defined(uint8_t)
- #define uint8_t __cl_uint8_t
-#endif
-//end redefine defaults
-
-
 #if defined(_ASCII)
  #undef _UCS2
 #elif defined(_UCS2)
@@ -57,30 +20,27 @@
  #define CL_CHARSET_GUESS
 #endif
 
+//dont allow FS_MMAP if mmap is not available
 #if defined(LUCENE_FS_MMAP) && !defined(_CL_HAVE_MMAP)
-	#undef LUCENE_FS_MMAP
+	#error "LUCENE_FS_MMAP is defined and MMap doesn't appear to be available"
 #endif
 
 #ifdef _CL_HAVE_NO_FUNCTION_TRY_BLOCKS
     #undef  _LUCENE_DISABLE_EXCEPTIONS
     #define _LUCENE_DISABLE_EXCEPTIONS
     
-    #error this is bad if you made it here... your compiler seems not to have try/catch blocks.
-    #error maybe you could implement an alternative solution for us? :)
-#else
-    #define _BASE_THROW_TYPE CL_NS_STD(runtime_error)
+    #error "this is bad if you made it here... your compiler seems not to have try/catch blocks."
+    #error "maybe you could implement an alternative solution for us? :)"
 #endif
 
 #ifndef _CL_HAVE_NAMESPACES
 	#define DISABLE_NAMESPACE
 #endif
 
-#define _LUCENE_CURRTHREADID pthread_self()
-#define _LUCENE_THREADID_TYPE pthread_t
-
 #define CL_NS_HASHING(func) __gnu_cxx::func //todo: is this best way?
 #define LUCENE_DISABLE_HASHING
 
+//define the file functions
 #define fileSeek lseek
 #define fileSize _filelength
 #define fileStat stat
@@ -93,13 +53,23 @@
     #define fileTell(fhandle) fileSeek(fhandle, 0, SEEK_CUR)
 #endif
 
+//this is needed early on so that CL_MAX_PATH can be correctly determined
+//in the StdHeader.h. This was earlier causing problems with macosx.
+//:: crash was due to realpath() that expects an output arguments that
+//has at least the size of PATH_MAX (even if the result has a lower size)
+#include <limits.h>
+    
 #ifndef _CL_HAVE_WCHAR_T
     typedef unsigned short wchar_t;
 #endif
 
-#ifdef __CYGWIN__
+#if defined(__CYGWIN__)
    //cygwin seems to incorrectly define that it has wprintf???
    #undef _CL_HAVE_WPRINTF
+#elif defined(__MINGW32__)
+	#ifndef _CL_HAVE_WINDOWS_H
+		#define _CL_HAVE_WINDOWS_H
+	#endif
 #endif
 
 
@@ -110,13 +80,42 @@
     //second inclusion
 
     //types
-    #if defined(_CL_HAVE_INTTYPES_H)
-        #include <inttypes.h>
-    #endif
     #if defined(_CL_HAVE_SYS_TYPES_H)
         #include <sys/types.h>
     #endif
-    #include <limits.h>
+	#if defined(_CL_HAVE_INTTYPES_H)
+		#include <inttypes.h>
+	#elif defined(_CL_HAVE_STDINT_H)
+		#include <stdint.h>
+	#else
+		#if _CL_SIZEOF_UNSIGNED_LONG_LONG==8
+			typedef unsigned long long uint64_t;
+			typedef long long int64_t;
+		#elif _CL_SIZEOF_UNSIGNED_LONG==8
+			typedef unsigned long uint64_t;
+			typedef long int64_t;
+		#else
+			#error I do not know what to use for a uint64_t.
+		#endif
+		
+		/* Give us an unsigned 32-bit data type. */
+		#if _CL_SIZEOF_UNSIGNED_LONG==4
+			typedef unsigned long uint32_t;
+			typedef long int32_t;
+		#elif _CL_SIZEOF_UNSIGNED_INT==4
+			typedef unsigned int uint32_t;
+			typedef int int32_t;
+		#else
+			#error I do not know what to use for a uint32_t.
+		#endif
+
+		/* An unsigned 8-bit data type */
+		#if _CL_SIZEOF_UNSIGNED_CHAR==1
+			typedef unsigned char uint8_t;
+		#else
+			#error I do not know what to use for a uint8_t.
+		#endif
+	#endif
     
     //second chance to fix default settings
 	//this must be defined later, otherwise it messes up
@@ -126,18 +125,17 @@
 	    #define _read ::read
 	#endif
 
-
-  //now that int64_t is defined, we can define this...
+  	//now that int64_t is defined, we can define this...
 	#ifndef _CL_HAVE_FILELENGTH
 	    #undef fileSize
 	    #define fileSize lucene_filelength
 	    int64_t lucene_filelength(int handle);
 	#endif
-    
+
 #elif !defined(_lucene_COMPILER_GCC3)
 #define _lucene_COMPILER_GCC3
     //third inclusion
-    
+
 	#if !defined(__MINGW32__)
 	    //define replacements
 	    #define O_RANDOM 0
@@ -145,36 +143,20 @@
 	    #define O_BINARY 0
 	    #define _S_IREAD  0444
 	    #define _S_IWRITE 0333  // write and execute permissions
-	    
+
 	    //some functions that are needed - not charset dependent and not tchar type functions
 	    #define _open open
 	    #define _sleep(x) usleep(x*1000) //_sleep should be in millis, usleep is in micros
 	    #define _write write
 	    #define _snprintf snprintf
-	    
+
 	    //clucene uses ascii for filename interactions
-	    #define _fullpath(abs,rel,len) realpath(rel,abs)
+	    #define _realpath(rel,abs) realpath(rel,abs)
 	    #define _mkdir(x) mkdir(x,0777)
 	    #define _unlink unlink
+	#else
+	    #define _realpath(rel,abs) _fullpath(abs,rel,CL_MAX_PATH)
 	#endif
 	//also required by mingw
 	#define _rename rename
-   
-   
-	#if !defined(_CL_DISABLE_MULTITHREADING) && defined(_CL_HAVE_PTHREAD) && defined(_POSIX_THREADS)
-	class CLuceneThreadIdCompare
-	{
-	public:
-		enum
-		{	// parameters for hash table
-			bucket_size = 4,	// 0 < bucket_size
-			min_buckets = 8
-		};	// min_buckets = 2 ^^ N, 0 < N
-
-		bool operator()( pthread_t t1, pthread_t t2 ) const{
-			return t1 < t2;
-		}
-	};
-	#endif
-
 #endif

Modified: trunk/clucene/src/CLucene/config/CompilerMsvc.h
===================================================================
--- trunk/clucene/src/CLucene/config/CompilerMsvc.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/CompilerMsvc.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #if !defined(_lucene_COMPILER_MSVC)
 #define _lucene_COMPILER_MSVC
 
@@ -23,7 +14,9 @@
 #if (_MSC_VER >= 1300)
 //>= 7.0
 	# pragma warning(disable: 4512) // This would be very annoying
+	# pragma warning(disable: 4290) // Ignore exception specification warning
 	#define CL_NS_HASHING(func) stdext::func
+	#define LUCENE_STATIC_CONSTANT_SYNTAX 1
 
 #elif (_MSC_VER >= 1200)
 //6.0
@@ -39,7 +32,7 @@
 	#define _CLDELETE_LCaARRAY(x) if (x!=NULL){delete[] __CONST_CAST(char*,x);}
 	
 #endif
-	#define LUCENE_STATIC_CONSTANT(type, assignment) enum { assignment }
+	#define LUCENE_STATIC_CONSTANT_SYNTAX 2
 
 	# pragma warning(disable: 4786) // This would be very annoying
 	namespace std{
@@ -64,7 +57,6 @@
 #endif
 
 
-#define _BASE_THROW_TYPE exception
 #if _MSC_VER >= 1020
  #define _LUCENE_PRAGMA_ONCE
 #endif
@@ -73,9 +65,6 @@
 //if we are compiling using single-threaded libraries, we can disable multi-threading stuff
 #if !defined(_MT) && !defined(_CL_DISABLE_MULTITHREADING)
    #define _CL_DISABLE_MULTITHREADING
-#else
-	#define _LUCENE_CURRTHREADID GetCurrentThreadId()
-	#define _LUCENE_THREADID_TYPE DWORD
 #endif
 
 //msvc supports large files
@@ -96,6 +85,9 @@
 //_rename is not defined???
 #define _rename rename
 
+#define CL_MAX_PATH 260 //give the windef.h value for this...
+#define _realpath(rel,abs) _fullpath(abs,rel,CL_MAX_PATH)
+
 //java long type
 typedef __int64 int64_t; 
 typedef unsigned __int64 uint64_t;
@@ -125,21 +117,4 @@
 #elif !defined(_lucene_COMPILER_MSVC3)
 #define _lucene_COMPILER_MSVC3
   //third inclusion
-
-	#ifndef _CL_DISABLE_MULTITHREADING
-		class CLuceneThreadIdCompare
-		{
-		public:
-				
-			enum
-			{	// parameters for hash table
-				bucket_size = 4,	// 0 < bucket_size
-				min_buckets = 8
-			};	// min_buckets = 2 ^^ N, 0 < N
-
-			bool operator()( DWORD t1, DWORD t2 ) const{
-				return t1 < t2;
-			}
-		};
-	#endif
 #endif

Modified: trunk/clucene/src/CLucene/config/PlatformMac.h
===================================================================
--- trunk/clucene/src/CLucene/config/PlatformMac.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/PlatformMac.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 // It is internal CLucene header - DO NOT include it directly
 
 # define PATH_DELIMITER _T("/")

Modified: trunk/clucene/src/CLucene/config/PlatformUnix.h
===================================================================
--- trunk/clucene/src/CLucene/config/PlatformUnix.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/PlatformUnix.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 // It is internal CLucene header - DO NOT include it directly
 
 # define PATH_DELIMITER _T("/")

Modified: trunk/clucene/src/CLucene/config/PlatformWin32.h
===================================================================
--- trunk/clucene/src/CLucene/config/PlatformWin32.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/PlatformWin32.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 // It is internal CLucene header - DO NOT include it directly
 
 # define PATH_DELIMITER  _T("\\")

Modified: trunk/clucene/src/CLucene/config/compiler.h
===================================================================
--- trunk/clucene/src/CLucene/config/compiler.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/compiler.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #if !defined(lucene_compiler_h)
 #define lucene_compiler_h
 
@@ -45,7 +36,7 @@
     #define _CLCOMPILER_MSVC _MSC_VER
 #endif
 
-#ifdef __GNUC__
+#if defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__xlC__)
     #include "CLucene/config/CompilerGcc.h"
 
 #elif defined(_CLCOMPILER_MSVC)
@@ -111,15 +102,6 @@
  #undef _ASCII
 #endif
 
-
-#ifdef IS_BIG_ENDIAN
-	#ifdef _LUCENE_PRAGMA_WARNINGS
-	 #pragma message ("Big endian build hasn't been tested yet. Please send in your success/failure to the project.")
-	#else
-	 #warning "Big endian build hasn't been tested yet. Please send in your success/failure to the project."
-	#endif
-#endif
-
 #ifndef  _LUCENE_NO_NEW_STYLE_CASTS
     #define __CONST_CAST(typ,var) const_cast<typ>(var)
     #define __REINTERPRET_CAST(typ,var) reinterpret_cast<typ>(var)
@@ -145,41 +127,53 @@
 #define LUCENE_INT32_MAX_SHOULDBE 0x7FFFFFFFL
 #define LUCENE_UINT8_MAX_SHOULDBE 0xff
 
-#ifdef PATH_MAX
+//maximum path length. only used for buffers that use fullpath.
+//anything else should use a dynamic length.
+#if defined(CL_MAX_PATH)
+//do nothing...
+#elif defined(PATH_MAX)
  #define CL_MAX_PATH PATH_MAX
 #elif defined(MAX_PATH)
  #define CL_MAX_PATH MAX_PATH
 #elif defined(_MAX_PATH)
  #define CL_MAX_PATH _MAX_PATH
 #else
- #define CL_MAX_PATH 256    /* Should be safe for any weird systems that do not define it */
+ #error "CL_MAX_PATH could not be determined"
 #endif
 
-#ifndef MAX_DIR
- #ifdef DIR_MAX
-  #define MAX_DIR DIR_MAX
- #elif defined(_MAX_DIR)
-  #define MAX_DIR _MAX_DIR
- #else
-  #define MAX_DIR 32    /* Should be safe for any weird systems that do not define it */
- #endif
-#endif // MAX_DIR
+//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
+//todo: this is a temporary fix for a potential buffer overflow...
+//should never use this
+#define CL_MAX_DIR CL_MAX_PATH*32
 
-#define CL_MAX_DIR MAX_DIR*CL_MAX_PATH //32 directories * 256 bytes...
-
 #ifdef _LARGE_FILES
     #define LUCENE_MAX_FILELENGTH LUCENE_INT64_MAX_SHOULDBE
 #else
     #define LUCENE_MAX_FILELENGTH LUCENE_INT32_MAX_SHOULDBE
 #endif
 
+//use the LUCENE_STATIC_CONSTANT_SYNTAX to determine LUCENE_STATIC_CONSTANT
+#ifndef LUCENE_STATIC_CONSTANT
+	//autoconf is not properly detecting the correct method for this, and since there's no real big
+	//harm in always using an enum, we'll probably just make this the default.
+	/*#if LUCENE_STATIC_CONSTANT_SYNTAX == 1
+		#define LUCENE_STATIC_CONSTANT(type, assignment) static const type assignment
+	#elif LUCENE_STATIC_CONSTANT_SYNTAX == 2*/
+		#define LUCENE_STATIC_CONSTANT(type, assignment) enum { assignment }
+	/*#else
+		#error "LUCENE_STATIC_CONSTANT not defined, and/or LUCENE_STATIC_CONSTANT_SYNTAX is not defined to a valid value"
+	#endif*/
+#endif
+
 //end of lucene_compiler_h
 #elif !defined(lucene_compiler_h2)
 #define lucene_compiler_h2
 //here we include the compiler header again, this gives the header a
 //second chance at including stuff, after the main inclusions are complete
 
-    #if defined (__GNUC__)
+    #if defined (__GNUC__) || defined(__SUNPRO_CC) || defined(__xlC__)
         #include "CLucene/config/CompilerGcc.h"
     
     #elif defined(_CLCOMPILER_MSVC)
@@ -226,7 +220,7 @@
 //here we include the compiler header again, this gives the header a
 //third chance at including stuff, after the main inclusions are complete
  
-    #if defined (__GNUC__ )
+    #if defined (__GNUC__ ) || defined(__SUNPRO_CC) || defined(__xlC__)
         #include "CLucene/config/CompilerGcc.h"
     
     #elif defined(_CLCOMPILER_MSVC)

Modified: trunk/clucene/src/CLucene/config/define_std.h
===================================================================
--- trunk/clucene/src/CLucene/config/define_std.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/define_std.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef lucene_define_std
 #define lucene_define_std
 //define a standard list of defines. 

Modified: trunk/clucene/src/CLucene/config/gunichartables.cpp
===================================================================
--- trunk/clucene/src/CLucene/config/gunichartables.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/gunichartables.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -132,10 +132,9 @@
  #warning "===== Using internal character function ====="
 #endif
 
-bool cl_isletter(TCHAR ch)
+bool cl_isletter(gunichar c)
 {
-	gunichar c=ch;
-    int t = TYPE ((gunichar)c);
+    int t = TYPE (c);
     switch(t)
     {
       case G_UNICODE_LOWERCASE_LETTER: return true;
@@ -147,9 +146,8 @@
     }
 }
 
-bool cl_isalnum(TCHAR ch)
+bool cl_isalnum(gunichar c)
 {
-	gunichar c=ch;
     int t = TYPE (c);
     switch(t)
     {
@@ -165,10 +163,9 @@
     }
 }
 
-bool cl_isdigit(TCHAR ch)
+bool cl_isdigit(gunichar c)
 {
-	gunichar c=ch;
-    int t = TYPE ((gunichar)c);
+    int t = TYPE (c);
     switch(t)
     {
       case G_UNICODE_DECIMAL_NUMBER: return true;
@@ -192,9 +189,8 @@
  *
  * Return value: %TRUE if @c is a punctuation character
  **/
-bool cl_isspace (TCHAR ch)
+bool cl_isspace (gunichar c)
 {
-  gunichar c=ch;
   switch (c)
   {
       /* special-case these since Unicode thinks they are not spaces */
@@ -239,12 +235,9 @@
 		wchar_t ret=0;
 		lucene_utf8towc(&ret,p,6);
 #ifdef _UCS2
-		  return ret;
+		return ret;
 #else
-        if ( ret > 0x80 )
-           return LUCENE_OOR_CHAR;
-        else
-           return (char)ret;
+        return LUCENE_OOR_CHAR(ret);
 #endif
         //return cl_utf8_get_char (p, &len);
       }else
@@ -286,10 +279,7 @@
 #ifdef _UCS2
 	  return ret;
 #else
-     if ( ret > 0x80 )
-        return LUCENE_OOR_CHAR;
-     else
-        return (char)ret;
+      return LUCENE_OOR_CHAR(ret);
 #endif
 	  //return lucene_utf8towc (p);
 	}
@@ -345,12 +335,9 @@
 				   lucene_utf8towc(&ret,casefold_table[half].data,6);
 
                #ifdef _UCS2
-		               return ret;
+		           return ret;
                #else
-                     if ( ret > 0x80 )
-                        return LUCENE_OOR_CHAR;
-                     else
-                        return (char)ret;
+                   LUCENE_OOR_CHAR(ret)
                #endif
             }else if (half == start){
                 break;

Modified: trunk/clucene/src/CLucene/config/repl_lltot.cpp
===================================================================
--- trunk/clucene/src/CLucene/config/repl_lltot.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/repl_lltot.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 
 TCHAR* lucene_i64tot(

Modified: trunk/clucene/src/CLucene/config/repl_tchar.h
===================================================================
--- trunk/clucene/src/CLucene/config/repl_tchar.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/repl_tchar.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _CL_HAVE_TCHAR_H
 #if defined(_UCS2)
     #define TCHAR wchar_t

Modified: trunk/clucene/src/CLucene/config/repl_tcscasecmp.cpp
===================================================================
--- trunk/clucene/src/CLucene/config/repl_tcscasecmp.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/repl_tcscasecmp.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
  
 #include "CLucene/StdHeader.h"
 

Modified: trunk/clucene/src/CLucene/config/repl_tcslwr.cpp
===================================================================
--- trunk/clucene/src/CLucene/config/repl_tcslwr.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/repl_tcslwr.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
  
 #include "CLucene/StdHeader.h"
 

Modified: trunk/clucene/src/CLucene/config/repl_tcstod.cpp
===================================================================
--- trunk/clucene/src/CLucene/config/repl_tcstod.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/repl_tcstod.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
  
 #include "CLucene/StdHeader.h"
 

Modified: trunk/clucene/src/CLucene/config/repl_tcstoll.cpp
===================================================================
--- trunk/clucene/src/CLucene/config/repl_tcstoll.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/repl_tcstoll.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 
 #include "CLucene/StdHeader.h"
 

Modified: trunk/clucene/src/CLucene/config/repl_tprintf.cpp
===================================================================
--- trunk/clucene/src/CLucene/config/repl_tprintf.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/repl_tprintf.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,24 +1,15 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "CLucene/util/StringBuffer.h"
 
 #ifdef __CL_INCLUDE_TPRINTF
 
-CL_NS_USE(util);
+CL_NS_USE(util)
 
 //print a variable argument to a stream
 //currently special number formatting is not supported. it is very minimalistic

Modified: trunk/clucene/src/CLucene/config/repl_wchar.h
===================================================================
--- trunk/clucene/src/CLucene/config/repl_wchar.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/repl_wchar.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,21 +1,14 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_repl_wchar_h
 #define _lucene_repl_wchar_h
 
+#ifdef _UCS2
+
 #ifndef _CL_HAVE_WCSCPY
 	//copy a string to another string
 	#error wcscpy is not defined, and a licensed replacement has not been written yet
@@ -62,6 +55,8 @@
 	#error wcscspn is not defined, and a licensed replacement has not been written yet
 #endif
 
+#endif //_UCS2
+
 //string function replacements
 #if defined(LUCENE_USE_INTERNAL_CHAR_FUNCTIONS) || (defined(_UCS2) && !defined(_CL_HAVE_WCSCASECMP)) || (defined(_ASCII) && !defined(_CL_HAVE_STRCASECMP))
     int lucene_tcscasecmp(const TCHAR *, const TCHAR *);

Modified: trunk/clucene/src/CLucene/config/utf8.cpp
===================================================================
--- trunk/clucene/src/CLucene/config/utf8.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/config/utf8.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -78,12 +78,12 @@
   else									      \
     Len = -1;
 
-#define UTF8_LENGTH(Char)              \
+/*#define UTF8_LENGTH(Char)              \
   ((Char) < 0x80 ? 1 :                 \
    ((Char) < 0x800 ? 2 :               \
     ((Char) < 0x10000 ? 3 :            \
      ((Char) < 0x200000 ? 4 :          \
-      ((Char) < 0x4000000 ? 5 : 6)))))
+      ((Char) < 0x4000000 ? 5 : 6)))))*/
 
 
 #define UTF8_GET(Result, Chars, Count, Mask, Len)			      \

Modified: trunk/clucene/src/CLucene/debug/condition.cpp
===================================================================
--- trunk/clucene/src/CLucene/debug/condition.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/debug/condition.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "condition.h"
 #include "CLucene/util/Misc.h"

Modified: trunk/clucene/src/CLucene/debug/condition.h
===================================================================
--- trunk/clucene/src/CLucene/debug/condition.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/debug/condition.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef __CONDITION_H
 #define __CONDITION_H
 

Modified: trunk/clucene/src/CLucene/debug/error.cpp
===================================================================
--- trunk/clucene/src/CLucene/debug/error.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/debug/error.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,20 +1,10 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
-#include "CLucene/index/Term.h"
 
 CL_NS_USE(util)
 
@@ -72,8 +62,9 @@
 #ifndef _ASCII
 	CLuceneError::CLuceneError(int num, const TCHAR* str, bool ownstr)
 	{
-		_twhat=STRDUP_TtoT(str);
+		error_number = 0;
 		_awhat=NULL;
+		_twhat=STRDUP_TtoT(str);
 		if ( ownstr )
 			_CLDELETE_CARRAY(str);
     }

Modified: trunk/clucene/src/CLucene/debug/error.h
===================================================================
--- trunk/clucene/src/CLucene/debug/error.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/debug/error.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_debug_error_
 #define _lucene_debug_error_
 

Modified: trunk/clucene/src/CLucene/debug/lucenebase.h
===================================================================
--- trunk/clucene/src/CLucene/debug/lucenebase.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/debug/lucenebase.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_debug_lucenebase_
 #define _lucene_debug_lucenebase_
 
@@ -22,51 +13,63 @@
 
 CL_NS_DEF(debug)
 
+//Lucenebase is the superclass of all clucene objects. It provides
+//memory debugging tracking and/or reference counting
 class LuceneBase{
 public:
-#ifdef LUCENE_ENABLE_LUCENEBASE
-	static void* operator new (size_t size, char const * file, int_t line);
+#ifdef LUCENE_ENABLE_MEMLEAKTRACKING
 	static void* operator new (size_t size);
-	static void operator delete (void *p, char const * file, int_t line);
 	static void operator delete (void *p);
-	static int_t __cl_GetUnclosedObjectsCount();  ///< gets the number of unclosed objects
-	static const char* __cl_GetUnclosedObject(int_t item);  ///< get the name of the nth unclosed object
-	static TCHAR* __cl_GetUnclosedObjects();  ///< get a string with the names of the unclosed objects
+	int32_t __cl_initnum; ///< The order that the object was created at. This is then used to do a lookup in the objects list
+
+	static void* operator new (size_t size, char const * file, int32_t line);
+	static void operator delete (void *p, char const * file, int32_t line);
+
+	static void* __cl_voidpadd(void* data, const char* file, int line, size_t size); ///<add arbitary data to the lucenbase_list and returns the same data
+	static void __cl_voidpremove(const void* data, const char* file, int line);///<remove arbitary data to the lucenbase_list
+	static void __cl_unregister(const void* obj); ///<un register object from the mem leak and ref count system
+
+	static int32_t __cl_GetUnclosedObjectsCount();  ///< gets the number of unclosed objects
+	static const char* __cl_GetUnclosedObject(int32_t item);  ///< get the name of the nth unclosed object
+	static char* __cl_GetUnclosedObjects();  ///< get a string with the names of the unclosed objects
 	static void __cl_PrintUnclosedObjects(); ///< print unclosed objects to the stdout
-   static void __cl_ClearMemory(); ///< delete memory in refcounted list
+  
+  	///This will clear memory relating to refcounting
+	///other tools can be used to more accurately identify
+	///memory leaks. This should only be called just
+	///before closing, and after retrieving the
+	///unclosed object list
+  	static void __cl_ClearMemory();
 
-	int_t __cl_initnum; ///< The order that the object was created at.
-#else
-	static void* operator new (size_t size);
-	static void operator delete (void *p);
-#endif //LUCENE_ENABLE_LUCENEBASE
-#ifdef LUCENE_ENABLE_REFCOUNT
+#endif //LUCENE_ENABLE_MEMLEAKTRACKING
+
 	int __cl_refcount;
 	LuceneBase(){
-		__cl_refcount=0;
+		__cl_refcount=1;
 	}
-	int __cl_getref(){
+	inline int __cl_getref(){
 		return __cl_refcount;
 	}
-	void __cl_addref(){
+	inline int __cl_addref(){
 		__cl_refcount++;
+		return __cl_refcount;
 	}
-	int __cl_decref(){
-		return --__cl_refcount;
+	inline int __cl_decref(){
+		__cl_refcount--;
+		return __cl_refcount;
 	}
-#endif //LUCENE_ENABLE_REFCOUNT
+    virtual ~LuceneBase(){};
 };
 
-#ifdef LUCENE_ENABLE_REFCOUNT
-	//we use this in the _CLDELETE macro
-#ifdef _DEBUG
-	bool lucene_refCount_CanDelete(const LuceneBase* d, const char* file, const int_t line);
-	bool lucene_refCount_CanDelete(const void* d, const char* file, const int_t line);
-#else
-	bool lucene_refCount_CanDelete(const void* d);
-	bool lucene_refCount_CanDelete(const LuceneBase* d);
-#endif
-#endif
+class LuceneVoidBase{
+	public:
+	#ifdef _DEBUG
+		//a compile time check to make sure that _CLDELETE and _CLDECDELETE is being
+		//used correctly.
+		int dummy__see_mem_h_for_details; 
+	#endif
+        virtual ~LuceneVoidBase(){};
+};
 
 CL_NS_END
 #endif //_lucene_debug_lucenebase_

Modified: trunk/clucene/src/CLucene/debug/mem.h
===================================================================
--- trunk/clucene/src/CLucene/debug/mem.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/debug/mem.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,25 +1,17 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef _lucene_debug_lucenebase_
-#define _lucene_debug_lucenebase_
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
+#ifndef _lucene_debug_mem_h
+#define _lucene_debug_mem_h
 
 #if defined(_LUCENE_PRAGMA_ONCE)
 # pragma once
 #endif
 
+#include "lucenebase.h"
 
 //some memory pool definitions
 #ifdef LUCENE_ENABLE_MEMORY_POOL
@@ -104,65 +96,4 @@
 //into a LuceneBase*.
 #define _CLVDELETE(x) if(x!=NULL){delete x; x=NULL;}
 
-
-CL_NS_DEF(debug)
-class LuceneVoidBase{
-	public:
-	#ifdef _DEBUG
-		//a compile time check to make sure that _CLDELETE and _CLDECDELETE is being
-		//used correctly.
-		int dummy__see_mem_h_for_details; 
-	#endif
-        virtual ~LuceneVoidBase(){};
-};
-
-//Lucenebase is the superclass of all clucene objects. It provides
-//memory debugging tracking and/or reference counting
-class LuceneBase{
-public:
-#ifdef LUCENE_ENABLE_MEMLEAKTRACKING
-	static void* operator new (size_t size);
-	static void operator delete (void *p);
-	int32_t __cl_initnum; ///< The order that the object was created at. This is then used to do a lookup in the objects list
-
-	static void* operator new (size_t size, char const * file, int32_t line);
-	static void operator delete (void *p, char const * file, int32_t line);
-
-	static void* __cl_voidpadd(void* data, const char* file, int line, size_t size); ///<add arbitary data to the lucenbase_list and returns the same data
-	static void __cl_voidpremove(const void* data, const char* file, int line);///<remove arbitary data to the lucenbase_list
-	static void __cl_unregister(const void* obj); ///<un register object from the mem leak and ref count system
-
-	static int32_t __cl_GetUnclosedObjectsCount();  ///< gets the number of unclosed objects
-	static const char* __cl_GetUnclosedObject(int32_t item);  ///< get the name of the nth unclosed object
-	static TCHAR* __cl_GetUnclosedObjects();  ///< get a string with the names of the unclosed objects
-	static void __cl_PrintUnclosedObjects(); ///< print unclosed objects to the stdout
-  
-  ///This will clear memory relating to refcounting
-	///other tools can be used to more accurately identify
-	///memory leaks. This should only be called just
-	///before closing, and after retrieving the
-	///unclosed object list
-  static void __cl_ClearMemory();
-
-#endif //LUCENE_ENABLE_MEMLEAKTRACKING
-
-	int __cl_refcount;
-	LuceneBase(){
-		__cl_refcount=1;
-	}
-	inline int __cl_getref(){
-		return __cl_refcount;
-	}
-	inline int __cl_addref(){
-		__cl_refcount++;
-		return __cl_refcount;
-	}
-	inline int __cl_decref(){
-		__cl_refcount--;
-		return __cl_refcount;
-	}
-    virtual ~LuceneBase(){};
-};
-
-CL_NS_END
 #endif //_lucene_debug_lucenebase_

Modified: trunk/clucene/src/CLucene/debug/mempool.cpp
===================================================================
--- trunk/clucene/src/CLucene/debug/mempool.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/debug/mempool.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 
 #ifdef LUCENE_ENABLE_MEMORY_POOL

Modified: trunk/clucene/src/CLucene/debug/memtracking.cpp
===================================================================
--- trunk/clucene/src/CLucene/debug/memtracking.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/debug/memtracking.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,25 +1,14 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
-
-#include "CLucene/util/StringBuffer.h"
 #include "CLucene/util/Misc.h"
 
-bool _lucene_disable_debuglogging = true; //if LUCENE_ENABLE_CONSTRUCTOR_LOG is on, dont do log if this is true
-bool _lucene_run_objectcheck = false; //run a memory check before deleting objects
+static bool _lucene_disable_debuglogging = true; //if LUCENE_ENABLE_CONSTRUCTOR_LOG is on, dont do log if this is true
+static bool _lucene_run_objectcheck = false; //run a memory check before deleting objects
 int _lucene_counter_break = -1; //to break at this item, change this 
 							 //and put break points at points below
 
@@ -252,52 +241,48 @@
 ////////////////////////////////////////////////////////////
 //static
 void __internalcl_PrintUnclosedObject(bool isObject, string& sb,_pointers* bp,_file* bf, bool print){
-	sb.append(_T("   ") );
-
+	TCHAR ttmp[100];
+	char atmp[100];
+	
+	sb.append("   ");
 	{
-		char tmp[100];
-		itoa(bp->initnumber,tmp,10);
-		sb.append(tmp);
+		_i64tot(bp->initnumber,ttmp,10);
+		STRCPY_TtoA(atmp,ttmp,100);
+		sb.append(atmp);
 	}
 	if ( isObject ){
-		sb.append(_T("(obj). "));
+		sb.append("(obj). ");
 	}else{
-		sb.append(_T(". "));
+		sb.append(". ");
 	}
-
-	TCHAR tmp[CL_MAX_DIR];
-	/*if ( lb->__cl_initfile < 0 || lb->__cl_initfile >= LuceneBase_Files.size() )
-		_tcscpy(tmp,_T("unknown (filename lost), use number to identify object instead"));
-	else
-		STRCPY_AtoT(tmp,LuceneBase_Files.at(lb->__cl_initfile),CL_MAX_DIR);*/
-    STRCPY_AtoT(tmp,bf->value,CL_MAX_DIR);
-	sb.append(tmp);
-	
-	sb.append(_T(", line ") );
+	sb.append(bf->value);
+	sb.append(", line ");
 	{
-		char tmp[100];
-		itoa(bp->initline,tmp,10);
-		sb.append(tmp);
+		_i64tot(bp->initline,ttmp,10);
+		STRCPY_TtoA(atmp,ttmp,100);
+		sb.append(atmp);
 	}
-	sb.append(_T("\n"));
+	sb.append("\n");
 
 	if ( print && sb.length() > 0 ){
-		_tprintf(sb.c_str());
-		sb.clear();
+		printf("%s\n", sb.c_str());
+		sb = "";
 	}
 }
-TCHAR* __internalcl_GetUnclosedObjects(bool print){
+char* __internalcl_GetUnclosedObjects(bool print){
+	TCHAR ttmp[100];
+	char atmp[100];
 	SCOPED_LOCK_MUTEX(memleak_lock)
 
 	string sb;
     bool unknowns = false;
 	if ( LuceneBase_Pointers.size() > 0 ){
 		{
-			char tmp[100];
-			itoa((int32_t)LuceneBase_Pointers.size(),tmp,10);
-			sb.append(tmp);
+			_i64tot(LuceneBase_Pointers.size(),ttmp,10);
+			STRCPY_TtoA(atmp,ttmp,100);
+			sb.append(atmp);
 		}
-		sb.append(_T(" clucene objects are still open\n"));
+		sb.append(" clucene objects are still open\n");
 
 		defPointer::iterator itr = LuceneBase_Pointers.begin();
 		while ( itr != LuceneBase_Pointers.end() ){
@@ -308,7 +293,7 @@
 				unknowns = true;
 			__internalcl_PrintUnclosedObject(true, sb,bp,bf,print);
 
-			itr++;
+			++itr;
 		}
 
 		defVoid::iterator itr2 = LuceneBase_Voids.begin();
@@ -325,20 +310,20 @@
 	}
 
 	if ( unknowns == true ){
-		sb.append(_T("*** Some memory was not created with _CLNEW and was not tracked... ***\n") );
-		sb.append(_T("*** Use _CLNEW instead of new when creating CLucene objects ***\n") );
-		sb.append(_T("*** Memory may also have not been freed in the current context ***\n") );
+		sb.append("*** Some memory was not created with _CLNEW and was not tracked... ***\n");
+		sb.append("*** Use _CLNEW instead of new when creating CLucene objects ***\n");
+		sb.append("*** Memory may also have not been freed in the current context ***\n");
 	}
 	
 	if ( print ){
 		if ( sb.length() > 0 ){
-			_tprintf(sb.c_str());
-			sb.clear();
+			printf("%s\n", sb.c_str());
+			sb = "";
 		}
 		return NULL;
 	}else{
 		if ( sb.length() > 0 )
-			return stringDuplicate(sb.c_str());
+			return STRDUP_AtoA(sb.c_str());
 		else
 			return NULL;
 	}
@@ -356,7 +341,7 @@
    LuceneBase_Pointers.clear();
    LuceneBase_Voids.clear();
 }
-TCHAR* LuceneBase::__cl_GetUnclosedObjects(){
+char* LuceneBase::__cl_GetUnclosedObjects(){
 	return __internalcl_GetUnclosedObjects(false);
 }
 //static
@@ -370,7 +355,7 @@
    defPointer::iterator itr=LuceneBase_Pointers.begin();
    int32_t i=0;
    for ( ;itr!=LuceneBase_Pointers.end() && i<item ;itr++ ){
-      i++;
+      ++i;
    }
    if ( itr != LuceneBase_Pointers.end() )
       return itr->second->file->value;

Modified: trunk/clucene/src/CLucene/debug/pool.h
===================================================================
--- trunk/clucene/src/CLucene/debug/pool.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/debug/pool.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_debug_pool_
 #define _lucene_debug_pool_
 //this code is based on the boost memory pool library

Modified: trunk/clucene/src/CLucene/document/DateField.cpp
===================================================================
--- trunk/clucene/src/CLucene/document/DateField.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/document/DateField.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 
 #include "DateField.h"
@@ -20,48 +11,46 @@
 CL_NS_USE(util)
 CL_NS_DEF(document)
 
-	DateField::~DateField(){
-	}
+DateField::~DateField(){
+}
 	
-  TCHAR* DateField::timeToString(const int64_t time) {
-    if (time < 0)
-      _CLTHROWA (CL_ERR_IllegalArgument,"time too early");
-    /* DSR:2004.10.28: */
-    /* Check for too-late time here rather than after the _i64tot call
-    ** so as to avoid buffer overflow potential. */
-    if (time > DATEFIELD_DATE_MAX)
-      _CLTHROWA (CL_ERR_IllegalArgument, "time too late (past DATEFIELD_DATE_MAX");
+TCHAR* DateField::timeToString(const int64_t time) {
+	if (time < 0)
+	  _CLTHROWA (CL_ERR_IllegalArgument,"time too early"); //todo: make richer error
 
+	if (time > DATEFIELD_DATE_MAX)
+	  _CLTHROWA (CL_ERR_IllegalArgument, "time too late (past DATEFIELD_DATE_MAX"); //todo: make richer error
+	
 	 TCHAR* buf = _CL_NEWARRAY(TCHAR,DATEFIELD_DATE_LEN + 1);
-    _i64tot(time, buf, 36);
-    int32_t bufLen = _tcslen(buf);
-
-    CND_PRECONDITION (bufLen <= DATEFIELD_DATE_LEN, "timeToString length is greater than 9");
-
-    /* Supply leading zeroes if necessary. */
-    if (bufLen < DATEFIELD_DATE_LEN) {
-      const int32_t nMissingZeroes = DATEFIELD_DATE_LEN - bufLen;
-      /* Move buffer contents forward to make room for leading zeroes. */
-      for (int32_t i = DATEFIELD_DATE_LEN - 1; i >= nMissingZeroes; i--)
-        buf[i] = buf[i - nMissingZeroes];
-      
+	_i64tot(time, buf, 36);
+	int32_t bufLen = _tcslen(buf);
+	
+	CND_PRECONDITION (bufLen <= DATEFIELD_DATE_LEN, "timeToString length is greater than 9");
+	
+	/* Supply leading zeroes if necessary. */
+	if (bufLen < DATEFIELD_DATE_LEN) {
+	  const int32_t nMissingZeroes = DATEFIELD_DATE_LEN - bufLen;
+	  /* Move buffer contents forward to make room for leading zeroes. */
+	  for (int32_t i = DATEFIELD_DATE_LEN - 1; i >= nMissingZeroes; i--)
+	    buf[i] = buf[i - nMissingZeroes];
+	  
 	  {// MSVC6 scoping fix
 	  /* Insert leading zeroes. */
-      for (int32_t i = 0; i < nMissingZeroes; i++)
-        buf[i] = '0';
+	  for (int32_t i = 0; i < nMissingZeroes; i++)
+	    buf[i] = '0';
 	  }
+	
+	  buf[DATEFIELD_DATE_LEN] = 0;
+	}
+	
+	CND_PRECONDITION (_tcslen(buf) == DATEFIELD_DATE_LEN, "timeToString return is not equal to 9");
+	
+	return buf;
+}
 
-      buf[DATEFIELD_DATE_LEN] = 0;
-    }
+int64_t DateField::stringToTime(const TCHAR* time) {
+	TCHAR* end;
+	return _tcstoi64(time, &end, 36);
+}
 
-    CND_PRECONDITION (_tcslen(buf) == DATEFIELD_DATE_LEN, "timeToString return is not equal to 9");
-
-    return buf;
-  }
-
-  int64_t DateField::stringToTime(const TCHAR* time) {
-    TCHAR* end;
-    return _tcstoi64(time, &end, 36);
-  }
-
 CL_NS_END

Modified: trunk/clucene/src/CLucene/document/DateField.h
===================================================================
--- trunk/clucene/src/CLucene/document/DateField.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/document/DateField.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_document_DateField_
 #define _lucene_document_DateField_
 
@@ -28,41 +19,40 @@
 
 #define DATEFIELD_DATE_LEN 9 ////Long.toString(DATEFIELD_DATE_MAX, Character.MAX_RADIX).length()
 
-  /**
- * Provides support for converting dates to strings and vice-versa.
- * The strings are structured so that lexicographic sorting orders by date,
- * which makes them suitable for use as field values and search terms.
- * 
- * <P>
- * Note that you do not have to use this class, you can just save your
- * dates as strings if lexicographic sorting orders them by date. This is
- * the case for example for dates like <code>yyyy-mm-dd hh:mm:ss</code>
- * (of course you can leave out the delimiter characters to save some space).
- * The advantage with using such a format is that you can easily save dates
- * with the required granularity, e.g. leaving out seconds. This saves memory
- * when searching with a RangeQuery or PrefixQuery, as Lucene
- * expands these queries to a BooleanQuery with potentially very many terms. 
- * 
- * <P>
- * Note: dates before 1970 cannot be used, and therefore cannot be
- * indexed when using this class.
- */
-  class DateField :LUCENE_BASE {
-  private:
-    static void initDS();
-  public:
-  	~DateField();
-
-    /**
-   * Converts a millisecond time to a string suitable for indexing.
-   * @throws RuntimeException if the time specified in the
-   * method argument is negative, that is, before 1970
-   */
-    static TCHAR* timeToString(const int64_t time);
-
-    /** Converts a string-encoded date into a millisecond time. */
-    static int64_t stringToTime(const TCHAR* s);
-
-  };
+/**
+* Provides support for converting dates to strings and vice-versa.
+* The strings are structured so that lexicographic sorting orders by date,
+* which makes them suitable for use as field values and search terms.
+*
+* <P>Note that this class saves dates with millisecond granularity,
+* which is bad for {@link RangeQuery} and {@link PrefixQuery}, as those
+* queries are expanded to a BooleanQuery with a potentially large number
+* of terms when searching. Thus you might want to use
+* {@link DateTools} instead.
+*
+* <P>
+* Note: dates before 1970 cannot be used, and therefore cannot be
+* indexed when using this class. See {@link DateTools} for an
+* alternative without such a limitation.
+*
+* @deprecated If you build a new index, use {@link DateTools} instead. This class is included for use with existing
+* indices and will be removed in a future release.
+*/
+class DateField :LUCENE_BASE {
+private:
+	static void initDS();
+public:
+	~DateField();
+	
+	/**
+	* Converts a millisecond time to a string suitable for indexing.
+	* @throws RuntimeException if the time specified in the
+	* method argument is negative, that is, before 1970
+	*/
+	static TCHAR* timeToString(const int64_t time);
+	
+	/** Converts a string-encoded date into a millisecond time. */
+	static int64_t stringToTime(const TCHAR* s);
+};
 CL_NS_END
 #endif

Modified: trunk/clucene/src/CLucene/document/Document.cpp
===================================================================
--- trunk/clucene/src/CLucene/document/Document.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/document/Document.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "Document.h"
 #include "Field.h"
@@ -130,13 +121,12 @@
 
 	const TCHAR* Document::get(const TCHAR* field) const {
 	    CND_PRECONDITION(field != NULL, "field is NULL");
-
 		Field *f = getField(field);
 		if (f!=NULL)
-			return f->stringValue();
+			return f->stringValue(); //this returns null it is a binary(reader)
 		else
 			return NULL;
-	} ///<returns reference
+	}
 
 	DocumentFieldEnumeration* Document::fields() const {
 		return _CLNEW DocumentFieldEnumeration(fieldList);
@@ -210,8 +200,9 @@
       DocumentFieldEnumeration* it = fields();
       int32_t count = 0;
       while ( it->hasMoreElements() ){
+      	Field* f = it->nextElement();
          //cannot use interning here, because name is probably not interned
-         if ( _tcscmp(it->nextElement()->name(),name) == 0 )
+         if ( _tcscmp(f->name(),name) == 0 && f->stringValue() != NULL )
             count++;
       }
       _CLDELETE(it);
@@ -225,7 +216,7 @@
          int32_t i=0;
          while ( it->hasMoreElements() ){
             Field* fld=it->nextElement();
-            if ( _tcscmp(fld->name(),name)== 0 ){
+            if ( _tcscmp(fld->name(),name)== 0 && fld->stringValue() != NULL ){
                ret[i] = stringDuplicate(fld->stringValue());
                i++;
             }

Modified: trunk/clucene/src/CLucene/document/Document.h
===================================================================
--- trunk/clucene/src/CLucene/document/Document.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/document/Document.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_document_Document_
 #define _lucene_document_Document_
 
@@ -26,135 +17,136 @@
 ///to using a java List... do we want to do this too?
 CL_NS_DEF(document)
 
-   ///\exclude Internal field enumeration
-	class DocumentFieldList :LUCENE_BASE{
-	public:
-		DocumentFieldList(Field* f, DocumentFieldList* n);
-		~DocumentFieldList();
-		Field* field;
-		DocumentFieldList* next;
-	};
+///\exclude Internal field enumeration
+class DocumentFieldList :LUCENE_BASE{
+public:
+	DocumentFieldList(Field* f, DocumentFieldList* n);
+	~DocumentFieldList();
+	Field* field;
+	DocumentFieldList* next;
+};
 
-	class DocumentFieldEnumeration :LUCENE_BASE{
-	private:
-		const DocumentFieldList* fields;
-	public:
-		DocumentFieldEnumeration(const DocumentFieldList* fl);
-		~DocumentFieldEnumeration();
-		bool hasMoreElements() const;
-		Field* nextElement();
-	};
+class DocumentFieldEnumeration :LUCENE_BASE{
+private:
+	const DocumentFieldList* fields;
+public:
+	DocumentFieldEnumeration(const DocumentFieldList* fl);
+	~DocumentFieldEnumeration();
+	bool hasMoreElements() const;
+	Field* nextElement();
+};
 
-   /** Documents are the unit of indexing and search.
-   *
-   * A Document is a set of fields.  Each field has a name and a textual value.
-   * A field may be {@link Field#isStored() stored} with the document, in which
-   * case it is returned with search hits on the document.  Thus each document
-   * should typically contain one or more stored fields which uniquely identify
-   * it.
-   *
-   * <p>Note that fields which are <i>not</i> {@link Field#isStored() stored} are
-   * <i>not</i> available in documents retrieved from the index, e.g. with {@link
-   * Hits#doc(int32_t)}, {@link Searcher#doc(int32_t)} or {@link
-   * IndexReader#document(int32_t)}.
-   */
-	class Document:LUCENE_BASE {
-	private:
-		DocumentFieldList* fieldList;
-      float_t boost;
-	public:
-		Document();
-      ~Document();
+/** Documents are the unit of indexing and search.
+*
+* A Document is a set of fields.  Each field has a name and a textual value.
+* A field may be {@link Field#isStored() stored} with the document, in which
+* case it is returned with search hits on the document.  Thus each document
+* should typically contain one or more stored fields which uniquely identify
+* it.
+*
+* <p>Note that fields which are <i>not</i> {@link Field#isStored() stored} are
+* <i>not</i> available in documents retrieved from the index, e.g. with {@link
+* Hits#doc(int32_t)}, {@link Searcher#doc(int32_t)} or {@link
+* IndexReader#document(int32_t)}.
+*/
+class Document:LUCENE_BASE {
+private:
+	DocumentFieldList* fieldList;
+	float_t boost;
+public:
+	Document();
+	~Document();
+	
+	/**
+	* <p>Adds a field to a document.  Several fields may be added with
+	* the same name.  In this case, if the fields are indexed, their text is
+	* treated as though appended for the purposes of search.</p>
+	* <p> Note that add like the removeField(s) methods only makes sense 
+	* prior to adding a document to an index. These methods cannot
+	* be used to change the content of an existing index! In order to achieve this,
+	* a document has to be deleted from an index and a new changed version of that
+	* document has to be added.</p>
+	*
+	*/
+	void add(Field& field);
+	/** Returns a field with the given name if any exist in this document, or
+	* null.  If multiple fields exists with this name, this method returns the
+	* first value added. 
+	* Note: name is case sensitive
+	*/
+	Field* getField(const TCHAR* name) const;
+	
+	/** Returns the string value of the field with the given name if any exist in
+	* this document, or null.  If multiple fields exist with this name, this
+	* method returns the first value added. If only binary fields with this name
+	* exist, returns null.
+	*/
+	const TCHAR* get(const TCHAR* field) const;
+	
+	/** Returns an Enumeration of all the fields in a document. */
+	DocumentFieldEnumeration* fields() const;
+	/** Prints the fields of a document for human consumption. */
+	TCHAR* toString() const;
+	
+	/** Sets a boost factor for hits on any field of this document.  This value
+	* will be multiplied into the score of all hits on this document.
+	*
+	* <p>Values are multiplied into the value of {@link Field#getBoost()} of
+	* each field in this document.  Thus, this method in effect sets a default
+	* boost for the fields of this document.
+	*
+	* @see Field#setBoost(float_t)
+	*/
+	void setBoost(float_t boost);
+	
+	/** Returns the boost factor for hits on any field of this document.
+	*
+	* <p>The default value is 1.0.
+	*
+	* <p>Note: This value is not stored directly with the document in the index.
+	* Documents returned from {@link IndexReader#document(int32_t)} and
+	* {@link Hits#doc(int32_t)} may thus not have the same value present as when
+	* this document was indexed.
+	*
+	* @see #setBoost(float_t)
+	*/
+	float_t getBoost() const;
+	
+	/**
+	* <p>Removes field with the specified name from the document.
+	* If multiple fields exist with this name, this method removes the first field that has been added.
+	* If there is no field with the specified name, the document remains unchanged.</p>
+	* <p> Note that the removeField(s) methods like the add method only make sense 
+	* prior to adding a document to an index. These methods cannot
+	* be used to change the content of an existing index! In order to achieve this,
+	* a document has to be deleted from an index and a new changed version of that
+	* document has to be added.</p>
+	* Note: name is case sensitive
+	*/
+	void removeField(const TCHAR* name);
+	
+	/**
+	* <p>Removes all fields with the given name from the document.
+	* If there is no field with the specified name, the document remains unchanged.</p>
+	* <p> Note that the removeField(s) methods like the add method only make sense 
+	* prior to adding a document to an index. These methods cannot
+	* be used to change the content of an existing index! In order to achieve this,
+	* a document has to be deleted from an index and a new changed version of that
+	* document has to be added.</p>
+	* Note: name is case sensitive
+	*/
+	void removeFields(const TCHAR* name);
 
-	  /**
-	   * <p>Adds a field to a document.  Several fields may be added with
-	   * the same name.  In this case, if the fields are indexed, their text is
-	   * treated as though appended for the purposes of search.</p>
-	   * <p> Note that add like the removeField(s) methods only makes sense 
-	   * prior to adding a document to an index. These methods cannot
-	   * be used to change the content of an existing index! In order to achieve this,
-	   * a document has to be deleted from an index and a new changed version of that
-	   * document has to be added.</p>
-	   *
-	   */
-		void add(Field& field);
-	  /** Returns a field with the given name if any exist in this document, or
-	   * null.  If multiple fields exists with this name, this method returns the
-	   * first value added. 
-	   * Note: name is case sensitive
-	   */
-		Field* getField(const TCHAR* name) const;
-		
-	  /** Returns the string value of the field with the given name if any exist in
-	   * this document, or null.  If multiple fields exist with this name, this
-	   * method returns the first value added.
-	   * Note: name is case sensitive
-	   */
-		const TCHAR* get(const TCHAR* field) const;
-		/// Returns an Enumeration of all the fields in a document.
-		DocumentFieldEnumeration* fields() const;
-  	/** Prints the fields of a document for human consumption. */
-		TCHAR* toString() const;
+	/**
+	* Returns an array of values of the field specified as the method parameter.
+	* This method can return <code>null</code>.
+	* Note: name is case sensitive
+	*
+	* @param name the name of the field
+	* @return a <code>String[]</code> of field values
+	*/
+	TCHAR** getValues(const TCHAR* name);
+};
 
-	   /** Sets a boost factor for hits on any field of this document.  This value
-	   * will be multiplied into the score of all hits on this document.
-	   *
-	   * <p>Values are multiplied into the value of {@link Field#getBoost()} of
-	   * each field in this document.  Thus, this method in effect sets a default
-	   * boost for the fields of this document.
-	   *
-	   * @see Field#setBoost(float_t)
-	   */
-      void setBoost(float_t boost);
-      
-   		/** Returns the boost factor for hits on any field of this document.
-      *
-      * <p>The default value is 1.0.
-      *
-      * <p>Note: This value is not stored directly with the document in the index.
-      * Documents returned from {@link IndexReader#document(int32_t)} and
-      * {@link Hits#doc(int32_t)} may thus not have the same value present as when
-      * this document was indexed.
-      *
-      * @see #setBoost(float_t)
-      */
-      float_t getBoost() const;
-
-
-	   /**
-	   * <p>Removes field with the specified name from the document.
-	   * If multiple fields exist with this name, this method removes the first field that has been added.
-	   * If there is no field with the specified name, the document remains unchanged.</p>
-	   * <p> Note that the removeField(s) methods like the add method only make sense 
-	   * prior to adding a document to an index. These methods cannot
-	   * be used to change the content of an existing index! In order to achieve this,
-	   * a document has to be deleted from an index and a new changed version of that
-	   * document has to be added.</p>
-	   * Note: name is case sensitive
-	   */
-      void removeField(const TCHAR* name);
-        
-	   /**
-	   * <p>Removes all fields with the given name from the document.
-	   * If there is no field with the specified name, the document remains unchanged.</p>
-	   * <p> Note that the removeField(s) methods like the add method only make sense 
-	   * prior to adding a document to an index. These methods cannot
-	   * be used to change the content of an existing index! In order to achieve this,
-	   * a document has to be deleted from an index and a new changed version of that
-	   * document has to be added.</p>
-	   * Note: name is case sensitive
-	   */
-      void removeFields(const TCHAR* name);
-
-	   /**
-	   * Returns an array of values of the field specified as the method parameter.
-	   * This method can return <code>null</code>.
-	   * Note: name is case sensitive
-	   *
-	   * @param name the name of the field
-	   * @return a <code>String[]</code> of field values
-	   */
-      TCHAR** getValues(const TCHAR* name);
-	};
 CL_NS_END
 #endif

Modified: trunk/clucene/src/CLucene/document/Field.cpp
===================================================================
--- trunk/clucene/src/CLucene/document/Field.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/document/Field.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "CLucene/util/Reader.h"
 #include "Field.h"

Modified: trunk/clucene/src/CLucene/document/Field.h
===================================================================
--- trunk/clucene/src/CLucene/document/Field.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/document/Field.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_document_Field_
 #define _lucene_document_Field_
 

Modified: trunk/clucene/src/CLucene/index/CompoundFile.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/CompoundFile.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/CompoundFile.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "CompoundFile.h"
 #include "CLucene/util/Misc.h"
@@ -61,7 +52,7 @@
    bool success = false;
 
    try {
-      stream = dir->openFile(name);
+      stream = dir->openInput(name);
 
       // read the directory and init files
       int32_t count = stream->readVInt();
@@ -125,7 +116,7 @@
   }
 }
 
-IndexInput* CompoundFileReader::openFile(const char* id){
+IndexInput* CompoundFileReader::openInput(const char* id){
   SCOPED_LOCK_MUTEX(THIS_LOCK)
 
   if (stream == NULL)
@@ -166,7 +157,7 @@
   directory->touchFile(fileName);
 }
 
-void CompoundFileReader::deleteFile(const char* name, const bool throwError){
+bool CompoundFileReader::deleteFile(const char* name){
    _CLTHROWA(CL_ERR_UnsupportedOperation,"UnsupportedOperationException");
 }
 
@@ -184,7 +175,7 @@
   }
   return e->length;
 }
-IndexOutput* CompoundFileReader::createFile(const char* name){
+IndexOutput* CompoundFileReader::createOutput(const char* name){
    _CLTHROWA(CL_ERR_UnsupportedOperation,"UnsupportedOperationException");
 }
 LuceneLock* CompoundFileReader::makeLock(const char* name){
@@ -255,7 +246,7 @@
   // open the compound stream
   IndexOutput* os = NULL;
   try {
-      os = directory->createFile(fileName);
+      os = directory->createOutput(fileName);
 
       // Write the number of entries
       os->writeVInt(entries.size());
@@ -307,7 +298,7 @@
   try {
       int64_t startPtr = os->getFilePointer();
 
-      is = directory->openFile(source->file);
+      is = directory->openInput(source->file);
       int64_t length = is->length();
       int64_t remainder = length;
       int32_t chunk = bufferLength;

Modified: trunk/clucene/src/CLucene/index/CompoundFile.h
===================================================================
--- trunk/clucene/src/CLucene/index/CompoundFile.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/CompoundFile.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_compoundfile_h
 #define _lucene_index_compoundfile_h
 
@@ -38,7 +29,7 @@
  *
  */
 class CompoundFileReader: public CL_NS(store)::Directory {
-
+private:
 	/** Implementation of an IndexInput that reads from a portion of the
 	*  compound file. The visibility is left as "package" *only* because
 	*  this helps with testing since JUnit test cases in a different class
@@ -85,7 +76,6 @@
 		}
 	};
 
-private:
 	// Base info
 	CL_NS(store)::Directory* directory;
 	char fileName[CL_MAX_PATH];
@@ -104,7 +94,7 @@
 	char* getName();
 
 	void close();
-	CL_NS(store)::IndexInput* openFile(const char* id);
+	CL_NS(store)::IndexInput* openInput(const char* id);
 
 	/** Returns an array of strings, one for each file in the directory-> */
 	char** list() const;
@@ -115,7 +105,7 @@
 	/** Set the modified time of an existing file to now. */
 	void touchFile(const char* name);
 	/** Removes an existing file in the directory-> */
-	void deleteFile(const char* name, const bool throwError = true);
+	bool deleteFile(const char* name);
 	/** Renames an existing file in the directory->
 	If a file already exists with the new name, then it is replaced.
 	This replacement should be atomic. */
@@ -124,7 +114,7 @@
 	int64_t fileLength(const char* name) const;
 	/** Creates a new, empty file in the directory with the given name.
 	Returns a stream writing this file. */
-	CL_NS(store)::IndexOutput* createFile(const char* name);
+	CL_NS(store)::IndexOutput* createOutput(const char* name);
 	/** Construct a {@link Lock}.
 	* @param name the name of the lock file
 	*/
@@ -177,7 +167,6 @@
 
 	};
 
-private:
 	CL_NS(store)::Directory* directory;
 	char fileName[CL_MAX_PATH];
 	CL_NS(util)::CLHashMap<char*, void*,

Modified: trunk/clucene/src/CLucene/index/DocumentWriter.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/DocumentWriter.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/DocumentWriter.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 
 #include "DocumentWriter.h"
@@ -36,7 +27,7 @@
 CL_NS_DEF(index)
 
     /*Posting*/
-	int32_t Posting::getPositionsLength(){
+	int32_t Posting::getPositionsLength() const{
 		return positionsLength;
 	}
 	  
@@ -72,7 +63,7 @@
 			similarity(sim),
 			fieldPositions(NULL),
 			fieldBoosts(NULL),
-			termBuffer(_CLNEW Term( LUCENE_BLANK_STRING, LUCENE_BLANK_STRING ,false)){
+			termBuffer(_CLNEW Term( LUCENE_BLANK_STRING, LUCENE_BLANK_STRING )){
     //Pre  - d contains a valid reference to a Directory
     //       d contains a valid reference to a Analyzer
     //       mfl > 0 and contains the maximum field length
@@ -104,7 +95,7 @@
 			_CLDELETE(itr->second);
 			_CLLDECDELETE(itr->first);
 
-			itr++;
+			++itr;
 		}
 		postingTable.clear();
 	}
@@ -189,7 +180,7 @@
 	}
 
 
-  void DocumentWriter::invertDocument(Document* doc) {
+  void DocumentWriter::invertDocument(const Document* doc) {
     DocumentFieldEnumeration* fields = doc->fields();
     try {
        while (fields->hasMoreElements()) {
@@ -303,7 +294,7 @@
                                          const TCHAR* text,
                                          const int32_t position) {
         
-		termBuffer->set(field,text, true );
+		termBuffer->set(field,text);
 
 		Posting* ti = postingTable.get(termBuffer);
 		if (ti != NULL) {				  // word seen before
@@ -380,8 +371,8 @@
 		quickSort(postings, left + 1, hi);
 	}
 
-    #define __DOCLOSE(obj) if(obj!=NULL){ try{ obj->close(); _CLDELETE(obj);} catch(CLuceneError &e){ierr=e.number();err=e.what();} catch(...){err="Unknown error while closing posting tables";} }
-	void DocumentWriter::writePostings(Posting** postings, const int32_t postingsLength, const char* segment){
+    void DocumentWriter::writePostings(Posting** postings, const int32_t postingsLength, const char* segment){
+		#define __DOCLOSE(obj) if(obj!=NULL){ try{ obj->close(); _CLDELETE(obj);} catch(CLuceneError &e){ierr=e.number();err=e.what();} catch(...){err="Unknown error while closing posting tables";} }
 		IndexOutput* freq = NULL;
 		IndexOutput* prox = NULL;
 		TermInfosWriter* tis = NULL;
@@ -389,11 +380,11 @@
 		try {
          //open files for inverse index storage
 		   const char* buf = Misc::segmentname( segment, ".frq");
-			freq = directory->createFile( buf );
+			freq = directory->createOutput( buf );
 			_CLDELETE_CaARRAY( buf );
 			
 			buf = Misc::segmentname( segment, ".prx");
-			prox = directory->createFile( buf );
+			prox = directory->createOutput( buf );
 			_CLDELETE_CaARRAY( buf );
 
 			tis = _CLNEW TermInfosWriter(directory, segment, fieldInfos);
@@ -448,8 +439,8 @@
             termVectorWriter->closeDocument();
 			_CLDELETE(ti);
         }_CLFINALLY ( 
-            char* err=NULL;
-					  int32_t ierr=0;
+            const char* err=NULL;
+			int32_t ierr=0;
 
             // make an effort to close all streams we can but remember and re-throw
             // the first exception encountered in this process
@@ -462,7 +453,7 @@
         );
 	}
 
-	void DocumentWriter::writeNorms(Document* doc, const char* segment) {
+	void DocumentWriter::writeNorms(const Document* doc, const char* segment) {
       char fn[CL_MAX_PATH];
       for(int32_t n = 0; n < fieldInfos->size(); n++){
          FieldInfo* fi = fieldInfos->fieldInfo(n);
@@ -470,7 +461,7 @@
             float_t norm = fieldBoosts[n] * similarity->lengthNorm(fi->name, fieldLengths[n]);
 
             _snprintf(fn,CL_MAX_PATH,"%s.f%d",segment,n);
-            IndexOutput* norms = directory->createFile(fn);
+            IndexOutput* norms = directory->createOutput(fn);
             try {
                norms->writeByte(CL_NS(search)::Similarity::encodeNorm(norm));
 				}_CLFINALLY ( 

Modified: trunk/clucene/src/CLucene/index/DocumentWriter.h
===================================================================
--- trunk/clucene/src/CLucene/index/DocumentWriter.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/DocumentWriter.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_DocumentWriter_
 #define _lucene_index_DocumentWriter_
 
@@ -40,7 +31,7 @@
 		Term* term;					  // the Term
 		int32_t freq;					  // its frequency in doc
 		
-		int32_t getPositionsLength();
+		int32_t getPositionsLength() const;
 		Posting(Term* t, const int32_t position);
 		~Posting();
 	};
@@ -51,10 +42,10 @@
 		CL_NS(analysis)::Analyzer* analyzer;
 		CL_NS(store)::Directory* directory;
 		FieldInfos* fieldInfos; //array
-      int32_t* fieldPositions; //array
-      float_t* fieldBoosts; //array
+		int32_t* fieldPositions; //array
+		float_t* fieldBoosts; //array
 		const int32_t maxFieldLength;
-      CL_NS(search)::Similarity* similarity;
+		CL_NS(search)::Similarity* similarity;
 
 		// Keys are Terms, values are Postings.
 		// Used to buffer a document before it is written to the index.
@@ -79,7 +70,7 @@
 
 	private:
 		// Tokenizes the fields of a document into Postings.
-		void invertDocument(CL_NS(document)::Document* doc);
+		void invertDocument(const CL_NS(document)::Document* doc);
 
 		void addPosition(const TCHAR* field, const TCHAR* text, const int32_t position);
 
@@ -89,7 +80,7 @@
 
 		void writePostings(Posting** postings, const int32_t postingsLength, const char* segment);
 
-		void writeNorms(CL_NS(document)::Document* doc, const char* segment);
+		void writeNorms(const CL_NS(document)::Document* doc, const char* segment);
 
 		void clearPostingTable();
 	};

Modified: trunk/clucene/src/CLucene/index/FieldInfo.h
===================================================================
--- trunk/clucene/src/CLucene/index/FieldInfo.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/FieldInfo.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_FieldInfo_
 #define _lucene_index_FieldInfo_
 
@@ -42,8 +33,8 @@
 		FieldInfo(const TCHAR* na, const bool tk, const int32_t nu, const bool stv):
 			name(CL_NS(util)::CLStringIntern::intern(na CL_FILELINE)),
 			isIndexed(tk),
-			number(nu),
-			storeTermVector(stv){
+			storeTermVector(stv),
+			number(nu){
         //Func - Constructor
 		//       Initialises FieldInfo.
 		//       na holds the name of the field

Modified: trunk/clucene/src/CLucene/index/FieldInfos.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/FieldInfos.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/FieldInfos.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "FieldInfos.h"
 
@@ -39,7 +30,7 @@
 	FieldInfos::FieldInfos(Directory* d, const char* name):
 		byName(false,false),byNumber(true) 
 	{
-		IndexInput* input = d->openFile(name);
+		IndexInput* input = d->openInput(name);
 		try {	
 			read(input);
 		} _CLFINALLY (
@@ -48,7 +39,7 @@
 		);
 	}
 
-	void FieldInfos::add(Document* doc) {
+	void FieldInfos::add(const Document* doc) {
 		DocumentFieldEnumeration* fields  = doc->fields();
 		while (fields->hasMoreElements()) {
 			Field* field = fields->nextElement();
@@ -109,8 +100,8 @@
 		return byNumber.size();
 	}
 
-	void FieldInfos::write(Directory* d, const char* name) {
-		IndexOutput* output = d->createFile(name);
+	void FieldInfos::write(Directory* d, const char* name) const{
+		IndexOutput* output = d->createOutput(name);
 		try {
 			write(output);
 		} _CLFINALLY (
@@ -119,7 +110,7 @@
 		);
 	}
 
-	void FieldInfos::write(IndexOutput* output) {
+	void FieldInfos::write(IndexOutput* output) const{
 		output->writeVInt(size());
 		for (int32_t i = 0; i < size(); i++) {
 			FieldInfo* fi = fieldInfo(i);
@@ -132,7 +123,7 @@
 		}
 	}
 
-	void FieldInfos::read(store::IndexInput* input) {
+	void FieldInfos::read(IndexInput* input) {
 		int32_t size = input->readVInt();
         TCHAR name[LUCENE_MAX_FIELD_LEN+1]; //todo: we make this very big, so that a jlucene field bigger than LUCENE_MAX_FIELD_LEN won't corrupt the buffer
 		for (int32_t i = 0; i < size; i++){

Modified: trunk/clucene/src/CLucene/index/FieldInfos.h
===================================================================
--- trunk/clucene/src/CLucene/index/FieldInfos.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/FieldInfos.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_FieldInfos_
 #define _lucene_index_FieldInfos_
 
@@ -73,7 +64,7 @@
       	bool hasVectors() const;
 
 		// Adds field info for a Document. 
-		void add(CL_NS(document)::Document* doc);
+		void add(const CL_NS(document)::Document* doc);
 
 		// Merges in information from another FieldInfos. 
 		void add(FieldInfos* other);
@@ -99,8 +90,8 @@
 	   */
    		void add(const TCHAR** names, const bool isIndexed, const bool storeTermVector=false);
 
-		void write(CL_NS(store)::Directory* d, const char* name);
-		void write(CL_NS(store)::IndexOutput* output);
+		void write(CL_NS(store)::Directory* d, const char* name) const;
+		void write(CL_NS(store)::IndexOutput* output) const;
 
 	private:
 		void read(CL_NS(store)::IndexInput* input);

Modified: trunk/clucene/src/CLucene/index/FieldsReader.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/FieldsReader.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/FieldsReader.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "FieldsReader.h"
 
@@ -40,11 +31,11 @@
 		CND_PRECONDITION(segment != NULL, "segment != NULL");
 
 		const char* buf = Misc::segmentname(segment,".fdt");
-		fieldsStream = d->openFile( buf );
+		fieldsStream = d->openInput( buf );
 		_CLDELETE_CaARRAY( buf );
 
 		buf = Misc::segmentname(segment,".fdx");
-		indexStream = d->openFile( buf );
+		indexStream = d->openInput( buf );
 		_CLDELETE_CaARRAY( buf );
 
 		_size = (int32_t)indexStream->length()/8;
@@ -73,7 +64,7 @@
 		_CLDELETE(indexStream);
 	}
 
-	int32_t FieldsReader::size() {
+	int32_t FieldsReader::size() const{
 		return _size;
 	}
 

Modified: trunk/clucene/src/CLucene/index/FieldsReader.h
===================================================================
--- trunk/clucene/src/CLucene/index/FieldsReader.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/FieldsReader.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_FieldsReader_
 #define _lucene_index_FieldsReader_
 
@@ -45,7 +36,7 @@
 
 		void close();
 
-		int32_t size();
+		int32_t size() const;
 
 		CL_NS(document)::Document* doc(int32_t n);
 	};

Modified: trunk/clucene/src/CLucene/index/FieldsWriter.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/FieldsWriter.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/FieldsWriter.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "FieldsWriter.h"
 
@@ -41,11 +32,11 @@
 		CND_PRECONDITION(segment != NULL,"segment is NULL");
 
 		const char* buf = Misc::segmentname(segment,".fdt");
-        fieldsStream = d->createFile ( buf );
+        fieldsStream = d->createOutput ( buf );
         _CLDELETE_CaARRAY( buf );
         
 		buf = Misc::segmentname(segment,".fdx");
-        indexStream = d->createFile( buf );
+        indexStream = d->createOutput( buf );
         _CLDELETE_CaARRAY( buf );
           
 		CND_CONDITION(indexStream != NULL,"indexStream is NULL");

Modified: trunk/clucene/src/CLucene/index/FieldsWriter.h
===================================================================
--- trunk/clucene/src/CLucene/index/FieldsWriter.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/FieldsWriter.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_FieldsWriter_
 #define _lucene_index_FieldsWriter_
 

Modified: trunk/clucene/src/CLucene/index/IndexModifier.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/IndexModifier.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/IndexModifier.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "IndexModifier.h"
 
@@ -51,7 +42,7 @@
 	close();
 }
 
-void IndexModifier::assureOpen() {
+void IndexModifier::assureOpen() const{
 	if (!open) {
 		_CLTHROWA(CL_ERR_IllegalState,"Index is closed");
 	}
@@ -218,7 +209,7 @@
 	open = false;
 }
 
-const TCHAR* IndexModifier::toString() {
+const TCHAR* IndexModifier::toString() const{
 	TCHAR* dir = directory->toString();
 	TCHAR* ret = _CL_NEWARRAY(TCHAR,_tcslen(dir)+7); //strlen("Index@")
 	_tcscpy(ret,_T("Index@"));

Modified: trunk/clucene/src/CLucene/index/IndexModifier.h
===================================================================
--- trunk/clucene/src/CLucene/index/IndexModifier.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/IndexModifier.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_IndexModifier_
 #define _lucene_index_IndexModifier_
 
@@ -128,7 +119,7 @@
 	* Throw an IllegalStateException if the index is closed.
 	* @throws IllegalStateException
 	*/
-	void assureOpen();
+	void assureOpen() const;
 
 	/**
 	* Close the IndexReader and open an IndexWriter.
@@ -143,8 +134,6 @@
 	void createIndexReader();
 
 public:
-   DEFINE_MUTEX(THIS_LOCK);
-
 	/**
 	* Make sure all changes are written to disk.
 	* @throws IOException
@@ -293,7 +282,7 @@
 	*/
 	void close();
 
-	const TCHAR* toString();	
+	const TCHAR* toString() const;	
 	
 	
 	/**

Modified: trunk/clucene/src/CLucene/index/IndexReader.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/IndexReader.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/IndexReader.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "IndexReader.h"
 
@@ -219,7 +210,7 @@
        CND_PRECONDITION(directory != NULL, "directory is NULL");
 
 	   //Create a buffer of length CL_MAXDIR
-       char f[CL_MAX_DIR];
+       char f[CL_MAX_PATH+10]; //add 10 in case that directory is already 260 long
 	   //Copy the directory string to the buffer
        strcpy(f,directory);
 	   //Cat the name of the segments to buffer
@@ -470,7 +461,7 @@
       CND_PRECONDITION(directory != NULL, "directory is NULL");
 
 	  //Create a buffer of length CL_MAXDIR
-      char f[CL_MAX_DIR];
+      char f[CL_MAX_PATH+12]; //add 12 in case that directory is already 260 long
 	  //Copy the directory string to the buffer
       strcpy(f,directory);
 	  //Cat the name of the write.lock file to buffer

Modified: trunk/clucene/src/CLucene/index/IndexReader.h
===================================================================
--- trunk/clucene/src/CLucene/index/IndexReader.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/IndexReader.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_IndexReader_
 #define _lucene_index_IndexReader_
 

Modified: trunk/clucene/src/CLucene/index/IndexWriter.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/IndexWriter.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/IndexWriter.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,25 +1,15 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "IndexWriter.h"
 
 #include "CLucene/document/Document.h"
 #include "CLucene/store/Directory.h"
 #include "CLucene/store/Lock.h"
-#include "CLucene/store/TransactionalRAMDirectory.h"
 #include "CLucene/util/VoidList.h"
 #include "DocumentWriter.h"
 #include "SegmentInfos.h"
@@ -277,16 +267,16 @@
 			SegmentInfo* si = _CLNEW SegmentInfo(segmentName, 1, ramDirectory);
 			CND_CONDITION(si != NULL, "Si is NULL");
 
-         {
-            SCOPED_LOCK_MUTEX(THIS_LOCK)
+			{
+				SCOPED_LOCK_MUTEX(THIS_LOCK)
 
-   			//Add the info object for this particular segment to the list
-   			// of all segmentInfos->
-   			segmentInfos->add(si);
-   			
-          	//Check to see if the segments must be merged
-          	maybeMergeSegments();
-         }
+   				//Add the info object for this particular segment to the list
+   				// of all segmentInfos->
+   				segmentInfos->add(si);
+	   			
+          		//Check to see if the segments must be merged
+          		maybeMergeSegments();
+			}
 		} _CLFINALLY(
 			_CLDELETE_CaARRAY(segmentName);
 		);
@@ -465,7 +455,7 @@
     if (!directory->fileExists("deletable"))
       return result;
 
-    lucene::store::IndexInput* input = directory->openFile("deletable");
+    IndexInput* input = directory->openInput("deletable");
     try {
 		TCHAR tname[CL_MAX_PATH];
 		for (int32_t i = input->readInt(); i > 0; i--){	  // read file names
@@ -482,7 +472,7 @@
   }
 
   void IndexWriter::writeDeleteableFiles(AStringArrayConstWithDeletor* files) {
-    IndexOutput* output = directory->createFile("deleteable.new");
+    IndexOutput* output = directory->createOutput("deleteable.new");
     try {
       output->writeInt(files->size());
 	  TCHAR tfile[CL_MAX_PATH]; //temporary space for tchar file name
@@ -502,7 +492,7 @@
 	AStringArrayConstWithDeletor::const_iterator itr = files->begin();
 	while ( itr != files->end() ){
 		directory->deleteFile( *itr );
-		itr++;
+		++itr;
 	}
   }
 
@@ -524,7 +514,7 @@
 			deletable->push_back(STRDUP_AtoA(file));		  // add to deletable
 			}
 		}
-	  itr++;
+	  ++itr;
 	 }
   }
 

Modified: trunk/clucene/src/CLucene/index/IndexWriter.h
===================================================================
--- trunk/clucene/src/CLucene/index/IndexWriter.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/IndexWriter.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_IndexWriter_
 #define _lucene_index_IndexWriter_
 
@@ -100,7 +91,7 @@
 		// explicitly set a truncation policy by adjusting maxFieldLength.
 		LUCENE_STATIC_CONSTANT(int32_t, DEFAULT_MAX_FIELD_LENGTH = 10000);
 		LUCENE_STATIC_CONSTANT(int32_t, FIELD_TRUNC_POLICY__WARN = -1);
-		int32_t getMaxFieldLength(){ return maxFieldLength; }
+		int32_t getMaxFieldLength() const{ return maxFieldLength; }
 		void setMaxFieldLength(int32_t val){ maxFieldLength = val; }
 
 		// Determines how often segment indices are merged by addDocument().  With
@@ -112,7 +103,7 @@
 		// interactively maintained.
 		//
 		// <p>This must never be less than 2.  The default value is 10.
-		int32_t getMergeFactor(){ return mergeFactor; }
+		int32_t getMergeFactor() const{ return mergeFactor; }
 		void setMergeFactor(int32_t val){ mergeFactor = val; }
       
 		/** Determines the minimal number of documents required before the buffered
@@ -122,7 +113,7 @@
 		* the number of files open in a FSDirectory.
 		*
 		* <p> The default value is 10.*/
-		int32_t getMinMergeDocs(){ return minMergeDocs; }
+		int32_t getMinMergeDocs() const{ return minMergeDocs; }
 		void setMinMergeDocs(int32_t val){ minMergeDocs = val; }
     
 
@@ -132,7 +123,7 @@
 		// Larger values are best for batched indexing and speedier searches.
 		//
 		// <p>The default value is {@link Integer#MAX_VALUE}.
-		int32_t getMaxMergeDocs(){ return maxMergeDocs; }
+		int32_t getMaxMergeDocs() const{ return maxMergeDocs; }
 		void setMaxMergeDocs(int32_t val){ maxMergeDocs = val; }
 
 		/**

Modified: trunk/clucene/src/CLucene/index/MultiReader.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/MultiReader.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/MultiReader.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "MultiReader.h"
 
@@ -393,7 +384,7 @@
   }
 
   void MultiTermDocs::seek(TermEnum* termEnum){
-    seek(termEnum->term());
+    seek(termEnum->term(false));
   }
 
   void MultiTermDocs::seek( Term* tterm) {
@@ -403,23 +394,23 @@
 
     CND_PRECONDITION(tterm != NULL, "tterm is NULL");
 
-      //Assigning tterm is done as below for a reason
-      //The construction ensures that if seek is called from within
-    //MultiTermDocs with as argument this->term (seek(this->term)) that the assignment
-    //will succeed and all referencecounters represent the correct situation
+	//Assigning tterm is done as below for a reason
+	//The construction ensures that if seek is called from within
+	//MultiTermDocs with as argument this->term (seek(this->term)) that the assignment
+	//will succeed and all referencecounters represent the correct situation
+	
+	//Get a pointer from tterm and increase its reference counter
+    Term *TempTerm = _CL_POINTER(tterm);
+	
+	//Finialize term to ensure we decrease the reference counter of the instance which term points to
+	_CLDECDELETE(term);
 
-    //Get a pointer from tterm and increase its reference counter
-      Term *TempTerm = _CL_POINTER(tterm);
-
-      //Finialize term to ensure we decrease the reference counter of the instance which term points to
-      _CLDECDELETE(term);
-
-    //Assign TempTerm to term
-      term = TempTerm;
-
-      base = 0;
-      pointer = 0;
-      current = NULL;
+	//Assign TempTerm to term
+	term = TempTerm;
+	
+	base = 0;
+	pointer = 0;
+	current = NULL;
   }
 
   bool MultiTermDocs::next() {
@@ -642,7 +633,7 @@
 }
 
 
-  Term* MultiTermEnum::term(const bool pointer) {
+  Term* MultiTermEnum::term() {
   //Func - Returns the current term of the set of enumerations
   //Pre  - pointer is true or false and indicates if the reference counter
   //       of term must be increased or not
@@ -650,10 +641,13 @@
   //Post - pointer = true -> term has been returned with an increased reference counter
   //       pointer = false -> term has been returned
 
-    if (pointer && _term!=NULL)
-        return _CL_POINTER(_term);
+    return _CL_POINTER(_term);
+  }
+  Term* MultiTermEnum::term(bool pointer) {
+  	if ( pointer )
+    	return _CL_POINTER(_term);
     else
-		return _term;
+    	return _term;
   }
 
   int32_t MultiTermEnum::docFreq() const {

Modified: trunk/clucene/src/CLucene/index/MultiReader.h
===================================================================
--- trunk/clucene/src/CLucene/index/MultiReader.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/MultiReader.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_MultiReader
 #define _lucene_index_MultiReader
 
@@ -30,7 +21,7 @@
 
    /** An IndexReader which reads multiple indexes, appending their content.
    *
-   * @version $Id: MultiReader.h 2006 2006-04-27 07:12:38Z ustramooner $
+   * @version $Id: MultiReader.h 2209 2006-06-15 14:12:41Z ustramooner $
    */
 	class MultiTermDocs:public virtual TermDocs {
 	private:
@@ -94,8 +85,9 @@
 		//Move the current term to the next in the set of enumerations
 		bool next();
 
-		//Returns the current term of the set of enumerations
-		Term* term(const bool pointer = true);
+		//Returns a pointer to the current term of the set of enumerations
+		Term* term();
+		Term* term(bool pointer);
 
 		//Returns the document frequency of the current term in the set
 		int32_t docFreq() const;

Modified: trunk/clucene/src/CLucene/index/SegmentHeader.h
===================================================================
--- trunk/clucene/src/CLucene/index/SegmentHeader.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/SegmentHeader.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_SegmentHeader_
 #define _lucene_index_SegmentHeader_
 
@@ -21,7 +12,7 @@
 #endif
 
 #include "SegmentInfos.h"
-#include "CLucene/util/BitVector.h"
+#include "CLucene/util/BitSet.h"
 #include "CLucene/util/VoidMap.h"
 #include "Term.h"
 #include "FieldInfos.h"
@@ -44,7 +35,7 @@
 
 		int32_t _doc;
 
-		CL_NS(util)::BitVector* deletedDocs;
+		CL_NS(util)::BitSet* deletedDocs;
 		CL_NS(store)::IndexInput* freqStream;
 		int32_t skipInterval;
 		int32_t numSkips;
@@ -62,7 +53,7 @@
 #endif
 
 		///\param Parent must be a segment reader
-		SegmentTermDocs( SegmentReader* Parent);
+		SegmentTermDocs( const SegmentReader* parent);
 		virtual ~SegmentTermDocs();
 
         virtual void seek(TermEnum* termEnum);
@@ -99,7 +90,7 @@
 
 	public:
 		///\param Parent must be a segment reader
-		SegmentTermPositions(SegmentReader* Parent);
+		SegmentTermPositions(const SegmentReader* parent);
 		~SegmentTermPositions();
 
 
@@ -151,7 +142,6 @@
 				void reWrite();
 		};
 
-	private:
 		//Holds the name of the segment that is being read
 		const char* segment;
 
@@ -181,8 +171,8 @@
 		void doSetNorm(int32_t doc, const TCHAR* field, uint8_t value);
 	public:
 #ifndef LUCENE_HIDE_INTERNAL
-		///For Internal Use. a bitVector that manages which documents have been deleted
-		CL_NS(util)::BitVector* deletedDocs;
+		///For Internal Use. a BitSet that manages which documents have been deleted
+		CL_NS(util)::BitSet* deletedDocs;
 		///For Internal Use. an IndexInput to the frequency file
 		CL_NS(store)::IndexInput* freqStream;
 		///For Internal Use. For reading the fieldInfos file

Modified: trunk/clucene/src/CLucene/index/SegmentInfos.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/SegmentInfos.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/SegmentInfos.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "SegmentInfos.h"
 
@@ -33,8 +24,9 @@
 	//       Dir holds the Directory where the segment resides
 	//Post - The instance has been created. name contains the duplicated string Name.
 	//       docCount = DocCount and dir references Dir
-			STRCPY_AtoA(name,Name,CL_MAX_DIR);
-  }
+			STRCPY_AtoA(name,Name,CL_MAX_NAME);
+   }
+  
    SegmentInfo::~SegmentInfo(){
    }
 
@@ -49,7 +41,7 @@
   
       //initialize counter to 0
       counter = 0;
-      version = 0;
+      version = Misc::currentTimeMillis();
   }
 
   SegmentInfos::~SegmentInfos(){
@@ -89,7 +81,7 @@
   void SegmentInfos::add(SegmentInfo* info){
 	infos.push_back(info);
   }
-  int32_t SegmentInfos::size(){
+  int32_t SegmentInfos::size() const{
 	  return infos.size();
   }
 
@@ -100,7 +92,7 @@
   //       a SegmentsInfo intance has been created and stored.
 
 	  //Open an IndexInput to the segments file
-      IndexInput* input = directory->openFile("segments");
+      IndexInput* input = directory->openInput("segments");
 	  //Check if input is valid
 	  if (input){
         try {
@@ -143,7 +135,7 @@
 
             if(format >= 0){ // in old format the version number may be at the end of the file
                if (input->getFilePointer() >= input->length())
-                  version = 0; // old file format without version number
+                  version = Misc::currentTimeMillis(); // old file format without version number
                else
                   version = input->readLong(); // read version
             }
@@ -161,7 +153,7 @@
   //Post - The new segment has been written to disk
     
 	  //Open an IndexOutput to the segments file
-	  IndexOutput* output = directory->createFile("segments.new");
+	  IndexOutput* output = directory->createOutput("segments.new");
 	   //Check if output is valid
 	  if (output){
           try {
@@ -205,7 +197,7 @@
 
   
   int64_t SegmentInfos::readCurrentVersion(Directory* directory){
-    IndexInput* input = directory->openFile("segments");
+    IndexInput* input = directory->openInput("segments");
     int32_t format = 0;
     int64_t version = 0;
     try {

Modified: trunk/clucene/src/CLucene/index/SegmentInfos.h
===================================================================
--- trunk/clucene/src/CLucene/index/SegmentInfos.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/SegmentInfos.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_SegmentInfos_
 #define _lucene_index_SegmentInfos_
 
@@ -33,8 +24,8 @@
 		///Gets the Directory where the segment resides
 		CL_NS(store)::Directory* getDir() const{ return dir; } 
 
-    //Unique name in directory dir
-		char name[CL_MAX_DIR];	
+    	//Unique name in directory dir
+		char name[CL_MAX_NAME];	
 		//Number of docs in the segment
 		const int32_t docCount;						  
 
@@ -75,12 +66,17 @@
   //      
   //Format and Version have not been implemented yet
 	class SegmentInfos: LUCENE_BASE {
-      /** The file format version, a negative number. */
-      /* Works since counter, the old 1st entry, is always >= 0 */
-      LUCENE_STATIC_CONSTANT(int32_t,FORMAT=-1);
+		/** The file format version, a negative number. */
+		/* Works since counter, the old 1st entry, is always >= 0 */
+		LUCENE_STATIC_CONSTANT(int32_t,FORMAT=-1);
 
-      int64_t version; //counts how often the index has been changed by adding or deleting docs
-      segmentInfosType infos;
+		/**
+		* counts how often the index has been changed by adding or deleting docs.
+		* starting with the current time in milliseconds forces to create unique version numbers.
+		*/
+		int64_t version;
+
+		segmentInfosType infos;
     public:
       SegmentInfos(bool deleteMembers=true);
       ~SegmentInfos();
@@ -88,25 +84,25 @@
 #ifndef LUCENE_HIDE_INTERNAL
       int32_t counter;  // used to name new segments
 #endif
+		
+		//delete and clears objects 'from' from to 'to'
+		void clearto(size_t to);
+		
+		//count of segment infos
+		int32_t size() const;
+		//add a segment info
+		void add(SegmentInfo* info);
+		//Returns a reference to the i-th SegmentInfo in the list.
+		SegmentInfo* info(int32_t i);
+		
+		/**
+		* version number when this SegmentInfos was generated.
+		*/
+		int64_t getVersion() { return version; }
+		
+		static int64_t readCurrentVersion(CL_NS(store)::Directory* directory);
 
-		  //delete and clears objects 'from' from to 'to'
-			void clearto(size_t to);
-			
-			//count of segment infos
-			int32_t size();
-			//add a segment info
-			void add(SegmentInfo* info);
-	  	//Returns a reference to the i-th SegmentInfo in the list.
-      SegmentInfo* info(int32_t i);
 
-      /**
-      * version number when this SegmentInfos was generated.
-      */
-      int64_t getVersion() { return version; }
-      
-      static int64_t readCurrentVersion(CL_NS(store)::Directory* directory);
-
-
 		  //Reads segments file that resides in directory
 		  void read(CL_NS(store)::Directory* directory);
 

Modified: trunk/clucene/src/CLucene/index/SegmentMergeInfo.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/SegmentMergeInfo.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/SegmentMergeInfo.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,22 +1,12 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "SegmentMergeInfo.h"
 
-#include "CLucene/util/BitVector.h"
 #include "SegmentTermEnum.h"
 #include "SegmentHeader.h"
 

Modified: trunk/clucene/src/CLucene/index/SegmentMergeInfo.h
===================================================================
--- trunk/clucene/src/CLucene/index/SegmentMergeInfo.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/SegmentMergeInfo.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_SegmentMergeInfo_
 #define _lucene_index_SegmentMergeInfo_
 
@@ -20,7 +11,6 @@
 # pragma once
 #endif
 
-#include "CLucene/util/BitVector.h"
 #include "SegmentTermEnum.h"
 #include "SegmentHeader.h"
 

Modified: trunk/clucene/src/CLucene/index/SegmentMergeQueue.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/SegmentMergeQueue.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/SegmentMergeQueue.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "SegmentMergeQueue.h"
 

Modified: trunk/clucene/src/CLucene/index/SegmentMergeQueue.h
===================================================================
--- trunk/clucene/src/CLucene/index/SegmentMergeQueue.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/SegmentMergeQueue.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_SegmentMergeQueue_
 #define _lucene_index_SegmentMergeQueue_
 

Modified: trunk/clucene/src/CLucene/index/SegmentMerger.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/SegmentMerger.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/SegmentMerger.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "SegmentMerger.h"
 
@@ -22,10 +13,10 @@
 CL_NS_DEF(index)
 
    // File extensions of old-style index files
-   char* COMPOUND_EXTENSIONS="fnm\0" "frq\0" "prx\0" "fdx\0" "fdt\0" "tii\0" "tis\0";
+   const char* COMPOUND_EXTENSIONS="fnm\0" "frq\0" "prx\0" "fdx\0" "fdt\0" "tii\0" "tis\0";
    int COMPOUND_EXTENSIONS_LENGTH=7;
 
-   char* VECTOR_EXTENSIONS="tvx\0" "tvd\0" "tvf\0";
+   const char* VECTOR_EXTENSIONS="tvx\0" "tvd\0" "tvf\0";
    int VECTOR_EXTENSIONS_LENGTH=3;
 
   SegmentMerger::SegmentMerger(Directory* dir, const char* name, const bool compoundFile): directory(dir){
@@ -347,14 +338,14 @@
 		  //create a filename for the new Frequency File for segment
           const char* buf = Misc::segmentname(segment,".frq");
 		  //Open an IndexOutput to the new Frequency File
-          freqOutput = directory->createFile( buf );
+          freqOutput = directory->createOutput( buf );
           //Destroy the buffer of the filename
           _CLDELETE_CaARRAY(buf);
 		
 		  //create a filename for the new Prox File for segment
           buf = Misc::segmentname(segment,".prx");
 		  //Open an IndexOutput to the new Prox File
-          proxOutput = directory->createFile( buf );
+          proxOutput = directory->createOutput( buf );
 		  //delete buffer
           _CLDELETE_CaARRAY( buf );
 		
@@ -660,7 +651,7 @@
 			  //Create an new filename for the norm file
               const char* buf = Misc::segmentname(segment,".f", i);
 			  //Instantiate  an IndexOutput to that norm file
-              output = directory->createFile( buf );
+              output = directory->createOutput( buf );
 
 			  //Condition check to see if output points to a valid instance
               CND_CONDITION(output != NULL, "No Outputstream retrieved");

Modified: trunk/clucene/src/CLucene/index/SegmentMerger.h
===================================================================
--- trunk/clucene/src/CLucene/index/SegmentMerger.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/SegmentMerger.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_SegmentMerger_
 #define _lucene_index_SegmentMerger_
 

Modified: trunk/clucene/src/CLucene/index/SegmentReader.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/SegmentReader.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/SegmentReader.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "SegmentHeader.h"
 
@@ -20,7 +11,6 @@
 #include "FieldsReader.h"
 #include "IndexReader.h"
 #include "TermInfosReader.h"
-#include "CLucene/util/BitVector.h"
 #include "Terms.h"
 
 CL_NS_USE(util)
@@ -28,7 +18,7 @@
 CL_NS_USE(document)
 CL_NS_DEF(index)
 
- SegmentReader::Norm::Norm(lucene::store::IndexInput* instrm, int32_t n, SegmentReader* r, const char* seg): 
+ SegmentReader::Norm::Norm(IndexInput* instrm, int32_t n, SegmentReader* r, const char* seg): 
    in(instrm), number(n), reader(r), segment(seg){
   //Func - Constructor
   //Pre  - instrm is a valid reference to an IndexInput
@@ -59,7 +49,7 @@
       sprintf(buf,"%s.tmp",segment);
 
       // NOTE: norms are re-written in regular directory, not cfs
-      IndexOutput* out = reader->getDirectory()->createFile(buf);
+      IndexOutput* out = reader->getDirectory()->createOutput(buf);
       try {
         out->writeBytes(bytes, reader->maxDoc());
       }_CLFINALLY( out->close(); _CLDELETE(out) );
@@ -133,7 +123,7 @@
 		  freqStream = fsdir->openMMapFile( buf );
 	  }else
 #endif
-		freqStream = cfsDir->openFile( buf );
+		freqStream = cfsDir->openInput( buf );
 
       //Condition check to see if freqStream points to a valid instance and was able to open the
 	  //frequency file
@@ -143,7 +133,7 @@
       SegmentName(buf, CL_MAX_PATH,".prx");
 
 	  //Open an IndexInput proxStream to the prox file
-      proxStream = cfsDir->openFile( buf );
+      proxStream = cfsDir->openInput( buf );
 
 	  //Condition check to see if proxStream points to a valid instance and was able to open the
 	  //prox file
@@ -167,7 +157,7 @@
 		  //Create a deletion file with suffix .del          
           SegmentName(buf, CL_MAX_PATH,".del");
 		  //Instantiate a BitVector that manages which documents have been deleted
-          deletedDocs = _CLNEW BitVector(getDirectory(), buf );
+          deletedDocs = _CLNEW BitSet(getDirectory(), buf );
        }
 
 	  //Open the norm file. There's a norm file for each indexed field with a byte for each document. 
@@ -221,7 +211,7 @@
         if (norm->dirty) {
           norm->reWrite();
         }
-        itr++;
+        ++itr;
       }
     }
     deletedDocsDirty = false;
@@ -329,7 +319,7 @@
 
 	  //Check if deletedDocs exists
 	  if (deletedDocs == NULL){
-          deletedDocs = _CLNEW BitVector(maxDoc());
+          deletedDocs = _CLNEW BitSet(maxDoc());
 
           //Condition check to see if deletedDocs points to a valid instance
           CND_CONDITION(deletedDocs != NULL,"No memory could be allocated for deletedDocs");
@@ -461,7 +451,7 @@
   //Pre  - true
   //Post - An unpositioned TermDocs enumerator has been returned
 
-       return _CLNEW SegmentTermDocs((SegmentReader*)this);
+       return _CLNEW SegmentTermDocs(this);
   }
 
   TermPositions* SegmentReader::termPositions() const {
@@ -469,7 +459,7 @@
   //Pre  - true
   //Post - An unpositioned TermPositions enumerator has been returned
 
-      return _CLNEW SegmentTermPositions((SegmentReader*)this);
+      return _CLNEW SegmentTermPositions(this);
   }
 
   int32_t SegmentReader::docFreq(const Term* t) const {
@@ -548,7 +538,7 @@
       return;
     }
 
-   lucene::store::IndexInput* _normStream = norm->in->clone();
+   IndexInput* _normStream = norm->in->clone();
    CND_PRECONDITION(_normStream != NULL, "normStream==NULL")
 
     // read from disk
@@ -668,7 +658,7 @@
              if ( !d->fileExists(fileName) )
                 d = cfsDir;
 
-                 _norms.put(fi->name, _CLNEW Norm( d->openFile( fileName ),fi->number, this, segment ));
+                 _norms.put(fi->name, _CLNEW Norm( d->openInput( fileName ),fi->number, this, segment ));
           }
       }
   }
@@ -689,7 +679,7 @@
         _CLDELETE(n);
         //Move the interator to the next norm in the norms collection.
 	    //Note ++ is an overloaded operator
-        itr++;
+        ++itr;
      }
     _norms.clear(); //bvk: they're deleted, so clear them so that they are not re-used
   }
@@ -737,7 +727,7 @@
         ret[j]=STRDUP_TtoT(t);
 
         j++;
-        itr++;
+        ++itr;
     }
     ret[fieldSet.size()]=NULL;
     return ret;
@@ -768,7 +758,7 @@
         ret[j]=STRDUP_TtoT(t);
 
         j++;
-        itr++;
+        ++itr;
     }
     ret[fieldSet.size()]=NULL;
     return ret;

Modified: trunk/clucene/src/CLucene/index/SegmentTermDocs.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/SegmentTermDocs.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/SegmentTermDocs.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,35 +1,25 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "SegmentHeader.h"
 
-#include "CLucene/util/BitVector.h"
 #include "CLucene/store/IndexInput.h"
 #include "Term.h"
 
 CL_NS_DEF(index)
 
-  SegmentTermDocs::SegmentTermDocs(SegmentReader* Parent){
+  SegmentTermDocs::SegmentTermDocs(const SegmentReader* _parent){
   //Func - Constructor
   //Pre  - Paren != NULL
   //Post - The instance has been created
 
-      CND_PRECONDITION(Parent != NULL,"Parent is NULL");
+      CND_PRECONDITION(_parent != NULL,"Parent is NULL");
 
-      parent      = Parent;
+      parent      = _parent;
       deletedDocs =  parent->deletedDocs;
 
       _doc         = 0;

Modified: trunk/clucene/src/CLucene/index/SegmentTermEnum.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/SegmentTermEnum.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/SegmentTermEnum.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "SegmentTermEnum.h"
 
@@ -25,7 +16,7 @@
 CL_NS_USE(store)
 CL_NS_DEF(index)
 
-	SegmentTermEnum::SegmentTermEnum(store::IndexInput* i, FieldInfos* fis, const bool isi):
+	SegmentTermEnum::SegmentTermEnum(IndexInput* i, FieldInfos* fis, const bool isi):
 		fieldInfos(fis){
 	//Func - Constructor
 	//Pre  - i holds a reference to an instance of IndexInput
@@ -35,7 +26,7 @@
 		input		 = i;
 		position     = -1;
 		//Instantiate a Term with empty field, empty text and which is interned (see term.h what interned means)
-	    _term         = _CLNEW Term( LUCENE_BLANK_STRING,LUCENE_BLANK_STRING ,false);
+	    _term         = _CLNEW Term( LUCENE_BLANK_STRING,LUCENE_BLANK_STRING );
 		isIndex      = isi;
 		termInfo     = _CLNEW TermInfo();
 		indexPointer = 0;
@@ -203,7 +194,7 @@
 		return true;
 	}
 
-	Term* SegmentTermEnum::term(const bool pointer) {
+	Term* SegmentTermEnum::term() {
 	//Func - Returns the current term.
 	//Pre  - pointer is true or false and indicates if the reference counter
 	//       of term must be increased or not
@@ -211,7 +202,10 @@
 	//Post - pointer = true -> term has been returned with an increased reference counter
 	//       pointer = false -> term has been returned
 
-		if ( pointer && _term!=NULL )
+		return _CL_POINTER(_term);
+	}
+	Term* SegmentTermEnum::term(bool pointer) {
+		if ( pointer )
 			return _CL_POINTER(_term);
 		else
 			return _term;

Modified: trunk/clucene/src/CLucene/index/SegmentTermEnum.h
===================================================================
--- trunk/clucene/src/CLucene/index/SegmentTermEnum.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/SegmentTermEnum.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_SegmentTermEnum_
 #define _lucene_index_SegmentTermEnum_
 
@@ -70,8 +61,10 @@
 		//Moves the current of the set to the next in the set
 		bool next();
 
+		//Returns a pointer to the current term. 
+		Term* term();
 		//Returns the current term. 
-		Term* term(const bool pointer = true);
+		Term* term(bool pointer);
 
         //Scan for Term term without allocating new Terms
 		void scanTo(const Term *term);

Modified: trunk/clucene/src/CLucene/index/SegmentTermPositions.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/SegmentTermPositions.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/SegmentTermPositions.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "SegmentHeader.h"
 
@@ -21,15 +12,15 @@
 CL_NS_USE(util)
 CL_NS_DEF(index)
 
-  SegmentTermPositions::SegmentTermPositions(SegmentReader* Parent):
-      SegmentTermDocs(Parent){
+  SegmentTermPositions::SegmentTermPositions(const SegmentReader* _parent):
+      SegmentTermDocs(_parent){
   //Func - Constructor
   //Pre  - Parent != NULL
   //Post - The instance has been created
 
-       CND_PRECONDITION(Parent != NULL, "Parent is NULL");
+       CND_PRECONDITION(_parent != NULL, "Parent is NULL");
 
-       proxStream = ((SegmentReader*)parent)->proxStream->clone();
+       proxStream = _parent->proxStream->clone();
 
        CND_CONDITION(proxStream != NULL,"proxStream is NULL");
 

Modified: trunk/clucene/src/CLucene/index/SegmentTermVector.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/SegmentTermVector.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/SegmentTermVector.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "TermVector.h"
 #include "CLucene/util/StringBuffer.h"
@@ -38,7 +29,7 @@
     return field;
   }
 
-  TCHAR* SegmentTermVector::toString() {
+  TCHAR* SegmentTermVector::toString() const{
     StringBuffer sb;
     sb.appendChar('{');
     sb.append(field);
@@ -61,11 +52,11 @@
     if ( terms == NULL )
 		return 0;
 
-		if ( termsLen == -1 ){
-			termsLen=0;
-			while ( terms[termsLen] != 0 )
-				termsLen++;
-		}
+	if ( termsLen == -1 ){
+		termsLen=0;
+		while ( terms[termsLen] != 0 )
+			termsLen++;
+	}
     return termsLen;
   }
 

Modified: trunk/clucene/src/CLucene/index/Term.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/Term.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/Term.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,247 +1,237 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "Term.h"
 #include "CLucene/util/StringIntern.h"
 
 CL_NS_USE(util)
 CL_NS_DEF(index)
-	
-	Term::Term(){
-		//Intern fld and assign it to field
-		_field = LUCENE_BLANK_STRING;
-		internF = false;
-		cachedHashCode = 0;
 
-		textLen = 0;		
+Term::Term(){
+	//Intern fld and assign it to field
+	_field = LUCENE_BLANK_STRING;
+	internF = false;
+	cachedHashCode = 0;
+	textLen = 0;		
 		
-		//Duplicate txt and assign it to text
-#ifdef LUCENE_TERM_TEXT_LENGTH
-      _text[0]=0;
-#else
+	//Duplicate txt and assign it to text
+	#ifdef LUCENE_TERM_TEXT_LENGTH
+		_text[0]=0;
+	#else
 		_text = LUCENE_BLANK_STRING;
-		dupT = false;
-#endif
-	}
+		textLenBuf = 0;
+	#endif
+	textLen = 0;
+}
 
-	Term::Term(const TCHAR* fld, const TCHAR* txt,const bool internField){
-    //Func - Constructor.
-    //       Constructs a Term with the given field and text. Field and text are not copied
-	//       Field and text are deleted in destructor only if intern is false. 
-    //Pre  - fld != NULL and contains the name of the field
-    //       txt != NULL and contains the value of the field
-	//       internF is true or false and indicates if term Field is interned or not
-	//       internT is true or false and indicates if term Text is interned or not
-    //       canDelete defaults to true but can be false and indicates to the IGarbageCollector that the Term can be deleted when finalized
-    //Post - An instance of Term has been created.Field and txt have not been copied but assigned
+Term::Term(const TCHAR* fld, const TCHAR* txt,const bool internField){
+//Func - Constructor.
+//       Constructs a Term with the given field and text. Field and text are not copied
+//       Field and text are deleted in destructor only if intern is false. 
+//Pre  - fld != NULL and contains the name of the field
+//       txt != NULL and contains the value of the field
+//       internF is true or false and indicates if term Field is interned or not
+//       internT is true or false and indicates if term Text is interned or not
+//       canDelete defaults to true but can be false and indicates to the IGarbageCollector that the Term can be deleted when finalized
+//Post - An instance of Term has been created.Field and txt have not been copied but assigned
+	
+	_field = LUCENE_BLANK_STRING;
+	internF = false;
+	textLen = 0;
+	#ifdef LUCENE_TERM_TEXT_LENGTH
+		_text[0]=0;
+	#else
+		_text = LUCENE_BLANK_STRING;
+		textLenBuf = 0;
+	#endif
 
-        CND_PRECONDITION(fld != NULL, "fld contains NULL");
-        CND_PRECONDITION(txt != NULL, "txt contains NULL");
+    set(fld,txt,internField);
+}
 
-		//todo: this needs to be re-thought. i suggest allowing construction
-		//using an iterator containing the field field which can then
-		//be directly manipulated.
-		//if ( internField )
-			_field  = CLStringIntern::intern(fld  CL_FILELINE);
-		//else
-		//	_field = fld;
-		internF = internField;
-		cachedHashCode = 0;
+Term::Term(const TCHAR* fld, const TCHAR* txt){
+	_field = LUCENE_BLANK_STRING;
+	internF = false;
+	textLen = 0;
+	#ifdef LUCENE_TERM_TEXT_LENGTH
+		_text[0]=0;
+	#else
+		_text = LUCENE_BLANK_STRING;
+		textLenBuf = 0;
+	#endif
 
-		textLen = _tcslen(txt);
-		
-		//duplicate text if necessary
-#ifdef LUCENE_TERM_TEXT_LENGTH
-		if ( textLen > LUCENE_TERM_TEXT_LENGTH )
-		   textLen = LUCENE_TERM_TEXT_LENGTH;
-		_tcsncpy(_text,txt,textLen+1);
-        _text[textLen]=0;
-#else
-		dupT  = true;
-		//if ( duplicateText ){
-			if ( txt[0]==0 ){
-				_text = LUCENE_BLANK_STRING;
-				dupT = false;
-			}else
-				_text = stringDuplicate(txt);
-		/*}else
-			_text = txt;*/
-		textLenBuf = textLen;
-#endif
+    set(fld,txt);
+}
 
-		//this->_canDelete = canDelete;
-	}
-	
-	Term::~Term(){
-	//Func - Destructor.
-	//Pre  - true
-	//Post - The instance has been destroyed. field and text have been deleted if pre(intrn) is false
+Term::~Term(){
+//Func - Destructor.
+//Pre  - true
+//Post - The instance has been destroyed. field and text have been deleted if pre(intrn) is false
 
-		//Unintern field
-		//if ( internF )
-			CLStringIntern::unintern(_field);
-		_field = NULL;
+	//Unintern field
+	//if ( internF )
+		CLStringIntern::unintern(_field);
+	_field = NULL;
 
 #ifndef LUCENE_TERM_TEXT_LENGTH
-		//Deletetext if it is the owner
-		if ( dupT && _text)
-			_CLDELETE_CARRAY( _text );
+	//Deletetext if it is the owner
+	if ( _text != LUCENE_BLANK_STRING)
+		_CLDELETE_CARRAY( _text );
 #endif
-	}
+}
 
-    const TCHAR* Term::field() const {
-    //Func - Returns the field of this term, an interned string. The field indicates
-    //       the part of a document which this term came from. 
-    //Pre  - true
-    //Post - field has been returned
+const TCHAR* Term::field() const {
+//Func - Returns the field of this term, an interned string. The field indicates
+//       the part of a document which this term came from. 
+//Pre  - true
+//Post - field has been returned
 
-        return _field;
-    }
+    return _field;
+}
 
-    const TCHAR* Term::text() const {
-    //Func - Returns the text of this term.  In the case of words, this is simply the
-    //       text of the word.  In the case of dates and other types, this is an
-    //       encoding of the object as a string.
-	//Pre  - true
-	//Post - text has been returned
+const TCHAR* Term::text() const {
+//Func - Returns the text of this term.  In the case of words, this is simply the
+//       text of the word.  In the case of dates and other types, this is an
+//       encoding of the object as a string.
+//Pre  - true
+//Post - text has been returned
 
-        return _text;
-    }
+    return _text;
+}
 
-	void Term::set(const TCHAR* fld, const TCHAR* txt,const bool internField){
-    //Func - Resets the field and text of a Term.
-    //Pre  - fld != NULL and contains the name of the field
-    //       txt != NULL and contains the value of the field
-	//       internF is true or false
-	//       internT is true or false
-    //Post - field and text of Term have been reset
 
-        CND_PRECONDITION(fld != NULL, "fld contains NULL");
-        CND_PRECONDITION(txt != NULL, "txt contains NULL");
+void Term::set(Term* term, const TCHAR* txt){
+	set(term->field(),txt,false);
+}
 
-		//save field for unintern later
-		const TCHAR* oldField = _field;
-		bool oldInternF = internF;
-		cachedHashCode = 0;
+void Term::set(const TCHAR* fld, const TCHAR* txt,const bool internField){
+//Func - Resets the field and text of a Term.
+//Pre  - fld != NULL and contains the name of the field
+//       txt != NULL and contains the value of the field
+//       internF is true or false
+//       internT is true or false
+//Post - field and text of Term have been reset
 
-        textLen = _tcslen(txt);
+    CND_PRECONDITION(fld != NULL, "fld contains NULL");
+    CND_PRECONDITION(txt != NULL, "txt contains NULL");
 
-		//Delete text if it is the owner
+	//save field for unintern later
+	const TCHAR* oldField = _field;
+	bool oldInternF = internF;
+	cachedHashCode = 0;
+
+    textLen = _tcslen(txt);
+
+	//Delete text if it is the owner
 #ifdef LUCENE_TERM_TEXT_LENGTH
-		if ( textLen > LUCENE_TERM_TEXT_LENGTH )
-		   textLen = LUCENE_TERM_TEXT_LENGTH;
-		_tcsncpy(_text,txt,textLen+1);
-        _text[textLen]=0;
+	if ( textLen > LUCENE_TERM_TEXT_LENGTH )
+	   textLen = LUCENE_TERM_TEXT_LENGTH;
+	_tcsncpy(_text,txt,textLen+1);
+    _text[textLen]=0;
 #else
 
-		//assign new text
-		bool olddupT = dupT;
-		dupT = true;
+	//assign new text
+	//bool olddupT = dupT;
+	//dupT = true;
 
-		//if ( duplicateText ){
-			//if the term text buffer is bigger than what we have
-			if ( !olddupT && _text ){
-				_text = NULL;
-				textLenBuf = 0;
-			}else if ( _text && textLen > textLenBuf){
-				_CLDELETE_ARRAY( _text );
-				textLenBuf = 0;
-			}
+	//if the term text buffer is bigger than what we have
+	/*if ( !olddupT && _text ){
+		_text = NULL;
+		textLenBuf = 0; 
+	}else */
+	if ( _text && textLen > textLenBuf){
+		if ( _text != LUCENE_BLANK_STRING ){
+			_CLDELETE_ARRAY( _text );
+		}else
+			_text = NULL;
+		textLenBuf = 0;
+	}
 
-			if ( _text==NULL ){
-				if ( txt[0] == 0 ){
-					//if the string is blank and we aren't re-using the buffer...
-					_text = LUCENE_BLANK_STRING;
-					dupT = false;
-				}else{
-					//duplicate the text
-					_text  = stringDuplicate(txt);
-					textLenBuf = textLen;
-				}
-			}else{
-				//re-use the buffer
-				_tcscpy(_text,txt);
-			}
+	if ( _text==LUCENE_BLANK_STRING )
+		_text = LUCENE_BLANK_STRING;
+	else if ( _text==NULL ){
+		if ( txt[0] == 0 ){
+			//if the string is blank and we aren't re-using the buffer...
+			_text = LUCENE_BLANK_STRING;
+			//dupT = false;
+		}else{
+			//duplicate the text
+			_text  = stringDuplicate(txt);
+			textLenBuf = textLen;
+		}
+	}else{
+		//re-use the buffer
+		_tcscpy(_text,txt);
+	}
 
 #endif
 
-	    //Set Term Field
-		//if ( internField )
-			_field = CLStringIntern::intern(fld  CL_FILELINE);
-		//else
-		//	_field = fld;
-		internF = internField;
+    //Set Term Field
+	if ( internField )
+		_field = CLStringIntern::intern(fld  CL_FILELINE);
+	else
+		_field = CLStringIntern::intern(fld  CL_FILELINE); //todo: our interning is not optimised yet...
+	internF = internField;
 
-		//unintern old field after interning new one, 
-		//if ( oldInternF )
-			CLStringIntern::unintern(oldField);
-	}
+	//unintern old field after interning new one, 
+	//if ( oldInternF )
+		CLStringIntern::unintern(oldField);
+}
 
-   /** Compares two terms, returning true iff they have the same
-      field and text. */
-   bool Term::equals(const Term* other) const{
-	   if ( cachedHashCode != 0 && other->cachedHashCode != 0 &&
-			other->cachedHashCode != cachedHashCode )
-			return false;
+/** Compares two terms, returning true iff they have the same
+  field and text. */
+bool Term::equals(const Term* other) const{
+   if ( cachedHashCode != 0 && other->cachedHashCode != 0 &&
+		other->cachedHashCode != cachedHashCode )
+		return false;
 
-      if ( _field==other->_field ){
-         //this can be quicker than using compareTo, because checks
-         //field length first
-		  if ( textLen == other->textLen ){
-				
-			  return (_tcscmp(_text,other->_text)==0);
-		  }else
-            return false;
-      }else
-         return false;
-   }
+  if ( _field==other->_field ){
+     //this can be quicker than using compareTo, because checks
+     //field length first
+	  if ( textLen == other->textLen ){
+		  return (_tcscmp(_text,other->_text)==0);
+	  }else
+        return false;
+  }else
+     return false;
+}
 
-   size_t Term::hashCode(){
-		if ( cachedHashCode != 0 )
-			return cachedHashCode;
-
-		cachedHashCode = Misc::thashCode(_field) + Misc::thashCode(_text,textLen);
+size_t Term::hashCode(){
+	if ( cachedHashCode != 0 )
 		return cachedHashCode;
-   }
 
+	cachedHashCode = Misc::thashCode(_field) + Misc::thashCode(_text,textLen);
+	return cachedHashCode;
+}
 
-	int32_t Term::compareTo(const Term* other) const {
-    //Func - Compares two terms, to see if this term belongs before,is equal to or after
-	//       after the argument term.
-	//Pre  - other is a reference to another term
-	//Post - A negative integer is returned if this term belongs before the argument, 
-    //       zero is returned if this term is equal to the argument, and a positive integer 
-	//       if this term belongs after the argument.
 
-		//Check ret to see if text needs to be compared
-		if ( _field == other->_field ){ // fields are interned
-			//Compare text with text of other and return the result
-			return _tcscmp(_text,other->_text);
-		}else
-			return _tcscmp(_field,other->_field);
-	}
+int32_t Term::compareTo(const Term* other) const {
+//Func - Compares two terms, to see if this term belongs before,is equal to or after
+//       after the argument term.
+//Pre  - other is a reference to another term
+//Post - A negative integer is returned if this term belongs before the argument, 
+//       zero is returned if this term is equal to the argument, and a positive integer 
+//       if this term belongs after the argument.
 
-	TCHAR* Term::toString() const{
-	//Func - Forms the contents of Field and term in some kind of tuple notation
-	//       <field:text>
-	//Pre  - true
-	//Post - a string formatted as <field:text> is returned if pre(field) is NULL and
-	//       text is NULL the returned string will be formatted as <:>
+	//Check ret to see if text needs to be compared
+	if ( _field == other->_field ){ // fields are interned
+		//Compare text with text of other and return the result
+		return _tcscmp(_text,other->_text);
+	}else
+		return _tcscmp(_field,other->_field);
+}
 
-		return CL_NS(util)::Misc::join( _field, _T(":"), _text);
-	}
+TCHAR* Term::toString() const{
+//Func - Forms the contents of Field and term in some kind of tuple notation
+//       <field:text>
+//Pre  - true
+//Post - a string formatted as <field:text> is returned if pre(field) is NULL and
+//       text is NULL the returned string will be formatted as <:>
 
+	return CL_NS(util)::Misc::join( _field, _T(":"), _text);
+}
+
 CL_NS_END

Modified: trunk/clucene/src/CLucene/index/Term.h
===================================================================
--- trunk/clucene/src/CLucene/index/Term.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/Term.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_Term_
 #define _lucene_index_Term_
 
@@ -56,11 +47,16 @@
 #else
 		TCHAR* _text;
 		size_t textLenBuf; //a cache of text len, this allows for a preliminary comparison of text lengths
-		bool    dupT;    //Indicates if Term Text is duplicated (and therefore must be deleted). 
+		//bool    dupT;    //Indicates if Term Text is duplicated (and therefore must be deleted). 
 #endif
 		size_t textLen; //a cache of text len, this allows for a preliminary comparison of text lengths
 		bool    internF; //Indicates if Term Field is interned(and therefore must be uninternd). 
+		
 	  public:
+		
+		//todo: these need to be private, but a few other things need to be changed first...
+		Term(const TCHAR* fld, const TCHAR* txt, bool internField);
+		void set(const TCHAR* fld, const TCHAR* txt, const bool internField);
 			
 		///Constructs a blank term
 		Term();
@@ -69,7 +65,7 @@
 		* Constructor. Constructs a Term with the given field and text. Field and text are not copied
 		* Field and text are deleted in destructor only if intern is false. 
 		*/
-		Term(const TCHAR* fld, const TCHAR* txt, const bool internField=true); //todo:, const bool duplicateText
+		Term(const TCHAR* fld, const TCHAR* txt);
 		
 		///Destructor.
 		~Term();
@@ -84,10 +80,22 @@
 		const TCHAR* text() const; ///<returns reference
 		
 		///Resets the field and text of a Term.
-		void set(const TCHAR* fld, const TCHAR* txt, const bool internField=true); //todo:, const bool duplicateText=true
+		inline void set(const TCHAR* fld, const TCHAR* txt){
+			set(fld,txt,true);
+		}
+		
+		/**
+		* Optimized set of Term by reusing same field as this Term
+		* - avoids field.intern() overhead
+		* @param text The text of the new term (field is implicitly same as this Term instance)
+		*/
+		void set(Term* term, const TCHAR* txt);
 
-		///Compares two terms, to see if this term belongs before,is equal to or after
-		///after the argument term.
+		/** Compares two terms, returning a negative integer if this
+		term belongs before the argument, zero if this term is equal to the
+		argument, and a positive integer if this term belongs after the argument.
+		
+		The ordering of terms is first by field, then by text.*/
 		int32_t compareTo(const Term* other) const;
 
 		bool equals(const Term* other) const;

Modified: trunk/clucene/src/CLucene/index/TermInfo.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/TermInfo.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/TermInfo.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,108 +1,98 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "TermInfo.h"
 
 
 CL_NS_DEF(index)
 
-	TermInfo::TermInfo(){
-	//Func - Constructor
-	//Pre  - true
-	//Post - Instance has been created
-				
-		docFreq     = 0;
-		freqPointer = 0;
-		proxPointer = 0;
-      skipOffset = 0;
-    }
+TermInfo::TermInfo(){
+//Func - Constructor
+//Pre  - true
+//Post - Instance has been created
+			
+	docFreq     = 0;
+	freqPointer = 0;
+	proxPointer = 0;
+  skipOffset = 0;
+}
 
-    TermInfo::~TermInfo(){
-	//Func - Destructor.
-	//Pre  - true
-	//Post - Instance has been destroyed
-    }
+TermInfo::~TermInfo(){
+//Func - Destructor.
+//Pre  - true
+//Post - Instance has been destroyed
+}
 
-	TermInfo::TermInfo(const int32_t df, const int64_t fp, const int64_t pp){
-	//Func - Constructor. 
-	//Pre  - df >= 0, fp >= 0 pp >= 0
-	//Post - An instance has been created with FreqPointer = fp, proxPointer=pp and docFreq= df
+TermInfo::TermInfo(const int32_t df, const int64_t fp, const int64_t pp){
+//Func - Constructor. 
+//Pre  - df >= 0, fp >= 0 pp >= 0
+//Post - An instance has been created with FreqPointer = fp, proxPointer=pp and docFreq= df
 
-        CND_PRECONDITION(df >= 0, "df contains negative number");
-        CND_PRECONDITION(fp >= 0, "fp contains negative number");
-        CND_PRECONDITION(pp >= 0, "pp contains negative number");
+    CND_PRECONDITION(df >= 0, "df contains negative number");
+    CND_PRECONDITION(fp >= 0, "fp contains negative number");
+    CND_PRECONDITION(pp >= 0, "pp contains negative number");
 
-        freqPointer = fp;
-        proxPointer = pp;
-		  docFreq     = df;
-        skipOffset = 0;
-	}
+    freqPointer = fp;
+    proxPointer = pp;
+	  docFreq     = df;
+    skipOffset = 0;
+}
 
-	TermInfo::TermInfo(const TermInfo* ti) {
-    //Func - Constructor. 
-	//       Initialises this instance by copying the values of another TermInfo ti
-    //Pre  - ti is a reference to another TermInfo
-	//       ti->docFreq >= 0
-	//       ti->freqPointer >= 0
-	//       ti->proxPointer >= 0
-    //Post - Values of ti have been copied to the values of this Instance.
+TermInfo::TermInfo(const TermInfo* ti) {
+//Func - Constructor. 
+//       Initialises this instance by copying the values of another TermInfo ti
+//Pre  - ti is a reference to another TermInfo
+//       ti->docFreq >= 0
+//       ti->freqPointer >= 0
+//       ti->proxPointer >= 0
+//Post - Values of ti have been copied to the values of this Instance.
 
-        CND_PRECONDITION(ti->docFreq     >= 0, "ti->docFreq contains negative number");
-        CND_PRECONDITION(ti->freqPointer >= 0, "ti->freqPointer contains negative number");
-        CND_PRECONDITION(ti->proxPointer >= 0, "ti->proxPointer contains negative number");
+    CND_PRECONDITION(ti->docFreq     >= 0, "ti->docFreq contains negative number");
+    CND_PRECONDITION(ti->freqPointer >= 0, "ti->freqPointer contains negative number");
+    CND_PRECONDITION(ti->proxPointer >= 0, "ti->proxPointer contains negative number");
 
-		docFreq     = ti->docFreq;
-		freqPointer = ti->freqPointer;
-		proxPointer = ti->proxPointer;
-      skipOffset  = ti->skipOffset;
-	}
+	docFreq     = ti->docFreq;
+	freqPointer = ti->freqPointer;
+	proxPointer = ti->proxPointer;
+  skipOffset  = ti->skipOffset;
+}
 
-	void TermInfo::set(const int32_t df, const int64_t fp, const int64_t pp, const int32_t so) {
-    //Func - Sets a new document frequency, a new freqPointer and a new proxPointer
-    //Pre  - df >= 0, fp >= 0 pp >= 0
-    //Post - The new document frequency, a new freqPointer and a new proxPointer
-	//       have been set
+void TermInfo::set(const int32_t df, const int64_t fp, const int64_t pp, const int32_t so) {
+//Func - Sets a new document frequency, a new freqPointer and a new proxPointer
+//Pre  - df >= 0, fp >= 0 pp >= 0
+//Post - The new document frequency, a new freqPointer and a new proxPointer
+//       have been set
 
-        CND_PRECONDITION(df >= 0, "df contains negative number");
-        CND_PRECONDITION(fp >= 0, "fp contains negative number");
-        CND_PRECONDITION(pp >= 0, "pp contains negative number");
+    CND_PRECONDITION(df >= 0, "df contains negative number");
+    CND_PRECONDITION(fp >= 0, "fp contains negative number");
+    CND_PRECONDITION(pp >= 0, "pp contains negative number");
 
-		docFreq     = df;
-		freqPointer = fp;
-		proxPointer = pp;
-        skipOffset  = so;
-	}
+	docFreq     = df;
+	freqPointer = fp;
+	proxPointer = pp;
+    skipOffset  = so;
+}
 
-	void TermInfo::set(const TermInfo* ti) {
-    //Func - Sets a new document frequency, a new freqPointer and a new proxPointer
-	//       by copying these values from another instance of TermInfo
-    //Pre  - ti is a reference to another TermInfo
-	//       ti->docFreq >= 0
-	//       ti->freqPointer >= 0
-	//       ti->proxPointer >= 0
-    //Post - Values of ti have been copied to the values of this Instance.
+void TermInfo::set(const TermInfo* ti) {
+//Func - Sets a new document frequency, a new freqPointer and a new proxPointer
+//       by copying these values from another instance of TermInfo
+//Pre  - ti is a reference to another TermInfo
+//       ti->docFreq >= 0
+//       ti->freqPointer >= 0
+//       ti->proxPointer >= 0
+//Post - Values of ti have been copied to the values of this Instance.
 
-        CND_PRECONDITION(ti->docFreq     >= 0, "ti->docFreq contains negative number");
-        CND_PRECONDITION(ti->freqPointer >= 0, "ti->freqPointer contains negative number");
-        CND_PRECONDITION(ti->proxPointer >= 0, "ti->proxPointer contains negative number");
+    CND_PRECONDITION(ti->docFreq     >= 0, "ti->docFreq contains negative number");
+    CND_PRECONDITION(ti->freqPointer >= 0, "ti->freqPointer contains negative number");
+    CND_PRECONDITION(ti->proxPointer >= 0, "ti->proxPointer contains negative number");
 
-		docFreq     = ti->docFreq;
-		freqPointer = ti->freqPointer;
-		proxPointer = ti->proxPointer;
-        skipOffset =  ti->skipOffset;
-	}
+	docFreq     = ti->docFreq;
+	freqPointer = ti->freqPointer;
+	proxPointer = ti->proxPointer;
+    skipOffset =  ti->skipOffset;
+}
 CL_NS_END
-

Modified: trunk/clucene/src/CLucene/index/TermInfo.h
===================================================================
--- trunk/clucene/src/CLucene/index/TermInfo.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/TermInfo.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_TermInfo
 #define _lucene_index_TermInfo
 
@@ -24,44 +15,44 @@
 
 CL_NS_DEF(index)
 
-   LUCENE_MP_DEFINE(TermInfo)
-	// A TermInfo is the record of information stored for a term.
-	class TermInfo: LUCENE_POOLEDBASE(TermInfo){
-	public:
-		// The number of documents which contain the term. 
-		int32_t docFreq;
+LUCENE_MP_DEFINE(TermInfo)
+// A TermInfo is the record of information stored for a term.
+class TermInfo: LUCENE_POOLEDBASE(TermInfo){
+public:
+	// The number of documents which contain the term. 
+	int32_t docFreq;
 
-		//A pointer into the TermFreqs file (.frq)
-		//The .frq file contains the lists of documents which contain each term, 
-		//along with the frequency of the term in that document.
-		int64_t freqPointer;
+	//A pointer into the TermFreqs file (.frq)
+	//The .frq file contains the lists of documents which contain each term, 
+	//along with the frequency of the term in that document.
+	int64_t freqPointer;
 
-		//A pointer into the TermPosition file (.prx).
-		//The .prx file contains the lists of positions that each term 
-		//occurs at within documents.
-		int64_t proxPointer;
+	//A pointer into the TermPosition file (.prx).
+	//The .prx file contains the lists of positions that each term 
+	//occurs at within documents.
+	int64_t proxPointer;
 
-      int32_t skipOffset;
+  int32_t skipOffset;
 
-        //Constructor
-		TermInfo();
+    //Constructor
+	TermInfo();
 
-        //Constructor
-		TermInfo(const int32_t df, const int64_t fp, const int64_t pp);
+    //Constructor
+	TermInfo(const int32_t df, const int64_t fp, const int64_t pp);
 
-		//Constructor
-		//Initialises this instance by copying the values of another TermInfo ti
-		TermInfo(const TermInfo* ti);
+	//Constructor
+	//Initialises this instance by copying the values of another TermInfo ti
+	TermInfo(const TermInfo* ti);
 
-        //Destructor
-		~TermInfo();
+    //Destructor
+	~TermInfo();
 
-		//Sets a new document frequency, a new freqPointer and a new proxPointer
-		void set(const int32_t docFreq, const int64_t freqPointer, const int64_t proxPointer, int32_t skipOffset);
+	//Sets a new document frequency, a new freqPointer and a new proxPointer
+	void set(const int32_t docFreq, const int64_t freqPointer, const int64_t proxPointer, int32_t skipOffset);
 
-		//Sets a new document frequency, a new freqPointer and a new proxPointer
-	    //by copying these values from another instance of TermInfo
-		void set(const TermInfo* ti);
-	};
+	//Sets a new document frequency, a new freqPointer and a new proxPointer
+    //by copying these values from another instance of TermInfo
+	void set(const TermInfo* ti);
+};
 CL_NS_END
 #endif

Modified: trunk/clucene/src/CLucene/index/TermInfosReader.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/TermInfosReader.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/TermInfosReader.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "TermInfosReader.h"
 
@@ -59,8 +50,8 @@
 	  char* tiiFile = Misc::segmentname(segment,".tii");
 
       //Create an SegmentTermEnum for storing all the terms read of the segment
-      origEnum = _CLNEW SegmentTermEnum( directory->openFile( tisFile ), fieldInfos, false);
-      indexEnum = _CLNEW SegmentTermEnum( directory->openFile( tiiFile ), fieldInfos, true);
+      origEnum = _CLNEW SegmentTermEnum( directory->openInput( tisFile ), fieldInfos, false);
+      indexEnum = _CLNEW SegmentTermEnum( directory->openInput( tiiFile ), fieldInfos, true);
 
 	  //Check if enumerator points to a valid instance
       CND_CONDITION(origEnum != NULL, "No memory could be allocated for orig enumerator");
@@ -110,7 +101,6 @@
          _CLDELETE_ARRAY(indexInfos);
      }
 
-	 
 #ifdef _CL_DISABLE_MULTITHREADING
 	  _CLDELETE(stEnumerator);
 #endif
@@ -123,7 +113,7 @@
 
 	    //Get a pointer to IndexInput used by the enumeration but 
 	    //instantiated in the constructor by directory.open( tisFile )
-        lucene::store::IndexInput *is = origEnum->input;
+        IndexInput *is = origEnum->input;
 
         //Delete the enumuration enumerator
         _CLDELETE(origEnum);
@@ -137,7 +127,7 @@
 
 	    //Get a pointer to IndexInput used by the enumeration but 
 	    //instantiated in the constructor by directory.open( tiiFile )
-        lucene::store::IndexInput *is = indexEnum->input;
+        IndexInput *is = indexEnum->input;
 
         //Delete the enumuration enumerator
         _CLDELETE(indexEnum);
@@ -147,7 +137,7 @@
       }
   }
 
-  int64_t TermInfosReader::size() {
+  int64_t TermInfosReader::size() const{
   //Func - Return the size of the enumeration of TermInfos
   //Pre  - true
   //Post - size has been returened
@@ -194,6 +184,7 @@
 		  stEnumerator = terms();
 	return stEnumerator;
 #else
+	SCOPED_LOCK_MUTEX(enumerators_LOCK)
 	SegmentTermEnum* termEnum = enumerators.get(_LUCENE_CURRTHREADID);
     if (termEnum == NULL){
       termEnum = terms();
@@ -201,7 +192,7 @@
     }
     return termEnum;
 #endif
-	  }
+  }
 
   TermInfo* TermInfosReader::get(const Term* term){
   //Func - Returns a TermInfo for a term
@@ -337,7 +328,7 @@
 
 		  //Iterate through the terms of indexEnum
           for (int32_t i = 0; indexEnum->next(); i++){
-              indexTerms[i].set(indexEnum->term(false)->field(),indexEnum->term(false)->text(),false);
+              indexTerms[i].set(indexEnum->term(false),indexEnum->term(false)->text());
               indexEnum->getTermInfo(&indexInfos[i]);
               indexPointers[i] = indexEnum->indexPointer;
           }

Modified: trunk/clucene/src/CLucene/index/TermInfosReader.h
===================================================================
--- trunk/clucene/src/CLucene/index/TermInfosReader.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/TermInfosReader.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_TermInfosReader_
 #define _lucene_index_TermInfosReader_
 
@@ -44,8 +35,9 @@
 		SegmentTermEnum* stEnumerator;
 #else
 		CL_NS(util)::CLSet<_LUCENE_THREADID_TYPE, SegmentTermEnum*, 
-			CLuceneThreadIdCompare, 
+			CL_NS(util)::CLuceneThreadIdCompare, 
 			CL_NS(util)::Deletor::ConstNullVal<_LUCENE_THREADID_TYPE>, CL_NS(util)::Deletor::Object<SegmentTermEnum> > enumerators;
+		DEFINE_MUTEX(enumerators_LOCK)
 #endif
 		SegmentTermEnum* getEnum();
 		SegmentTermEnum* origEnum;
@@ -68,7 +60,7 @@
 		void close();
 		
 		//Return the size of the enumeration of TermInfos
-		int64_t size();
+		int64_t size() const;
 
 		int32_t getSkipInterval() { return origEnum->skipInterval; }
 		

Modified: trunk/clucene/src/CLucene/index/TermInfosWriter.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/TermInfosWriter.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/TermInfosWriter.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "TermInfosWriter.h"
 
@@ -80,7 +71,7 @@
 		skipInterval = LUCENE_DEFAULT_TERMDOCS_SKIP_INTERVAL;
 
 	    const char* buf = Misc::segmentname(segment, (isIndex ? ".tii" : ".tis"));
-	    output = directory->createFile( buf );
+	    output = directory->createOutput( buf );
 	    _CLDELETE_CaARRAY(buf);
 
       output->writeInt(FORMAT);                      // write format
@@ -172,7 +163,7 @@
 		output->writeVInt(fieldnum); // write field num
 
 		if ( lastTerm->__cl_refcount == 1 ){
-			lastTerm->set(term->field(),term->text(),false);
+			lastTerm->set(term,term->text());
 		}else{
 			_CLDECDELETE(lastTerm);
 			lastTerm = _CL_POINTER(term);

Modified: trunk/clucene/src/CLucene/index/TermInfosWriter.h
===================================================================
--- trunk/clucene/src/CLucene/index/TermInfosWriter.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/TermInfosWriter.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_TermInfosWriter_
 #define _lucene_index_TermInfosWriter_
 

Modified: trunk/clucene/src/CLucene/index/TermVector.h
===================================================================
--- trunk/clucene/src/CLucene/index/TermVector.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/TermVector.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_termvector_h
 #define _lucene_index_termvector_h
 
@@ -126,7 +117,7 @@
 		int32_t termTextLen; //textlen cache
 	public:
 		int32_t freq;
-		const TCHAR* getTermText();
+		const TCHAR* getTermText() const;
 		size_t getTermTextLen();
 		void setTermText(const TCHAR* val);
 		TVTerm();
@@ -174,7 +165,7 @@
   
   /** Close all streams. */
   void close();
-  bool isDocumentOpen();
+  bool isDocumentOpen() const;
   
   /** Start processing a field. This can be followed by a number of calls to
    *  addTerm, and a final call to closeField to indicate the end of
@@ -189,7 +180,7 @@
   void closeField();
   
   /** Return true if a field is currently open. */
-  bool isFieldOpen();
+  bool isFieldOpen() const;
   
   /** Add specified vectors to the document.
    */
@@ -231,7 +222,7 @@
    * @return The number of the field this vector is associated with
    */
   const TCHAR* getField();
-  TCHAR* toString();
+  TCHAR* toString() const;
   int32_t size();
   const TCHAR** getTerms();
   const int32_t* getTermFrequencies();
@@ -283,12 +274,12 @@
   TermVectorOffsetInfo();
   ~TermVectorOffsetInfo();
   TermVectorOffsetInfo(int32_t startOffset, int32_t endOffset);
-  int32_t getEndOffset();
+  int32_t getEndOffset() const;
   void setEndOffset(int32_t endOffset);
-  int32_t getStartOffset();
+  int32_t getStartOffset() const;
   void setStartOffset(int32_t startOffset);
   bool equals(TermVectorOffsetInfo* o);
-  size_t hashCode();
+  size_t hashCode() const;
 };
 
 

Modified: trunk/clucene/src/CLucene/index/TermVectorReader.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/TermVectorReader.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/TermVectorReader.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "TermVector.h"
 #include "CLucene/util/StringBuffer.h"
@@ -21,21 +12,21 @@
 CL_NS_DEF(index)
 
 TermVectorsReader::TermVectorsReader(CL_NS(store)::Directory* d, const char* segment, FieldInfos* fieldInfos){
-	char fbuf[CL_MAX_DIR];
+	char fbuf[CL_MAX_NAME];
 	strcpy(fbuf,segment);
 	char* fpbuf=fbuf+strlen(fbuf);
 
 	strcpy(fpbuf,LUCENE_TVX_EXTENSION);
 	if (d->fileExists(fbuf)) {
-      tvx = d->openFile(fbuf);
+      tvx = d->openInput(fbuf);
       checkValidFormat(tvx);
 	  
 	  strcpy(fpbuf,LUCENE_TVD_EXTENSION);
-	  tvd = d->openFile(fbuf);
+	  tvd = d->openInput(fbuf);
       checkValidFormat(tvd);
 	  
 	  strcpy(fpbuf,LUCENE_TVF_EXTENSION);
-	  tvf = d->openFile(fbuf);
+	  tvf = d->openInput(fbuf);
       checkValidFormat(tvf);
 
       _size = tvx->length() / 8;
@@ -295,7 +286,7 @@
 	this->startOffset = startOffset;
 }
 
-int32_t TermVectorOffsetInfo::getEndOffset() {
+int32_t TermVectorOffsetInfo::getEndOffset() const{
 	return endOffset;
 }
 
@@ -303,7 +294,7 @@
 	this->endOffset = endOffset;
 }
 
-int32_t TermVectorOffsetInfo::getStartOffset() {
+int32_t TermVectorOffsetInfo::getStartOffset() const{
 	return startOffset;
 }
 
@@ -325,7 +316,7 @@
 	return true;
 }
 
-size_t TermVectorOffsetInfo::hashCode() {
+size_t TermVectorOffsetInfo::hashCode() const{
 	size_t result;
 	result = startOffset;
 	result = 29 * result + endOffset;

Modified: trunk/clucene/src/CLucene/index/TermVectorWriter.cpp
===================================================================
--- trunk/clucene/src/CLucene/index/TermVectorWriter.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/TermVectorWriter.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,21 +1,11 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "TermVector.h"
-#include "CLucene/util/StringBuffer.h"
 #include "CLucene/util/Misc.h"
 
 CL_NS_USE(util)
@@ -25,20 +15,20 @@
     const char* segment,FieldInfos* fieldInfos)
  {
     // Open files for TermVector storage
-	char fbuf[CL_MAX_DIR];
+	char fbuf[CL_MAX_NAME];
 	strcpy(fbuf,segment);
 	char* fpbuf=fbuf+strlen(fbuf);
 
 	strcpy(fpbuf,LUCENE_TVX_EXTENSION);
-    tvx = directory->createFile(fbuf);
+    tvx = directory->createOutput(fbuf);
     tvx->writeInt(FORMAT_VERSION);
 
 	strcpy(fpbuf,LUCENE_TVD_EXTENSION);
-    tvd = directory->createFile(fbuf);
+    tvd = directory->createOutput(fbuf);
     tvd->writeInt(FORMAT_VERSION);
 	
 	strcpy(fpbuf,LUCENE_TVF_EXTENSION);
-    tvf = directory->createFile(fbuf);
+    tvf = directory->createOutput(fbuf);
     tvf->writeInt(FORMAT_VERSION);
 
     this->fieldInfos = fieldInfos;
@@ -80,7 +70,7 @@
   }
 
 
-  bool TermVectorsWriter::isDocumentOpen() {
+  bool TermVectorsWriter::isDocumentOpen() const{
     return currentDocPointer != -1;
   }
 
@@ -107,7 +97,7 @@
     }
   }
 
-  bool TermVectorsWriter::isFieldOpen() {
+  bool TermVectorsWriter::isFieldOpen() const{
     return currentField != NULL;
   }
 
@@ -255,7 +245,7 @@
   }
 
 
-  const TCHAR* TermVectorsWriter::TVTerm::getTermText(){
+  const TCHAR* TermVectorsWriter::TVTerm::getTermText() const{
       return termText;
   }
     size_t TermVectorsWriter::TVTerm::getTermTextLen(){ 

Modified: trunk/clucene/src/CLucene/index/Terms.h
===================================================================
--- trunk/clucene/src/CLucene/index/Terms.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/index/Terms.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_index_Terms_
 #define _lucene_index_Terms_
 
@@ -23,140 +14,156 @@
 #include "Term.h"
 CL_NS_DEF(index)
 
-    class TermEnum; //predefine
-	class TermPositions;
+class TermEnum; //predefine
+class TermPositions;
 
-    class TermDocs: LUCENE_BASE {
-	public:
-		virtual ~TermDocs(){
-		}
+/** TermDocs provides an interface for enumerating &lt;document, frequency&gt;
+ pairs for a term.  <p> The document portion names each document containing
+ the term.  Documents are indicated by number.  The frequency portion gives
+ the number of times the term occurred in each document.  <p> The pairs are
+ ordered by document number.
 
-		// Sets this to the data for a term.
-		// The enumeration is reset to the start of the data for this term.
-		virtual void seek(Term* term)=0;
+ @see IndexReader#termDocs()
+ */
+class TermDocs: LUCENE_BASE {
+public:
+	virtual ~TermDocs(){
+	}
 
-		/** Sets this to the data for the current term in a {@link TermEnum}.
-		* This may be optimized in some implementations.
-		*/
-		virtual void seek(TermEnum* termEnum)=0;
+	// Sets this to the data for a term.
+	// The enumeration is reset to the start of the data for this term.
+	virtual void seek(Term* term)=0;
 
-		// Returns the current document number.  <p> This is invalid until {@link
-		//	#next()} is called for the first time.
-		virtual int32_t doc() const=0;
+	/** Sets this to the data for the current term in a {@link TermEnum}.
+	* This may be optimized in some implementations.
+	*/
+	virtual void seek(TermEnum* termEnum)=0;
 
-		// Returns the frequency of the term within the current document.  <p> This
-		//	is invalid until {@link #next()} is called for the first time.
-		virtual int32_t freq() const=0;
+	// Returns the current document number.  <p> This is invalid until {@link
+	//	#next()} is called for the first time.
+	virtual int32_t doc() const=0;
 
-		// Moves to the next pair in the enumeration.  <p> Returns true iff there is
-		//	such a next pair in the enumeration.
-		virtual bool next() =0;
+	// Returns the frequency of the term within the current document.  <p> This
+	//	is invalid until {@link #next()} is called for the first time.
+	virtual int32_t freq() const=0;
 
-		// Attempts to read multiple entries from the enumeration, up to length of
-		// <i>docs</i>.  Document numbers are stored in <i>docs</i>, and term
-		// frequencies are stored in <i>freqs</i>.  The <i>freqs</i> array must be as
-		// int64_t as the <i>docs</i> array.
-		//
-		// <p>Returns the number of entries read.  Zero is only returned when the
-		// stream has been exhausted.
-		virtual int32_t read(int32_t* docs, int32_t* freqs, int32_t length)=0;
+	// Moves to the next pair in the enumeration.  <p> Returns true iff there is
+	//	such a next pair in the enumeration.
+	virtual bool next() =0;
 
-		// Skips entries to the first beyond the current whose document number is
-		// greater than or equal to <i>target</i>. <p>Returns true iff there is such
-		// an entry.  <p>Behaves as if written: <pre>
-		//   bool skipTo(int32_t target) {
-		//     do {
-		//       if (!next())
-		// 	     return false;
-		//     } while (target > doc());
-		//     return true;
-		//   }
-		// </pre>
-		// Some implementations are considerably more efficient than that.
-		virtual bool skipTo(const int32_t target)=0;
+	// Attempts to read multiple entries from the enumeration, up to length of
+	// <i>docs</i>.  Document numbers are stored in <i>docs</i>, and term
+	// frequencies are stored in <i>freqs</i>.  The <i>freqs</i> array must be as
+	// int64_t as the <i>docs</i> array.
+	//
+	// <p>Returns the number of entries read.  Zero is only returned when the
+	// stream has been exhausted.
+	virtual int32_t read(int32_t* docs, int32_t* freqs, int32_t length)=0;
 
-		// Frees associated resources.
-		virtual void close() = 0;
+	// Skips entries to the first beyond the current whose document number is
+	// greater than or equal to <i>target</i>. <p>Returns true iff there is such
+	// an entry.  <p>Behaves as if written: <pre>
+	//   bool skipTo(int32_t target) {
+	//     do {
+	//       if (!next())
+	// 	     return false;
+	//     } while (target > doc());
+	//     return true;
+	//   }
+	// </pre>
+	// Some implementations are considerably more efficient than that.
+	virtual bool skipTo(const int32_t target)=0;
 
-		
-		/** Solve the diamond inheritence problem by providing a reinterpret function.
-		  *	No dynamic casting is required and no RTTI data is needed to do this
-		  */
-		virtual TermPositions* __asTermPositions()=0;
-	};
+	// Frees associated resources.
+	virtual void close() = 0;
 
+	
+	/** Solve the diamond inheritence problem by providing a reinterpret function.
+	  *	No dynamic casting is required and no RTTI data is needed to do this
+	  */
+	virtual TermPositions* __asTermPositions()=0;
+};
 
-	// Abstract class for enumerating terms.
-	//
-	//<p>Term enumerations are always ordered by Term.compareTo().  Each term in
-	//the enumeration is greater than all that precede it.  
-	class TermEnum: LUCENE_BASE {
-	public:
-		// Increments the enumeration to the next element.  True if one exists.
-		virtual bool next()=0;
 
-		// Returns the current Term in the enumeration.
-		virtual Term* term(const bool pointer=true)=0;
+// Abstract class for enumerating terms.
+//
+//<p>Term enumerations are always ordered by Term.compareTo().  Each term in
+//the enumeration is greater than all that precede it.  
+class TermEnum: LUCENE_BASE {
+public:
+	// Increments the enumeration to the next element.  True if one exists.
+	virtual bool next()=0;
 
-		// Returns the docFreq of the current Term in the enumeration.
-		virtual int32_t docFreq() const=0;
+	// Returns a pointer to the current Term in the enumeration.
+	virtual Term* term()=0;
+	
+	// Returns the current Term in the enumeration.
+	virtual Term* term(bool pointer){
+		Term* ret = term();
+		if ( !pointer )
+			ret->__cl_decref();
+		return ret;
+	}
 
-		// Closes the enumeration to further activity, freeing resources.
-		virtual void close() =0;
+	// Returns the docFreq of the current Term in the enumeration.
+	virtual int32_t docFreq() const=0;
 
-		virtual ~TermEnum(){
-		}
+	// Closes the enumeration to further activity, freeing resources.
+	virtual void close() =0;
 
-      // Term Vector support
-      /** Skips terms to the first beyond the current whose value is
-      * greater or equal to <i>target</i>. <p>Returns true iff there is such
-      * an entry.  <p>Behaves as if written: <pre>
-      *   public boolean skipTo(Term target) {
-      *     do {
-      *       if (!next())
-      * 	     return false;
-      *     } while (target > term());
-      *     return true;
-      *   }
-      * </pre>
-      * Some implementations are considerably more efficient than that.
-      */
-      virtual bool skipTo(Term* target){
-         do {
-            if (!next())
-  	            return false;
-         } while (target->compareTo(term(false)) > 0);
-         return true;
-      }
-	};
+	virtual ~TermEnum(){
+	}
+	
+	// Term Vector support
+	/** Skips terms to the first beyond the current whose value is
+	* greater or equal to <i>target</i>. <p>Returns true iff there is such
+	* an entry.  <p>Behaves as if written: <pre>
+	*   public boolean skipTo(Term target) {
+	*     do {
+	*       if (!next())
+	* 	     return false;
+	*     } while (target > term());
+	*     return true;
+	*   }
+	* </pre>
+	* Some implementations are considerably more efficient than that.
+	*/
+	virtual bool skipTo(Term* target){
+		do {
+			if (!next())
+				return false;
+		} while (target->compareTo(term(false)) > 0);
+		return true;
+	}
+};
 
 
 
-	/**
-   * TermPositions provides an interface for enumerating the &lt;document,
-   * frequency, &lt;position&gt;* &gt; tuples for a term.  <p> The document and
-   * frequency are the same as for a TermDocs.  The positions portion lists the ordinal
-   * positions of each occurrence of a term in a document.
-   *
-   * @see IndexReader#termPositions
-   */
-	class TermPositions: public virtual TermDocs {
-	public:
-		// Returns next position in the current document.  It is an error to call
-		//	this more than {@link #freq()} times
-		//	without calling {@link #next()}<p> This is
-		//	invalid until {@link #next()} is called for
-		//	the first time.
-		virtual int32_t nextPosition() = 0;
+/**
+ * TermPositions provides an interface for enumerating the &lt;document,
+ * frequency, &lt;position&gt;* &gt; tuples for a term.  <p> The document and
+ * frequency are the same as for a TermDocs.  The positions portion lists the ordinal
+ * positions of each occurrence of a term in a document.
+ *
+ * @see IndexReader#termPositions()
+ */
+class TermPositions: public virtual TermDocs {
+public:
+	// Returns next position in the current document.  It is an error to call
+	//	this more than {@link #freq()} times
+	//	without calling {@link #next()}<p> This is
+	//	invalid until {@link #next()} is called for
+	//	the first time.
+	virtual int32_t nextPosition() = 0;
 
-		virtual ~TermPositions(){
-		}
+	virtual ~TermPositions(){
+	}
 
-		/** Solve the diamond inheritence problem by providing a reinterpret function.
-		  *	No dynamic casting is required and no RTTI data is needed to do this
-		  */
-		virtual TermDocs* __asTermDocs()=0;
-		virtual TermPositions* __asTermPositions()=0;
-	};
+	/** Solve the diamond inheritence problem by providing a reinterpret function.
+	  *	No dynamic casting is required and no RTTI data is needed to do this
+	  */
+	virtual TermDocs* __asTermDocs()=0;
+	virtual TermPositions* __asTermPositions()=0;
+};
 CL_NS_END
 #endif

Modified: trunk/clucene/src/CLucene/queryParser/Lexer.cpp
===================================================================
--- trunk/clucene/src/CLucene/queryParser/Lexer.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/queryParser/Lexer.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "Lexer.h"
 
@@ -165,6 +156,7 @@
          case '*':
             QueryParserBase::throwParserException( _T("Unrecognized TCHAR %d at %d::%d."), 
                ch, reader->Column(), reader->Line() );
+            return NULL;
          default:
             return ReadTerm(ch);
 

Modified: trunk/clucene/src/CLucene/queryParser/Lexer.h
===================================================================
--- trunk/clucene/src/CLucene/queryParser/Lexer.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/queryParser/Lexer.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_queryParser_Lexer_
 #define _lucene_queryParser_Lexer_
 

Modified: trunk/clucene/src/CLucene/queryParser/MultiFieldQueryParser.cpp
===================================================================
--- trunk/clucene/src/CLucene/queryParser/MultiFieldQueryParser.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/queryParser/MultiFieldQueryParser.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "MultiFieldQueryParser.h"
 #include "CLucene/analysis/AnalysisHeader.h"
@@ -52,10 +43,10 @@
             uint8_t flag = flags[i];
             switch (flag)
             {
-                case queryParser_REQUIRED_FIELD:
+				case MultiFieldQueryParser::REQUIRED_FIELD:
                     bQuery->add(q, true, true, false);
                     break;
-                case queryParser_PROHIBITED_FIELD:
+                case MultiFieldQueryParser::PROHIBITED_FIELD:
                     bQuery->add(q, true, false, true);
                     break;
                 default:

Modified: trunk/clucene/src/CLucene/queryParser/MultiFieldQueryParser.h
===================================================================
--- trunk/clucene/src/CLucene/queryParser/MultiFieldQueryParser.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/queryParser/MultiFieldQueryParser.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef MultiFieldQueryParser_H
 #define MultiFieldQueryParser_H
 
@@ -27,9 +18,6 @@
 
 CL_NS_DEF(queryParser)
 	
-#define queryParser_NORMAL_FIELD     0
-#define queryParser_REQUIRED_FIELD   1
-#define queryParser_PROHIBITED_FIELD 2
     /**
      * A QueryParser which constructs queries to search multiple fields.
      *
@@ -37,6 +25,9 @@
     class MultiFieldQueryParser: public QueryParser
     {
     public:
+    	LUCENE_STATIC_CONSTANT(uint8_t, NORMAL_FIELD=0);
+		LUCENE_STATIC_CONSTANT(uint8_t, REQUIRED_FIELD=1);
+		LUCENE_STATIC_CONSTANT(uint8_t, PROHIBITED_FIELD=2);
     
         /*MultiFieldQueryParser(QueryParserTokenManager tm)
         {

Modified: trunk/clucene/src/CLucene/queryParser/QueryParser.cpp
===================================================================
--- trunk/clucene/src/CLucene/queryParser/QueryParser.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/queryParser/QueryParser.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "QueryParser.h"
 
@@ -154,20 +145,17 @@
         CND_PRECONDITION(tokens != NULL, "tokens is NULL");
 
 		switch(tokens->peek()->Type){
-			case CL_NS(queryParser)::AND_ :{
+			case CL_NS(queryParser)::AND_ :
 				//Delete the first token of tokenlist
 				ExtractAndDeleteToken();
 				return CONJ_AND;
-				}
-			case CL_NS(queryParser)::OR   :{
+			case CL_NS(queryParser)::OR   :
 				//Delete the first token of tokenlist
 				ExtractAndDeleteToken();
 				return CONJ_OR;
-				}
-			default : {
+			default :
 				return CONJ_NONE;
-				}
-			}
+		}
 	}
 
 	int32_t QueryParser::MatchModifier(){
@@ -180,22 +168,18 @@
 		CND_PRECONDITION(tokens != NULL, "tokens is NULL");
 
 		switch(tokens->peek()->Type){
-			case CL_NS(queryParser)::PLUS :{
+			case CL_NS(queryParser)::PLUS :
 				//Delete the first token of tokenlist
 				ExtractAndDeleteToken();
 				return MOD_REQ;
-				}
-
 			case CL_NS(queryParser)::MINUS :
-			case CL_NS(queryParser)::NOT   :{
+			case CL_NS(queryParser)::NOT   :
 				//Delete the first token of tokenlist
 				ExtractAndDeleteToken();
 				return MOD_NOT;
-				}
-			default :{
+			default :
 				return MOD_NONE;
-				}
-			}
+		}
 	}
 
 	Query* QueryParser::MatchQuery(const TCHAR* field){
@@ -566,7 +550,7 @@
 		  _sntprintf(buf,200,_T("Error: Unexpected QueryToken: %d, expected: %d"),t->Type,expectedType);
 		  _CLDELETE(t);
 		  QueryParserBase::throwParserException(buf,' ',0,0);
-		  }
+		}
 
 	  //Return the matched token
 	  return t;

Modified: trunk/clucene/src/CLucene/queryParser/QueryParser.h
===================================================================
--- trunk/clucene/src/CLucene/queryParser/QueryParser.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/queryParser/QueryParser.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_queryParser_QueryParser_
 #define _lucene_queryParser_QueryParser_
 
@@ -91,11 +82,11 @@
 
 
 
-		void  setLowercaseWildcardTerms(bool lowercaseWildcardTerms)
-		{ this->lowercaseWildcardTerms = lowercaseWildcardTerms;}
+		void  setLowercaseWildcardTerms(bool lowercaseWildcardTerms){ 
+			this->lowercaseWildcardTerms = lowercaseWildcardTerms;
+		}
 		
-		bool getLowercaseWildcardTerms()
-		{ return lowercaseWildcardTerms; }
+		bool getLowercaseWildcardTerms() const { return lowercaseWildcardTerms; }
 
 	private:
 		// matches for CONJUNCTION

Modified: trunk/clucene/src/CLucene/queryParser/QueryParserBase.cpp
===================================================================
--- trunk/clucene/src/CLucene/queryParser/QueryParserBase.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/queryParser/QueryParserBase.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "QueryParserBase.h"
 
@@ -27,14 +18,10 @@
 #include "CLucene/search/PrefixQuery.h"
 #include "CLucene/search/FuzzyQuery.h"
 
-#include "CLucene/analysis/standard/StandardFilter.h"
-#include "CLucene/analysis/standard/StandardTokenizer.h"
 
-
 CL_NS_USE(search)
 CL_NS_USE(util)
 CL_NS_USE(analysis)
-CL_NS_USE2(analysis,standard)
 CL_NS_USE(index)
 
 CL_NS_DEF(queryParser)
@@ -55,7 +42,7 @@
 	}
 
 	
-	TCHAR* QueryParserBase::discardEscapeChar(const TCHAR* source){
+	TCHAR* QueryParserBase::discardEscapeChar(const TCHAR* source) const{
 		int len = _tcslen(source);
 		TCHAR* dest = _CL_NEWARRAY(TCHAR, len+1);
 
@@ -189,7 +176,7 @@
 					Term* t = _CLNEW Term(field, data);
 					q->add(t);
 					_CLDECDELETE(t);
-					itr++;
+					++itr;
 					}
 				_CLDELETE(source);
 				return q;
@@ -213,7 +200,7 @@
 	  * Gets implicit operator setting, which will be either OPERATOR_AND
 	  * or OPERATOR_OR.
 	  */
-	int QueryParserBase::getOperator() {
+	int QueryParserBase::getOperator() const{
 	    return oper;
 	}
 

Modified: trunk/clucene/src/CLucene/queryParser/QueryParserBase.h
===================================================================
--- trunk/clucene/src/CLucene/queryParser/QueryParserBase.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/queryParser/QueryParserBase.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_queryParser_QueryParserBase_
 #define _lucene_queryParser_QueryParserBase_
 
@@ -67,7 +58,7 @@
 		static void throwParserException(const TCHAR* message, TCHAR ch, int32_t col, int32_t line );
 
 		void setOperator(int oper);
-		int getOperator();
+		int getOperator() const;
 
     protected:
         //todo: we should make these virtual so that users can override the QueryParser
@@ -111,7 +102,7 @@
 		* Returns a String where the escape char has been
 		* removed, or kept only once if there was a double escape.
 		*/
-		TCHAR* discardEscapeChar(const TCHAR* token);
+		TCHAR* discardEscapeChar(const TCHAR* token) const;
 	};
 CL_NS_END
 #endif

Modified: trunk/clucene/src/CLucene/queryParser/QueryParserConstants.h
===================================================================
--- trunk/clucene/src/CLucene/queryParser/QueryParserConstants.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/queryParser/QueryParserConstants.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_queryParser_QueryParserConstants_
 #define _lucene_queryParser_QueryParserConstants_
 

Modified: trunk/clucene/src/CLucene/queryParser/QueryToken.cpp
===================================================================
--- trunk/clucene/src/CLucene/queryParser/QueryToken.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/queryParser/QueryToken.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "QueryToken.h"
 

Modified: trunk/clucene/src/CLucene/queryParser/QueryToken.h
===================================================================
--- trunk/clucene/src/CLucene/queryParser/QueryToken.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/queryParser/QueryToken.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_queryParser_QueryToken_
 #define _lucene_queryParser_QueryToken_
 

Modified: trunk/clucene/src/CLucene/queryParser/TokenList.cpp
===================================================================
--- trunk/clucene/src/CLucene/queryParser/TokenList.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/queryParser/TokenList.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "TokenList.h"
 
@@ -81,7 +72,7 @@
         return token;
     }
 
-    int32_t TokenList::count()
+    int32_t TokenList::count() const
     {
       return tokens.size();
     }

Modified: trunk/clucene/src/CLucene/queryParser/TokenList.h
===================================================================
--- trunk/clucene/src/CLucene/queryParser/TokenList.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/queryParser/TokenList.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_queryParser_TokenList_
 #define _lucene_queryParser_TokenList_
 
@@ -41,7 +32,7 @@
 
 		QueryToken* extract();
 
-		int32_t count();
+		int32_t count() const;
 	};
 CL_NS_END
 #endif

Modified: trunk/clucene/src/CLucene/search/BooleanClause.h
===================================================================
--- trunk/clucene/src/CLucene/search/BooleanClause.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/BooleanClause.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_BooleanClause_
 #define _lucene_search_BooleanClause_
 
@@ -28,14 +19,11 @@
 		class Compare:public CL_NS_STD(binary_function)<const BooleanClause*,const BooleanClause*,bool>
 		{
 		public:
-			bool operator()( const BooleanClause* val1, const BooleanClause* val2 ){
+			bool operator()( const BooleanClause* val1, const BooleanClause* val2 ) const{
 				return val1->equals(val2);
 			}
 		};
 
-
-		bool deleteQuery;
-
 		// The query whose matching documents are combined by the boolean query. 
 		Query* query;
 	   
@@ -48,6 +36,8 @@
 		// If true, documents documents which <i>do</i>
 		//	match this sub-query will <i>not</i> match the boolean query. 
 		bool prohibited;
+
+		bool deleteQuery;
 	      
 		// Constructs a BooleanClause with query <code>q</code>, required
 		//	<code>r</code> and prohibited <code>p</code>.  
@@ -84,7 +74,7 @@
 				&& (this->prohibited == other->prohibited);
 		}
 
-		size_t hashCode(){
+		size_t hashCode() const{
 			return query->hashCode() ^ (this->required?1:0) ^ (this->prohibited?2:0);
 		}
 	};

Modified: trunk/clucene/src/CLucene/search/BooleanQuery.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/BooleanQuery.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/BooleanQuery.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "BooleanQuery.h"
 
@@ -95,58 +86,11 @@
     clauses.push_back(clause);
   }
 
-  /*void BooleanQuery::prepare(IndexReader* reader) {
-    for (uint32_t i = 0 ; i < clauses.size(); i++) {
-      BooleanClause* c = clauses[i];
-      c->query->prepare(reader);
-    }
-  }
 
-  void BooleanQuery::normalize(const float_t norm) {
-    for (uint32_t i = 0 ; i < clauses.size(); i++) {
-      BooleanClause* c = clauses[i];
-      if (!c->prohibited)
-        c->query->normalize(norm);
-    }
-  }
-  float_t BooleanQuery::sumOfSquaredWeights(Searcher* searcher){
-    float_t sum = 0.0f;
-
-    for (uint32_t i = 0 ; i < clauses.size(); i++) {
-      BooleanClause* c = clauses[i];
-      if (!c->prohibited)
-        sum += c->query->sumOfSquaredWeights(searcher); // sum sub-query weights
-    }
-
-    return sum;
-  }
-*/
-
-
   size_t BooleanQuery::getClauseCount() const {
     return (int32_t) clauses.size();
   }
 
-  /*Scorer* BooleanQuery::scorer(IndexReader* reader){
-    if (clauses.size() == 1) {			  // optimize 1-term queries
-      BooleanClause* c = clauses[0];
-      if (!c->prohibited)			  // just return term scorer
-        return c->query->scorer(reader);
-    }
-
-    BooleanScorer* result = _CLNEW BooleanScorer;
-    for (uint32_t i = 0 ; i < clauses.size(); i++) {
-      BooleanClause* c = clauses[i];
-      Scorer* subScorer = c->query->scorer(reader);
-      if (subScorer != NULL)
-        result->add(subScorer, c->required, c->prohibited);
-      else if (c->required)
-        return NULL;
-    }
-
-    return result;
-  }*/
-
   TCHAR* BooleanQuery::toString(const TCHAR* field) const{
     StringBuffer buffer;
     if (getBoost() != 1.0) {
@@ -163,13 +107,13 @@
       if ( c->query->instanceOf(BooleanQuery::getClassName()) ) {	  // wrap sub-bools in parens
         buffer.append(_T("("));
 
-        const TCHAR* buf = c->query->toString(field);
+        TCHAR* buf = c->query->toString(field);
         buffer.append(buf);
         _CLDELETE_CARRAY( buf );
 
         buffer.append(_T(")"));
       } else {
-        const TCHAR* buf = c->query->toString(field);
+        TCHAR* buf = c->query->toString(field);
         buffer.append(buf);
         _CLDELETE_CARRAY( buf );
       }
@@ -270,7 +214,6 @@
 		this->parentQuery = parentQuery;
 		this->clauses = clauses;
 		for (uint32_t i = 0 ; i < clauses->size(); i++) {
-			BooleanClause* c = (*clauses)[i];
 			weights.push_back((*clauses)[i]->query->createWeight(searcher));
 		}
 	}

Modified: trunk/clucene/src/CLucene/search/BooleanQuery.h
===================================================================
--- trunk/clucene/src/CLucene/search/BooleanQuery.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/BooleanQuery.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_BooleanQuery_
 #define _lucene_search_BooleanQuery_
 

Modified: trunk/clucene/src/CLucene/search/BooleanScorer.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/BooleanScorer.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/BooleanScorer.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "BooleanScorer.h"
 
@@ -24,14 +15,14 @@
 
   BooleanScorer::BooleanScorer(Similarity* similarity):
     Scorer(similarity),
-	coordFactors (NULL),
+    scorers(NULL),
     maxCoord (1),
-    requiredMask (0),
-    prohibitedMask (0),
     nextMask (1),
-    scorers(NULL),
 	end(0),
-	current(NULL)
+	current(NULL),
+    requiredMask (0),
+    prohibitedMask (0),
+	coordFactors (NULL)
   {
     bucketTable = _CLNEW BucketTable(this);
   }
@@ -148,7 +139,13 @@
 
 
 
-  BooleanScorer::SubScorer::SubScorer(Scorer* scr, const bool r, const bool p, HitCollector* c, SubScorer* nxt){
+  BooleanScorer::SubScorer::SubScorer(Scorer* scr, const bool r, const bool p, HitCollector* c, SubScorer* nxt):
+      scorer(scr),
+      required(r),
+      prohibited(p),
+      collector(c),
+      next(nxt)
+  {
   //Func - Constructor
   //Pre  - scr != NULL, 
   //       c   != NULL
@@ -158,11 +155,6 @@
       CND_PRECONDITION(scr != NULL,"scr is NULL");
       CND_PRECONDITION(c != NULL,"c is NULL");
 
-      scorer      = scr;
-      collector   = c;
-      required    = r;
-      prohibited  = p;
-      next        = nxt;
       done        = !scorer->next();
   }
 
@@ -182,12 +174,14 @@
   }
 
   BooleanScorer::Bucket::Bucket():
-      doc(-1)
-  {
+      doc(-1),
+      score(0.0),
+      bits(0),
+      coord(0),
+      next(NULL)
+  {	
   }
   BooleanScorer::Bucket::~Bucket(){
-    //if ( next != NULL )
-    //	delete next;
   }
 
 
@@ -208,36 +202,6 @@
     //delete first;
     first = NULL;
   }
-  /*void BucketTable::collectHits(HitCollector* results){
-        int32_t required = scorer->requiredMask;
-        int32_t prohibited = scorer.prohibitedMask;
-        float_t* coord = scorer.coordFactors;
-
-        for (Bucket* bucket = first; bucket!=NULL; bucket = bucket.next) {
-	        if ((bucket->bits & prohibited) == 0 &&	  // check prohibited
-	        (bucket->bits & required) == required){// check required
-	        results.collect(bucket.doc,		  // add to results
-			    bucket->score * coord[bucket.coord]);
-	        }
-        }
-        first = NULL;				  // reset for next round
-    }
-  void BucketTable::collectHits(HitCollector* results){
-    const int32_t required = scorer->requiredMask;
-    const int32_t prohibited = scorer->prohibitedMask;
-    const float_t* coord = scorer->coordFactors;
-
-    for (Bucket* bucket = first; bucket!=NULL; bucket = bucket->next) {
-      if ((bucket->bits & prohibited) == 0 &&	  // check prohibited
-          (bucket->bits & required) == required){// check required
-
-        results->collect(bucket->doc,		  // add to results
-          bucket->score * coord[bucket->coord]);
-      }
-    }
-    clear(); //first = NULL;				  // reset for next round
-  }*/
-
   int32_t BooleanScorer::BucketTable::size() const { return BooleanScorer::BucketTable_SIZE; }
 
   HitCollector* BooleanScorer::BucketTable::newCollector(const int32_t mask) {
@@ -253,8 +217,8 @@
 
 
   BooleanScorer::Collector::Collector(const int32_t msk, BucketTable* bucketTbl):
-    mask(msk),
-    bucketTable(bucketTbl)
+    bucketTable(bucketTbl),
+    mask(msk)
   {
   }
 

Modified: trunk/clucene/src/CLucene/search/BooleanScorer.h
===================================================================
--- trunk/clucene/src/CLucene/search/BooleanScorer.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/BooleanScorer.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_BooleanScorer_
 #define _lucene_search_BooleanScorer_
 
@@ -41,14 +32,14 @@
 
 		class SubScorer: LUCENE_BASE {
 		public:
-		bool done;
-				Scorer* scorer;
-				bool required;
-				bool prohibited;
-				HitCollector* collector;
-				SubScorer* next;
-				SubScorer(Scorer* scr, const bool r, const bool p, HitCollector* c, SubScorer* nxt);
-				~SubScorer();
+			bool done;
+			Scorer* scorer;
+			bool required;
+			bool prohibited;
+			HitCollector* collector;
+			SubScorer* next;
+			SubScorer(Scorer* scr, const bool r, const bool p, HitCollector* c, SubScorer* nxt);
+			~SubScorer();
 		};
 
 		class BucketTable:LUCENE_BASE {		
@@ -56,14 +47,11 @@
 			BooleanScorer* scorer;
 		public:
 			Bucket* buckets;
+			Bucket* first;			  // head of valid list
 
 			BucketTable(BooleanScorer* scr);
-			//void collectHits(HitCollector* results);
 			int32_t size() const;
 			HitCollector* newCollector(const int32_t mask);
-
-			Bucket* first;			  // head of valid list
-
 			void clear();
 			~BucketTable();
 	      
@@ -84,28 +72,23 @@
 
 		int32_t maxCoord;
 		int32_t nextMask;
+		
+		void computeCoordFactors();
+		//void score(HitCollector* results, const int32_t maxDoc);
+
+      	int32_t end;
+		Bucket* current;
 	public:
 		LUCENE_STATIC_CONSTANT(int32_t,BucketTable_SIZE=1024);
 		int32_t requiredMask;
 		int32_t prohibitedMask;
 		float_t* coordFactors;
 
-    BooleanScorer(Similarity* similarity);
+    	BooleanScorer(Similarity* similarity);
 		~BooleanScorer();
 		void add(Scorer* scorer, const bool required, const bool prohibited);
-
-	private:
-		void computeCoordFactors();
-		//void score(HitCollector* results, const int32_t maxDoc);
-
-      int32_t end;
-		Bucket* current;
-
-	public:
 		int32_t doc() { return current->doc; }
-
 		bool next();
-
 		float_t score();
 		bool skipTo(int32_t target);
 		Explanation* explain(int32_t doc);

Modified: trunk/clucene/src/CLucene/search/CachingWrapperFilter.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/CachingWrapperFilter.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/CachingWrapperFilter.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "CachingWrapperFilter.h"
 
@@ -50,7 +41,7 @@
 	cache.put(reader,bsh);
 	return bs;
 }
-void AbstractCachingFilter::closeCallback(CL_NS(index)::IndexReader* reader, void* param){
+void AbstractCachingFilter::closeCallback(CL_NS(index)::IndexReader* reader, void*){
 	SCOPED_LOCK_MUTEX(cache.THIS_LOCK)
 	cache.remove(reader);
 }

Modified: trunk/clucene/src/CLucene/search/CachingWrapperFilter.h
===================================================================
--- trunk/clucene/src/CLucene/search/CachingWrapperFilter.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/CachingWrapperFilter.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_CachingWrapperFilter_
 #define _lucene_search_CachingWrapperFilter_
 
@@ -72,8 +63,8 @@
 private:
 	Filter* filter;
 	bool deleteFilter;
-	CachingWrapperFilter( const CachingWrapperFilter& copy );
 protected:
+	CachingWrapperFilter( const CachingWrapperFilter& copy );
 	CL_NS(util)::BitSet* doBits( CL_NS(index)::IndexReader* reader );
 	bool doShouldDeleteBitSet( CL_NS(util)::BitSet* bits );
 public:

Modified: trunk/clucene/src/CLucene/search/ChainedFilter.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/ChainedFilter.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/ChainedFilter.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,96 +1,48 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 
 #include <CLucene/StdHeader.h>
 #include <CLucene/util/Misc.h>
 #include "ChainedFilter.h"
 
-/*
-	Discussion - brian at unixpoet.com
-	
-	From ChainedFilter.java:
-
-	...
-	
-	/*
-	* First AND operation takes place against a completely false
-	* bitset and will always return zero results. Thanks to
-	* Daniel Armbrust for pointing this out and suggesting workaround.
-	*//*
-	if (logic[0] == AND)
-	{
-		result = (BitSet) chain[i].bits(reader).clone();
-		++i;
-	}
-	
-	...
-	
-	The observation is correct and it was buggy. The problem is that the same
-	issue remains for the ANDNOT logic op but with the inverse result: all bits
-	set to 1. The result of the other ops, i.e. OR, AND, XOR for the first filter
-	ends up just copying the bitset of the first filter (explicitly in the case of the AND).
-	
-	Why not do the same for the NAND? This will have the side effect of rendering the first op
-	in the logic array superflous - not a big problem.
-	
-	The only "problem" is that we will return different results then the Java 
-	Lucene code - though I prefer CLucene to be a correct implementation and only maintain 
-	API compat rather than full 100% compat with Lucene.	
-*/
 CL_NS_DEF(search)
 CL_NS_USE(index)
 CL_NS_USE(util)
 CL_NS_USE(document)
 
 
-ChainedFilter::ChainedFilter( Filter ** filters, int _op )
+ChainedFilter::ChainedFilter( Filter ** _filters, int _op ):
+	filters(_filters),
+	logicArray(NULL),
+	logic(_op)
 {
-	this->filters = filters;
-	this->logic   = _op;
-	this->logicArray = NULL;
 }
-
-
-ChainedFilter::ChainedFilter( Filter** filters, int* _array )
+ChainedFilter::ChainedFilter( Filter** _filters, int* _array ):
+	filters(_filters),
+	logicArray(_array),
+	logic(-1)
 {
-	this->filters = filters;
-	this->logic   = -1;
-	this->logicArray = _array;
 }
-
-
+ChainedFilter::ChainedFilter( const ChainedFilter& copy ) :
+	logicArray( copy.logicArray ),
+	logic( copy.logic )
+{
+	filters = copy.filters;
+}
 ChainedFilter::~ChainedFilter(void)
 {
 	
 }
 
-
-ChainedFilter::ChainedFilter( const ChainedFilter& copy ) :
-	filters( copy.filters ),
-	logic( copy.logic ),
-	logicArray( copy.logicArray )
-{
-}
-
-
 Filter* ChainedFilter::clone() const {
 	return _CLNEW ChainedFilter(*this );
 }
 
-TCHAR* ChainedFilter::getLogicString(int logic){
+const TCHAR* ChainedFilter::getLogicString(int logic){
 	if ( logic == ChainedFilter::OR )
 		return _T("OR");
 	else if ( logic == ChainedFilter::AND )
@@ -233,19 +185,19 @@
 		{
 		case OR:
 			for( i=0; i < maxDoc; i++ )
-				resultset->set( i, resultset->get(i) || (filterbits==NULL || filterbits->get(i) ) );
+				resultset->set( i, (resultset->get(i) || (filterbits==NULL || filterbits->get(i) ))?1:0 );
 			break;
 		case AND:
 			for( i=0; i < maxDoc; i++ )
-				resultset->set( i, resultset->get(i) && (filterbits==NULL || filterbits->get(i) ) );
+				resultset->set( i, (resultset->get(i) && (filterbits==NULL || filterbits->get(i) ))?1:0 );
 			break;
 		case ANDNOT:
 			for( i=0; i < maxDoc; i++ )
-				resultset->set( i, !(resultset->get(i) && (filterbits==NULL || filterbits->get(i) ) ) );
+				resultset->set( i, (resultset->get(i) && (filterbits==NULL || filterbits->get(i)))?0:1 );
 			break;
 		case XOR:
 			for( i=0; i < maxDoc; i++ )
-				resultset->set( i, resultset->get(i) ^ (filterbits==NULL || filterbits->get(i) ) );
+				resultset->set( i, resultset->get(i) ^ ((filterbits==NULL || filterbits->get(i) )?1:0) );
 			break;
 		default:
 			doChain( resultset, reader, DEFAULT, filter );

Modified: trunk/clucene/src/CLucene/search/ChainedFilter.h
===================================================================
--- trunk/clucene/src/CLucene/search/ChainedFilter.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/ChainedFilter.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_ChainedFilter_
 #define _lucene_search_ChainedFilter_
 
@@ -22,6 +13,37 @@
 
 CL_NS_DEF(search)
 
+/*
+Discussion - brian at unixpoet.com
+
+From ChainedFilter.java:
+
+...
+
+// First AND operation takes place against a completely false
+// bitset and will always return zero results. Thanks to
+// Daniel Armbrust for pointing this out and suggesting workaround.
+
+if (logic[0] == AND)
+{
+	result = (BitSet) chain[i].bits(reader).clone();
+	++i;
+}
+
+...
+
+The observation is correct and it was buggy. The problem is that the same
+issue remains for the ANDNOT logic op but with the inverse result: all bits
+set to 1. The result of the other ops, i.e. OR, AND, XOR for the first filter
+ends up just copying the bitset of the first filter (explicitly in the case of the AND).
+
+Why not do the same for the NAND? This will have the side effect of rendering the first op
+in the logic array superflous - not a big problem.
+
+The only "problem" is that we will return different results then the Java 
+Lucene code - though I prefer CLucene to be a correct implementation and only maintain 
+API compat rather than full 100% compat with Lucene.	
+*/
 class ChainedFilter: public Filter 
 {
 public:	
@@ -45,7 +67,7 @@
 	CL_NS(util)::BitSet* doChain( CL_NS(util)::BitSet* result, CL_NS(index)::IndexReader* reader, int logic, Filter* filter );
 
 	virtual void doUserChain( CL_NS(util)::BitSet* chain, CL_NS(util)::BitSet* filter, int logic );
-	virtual TCHAR* getLogicString(int logic);
+	virtual const TCHAR* getLogicString(int logic);
 public:
 	ChainedFilter( Filter** filters, int op = DEFAULT );
 	ChainedFilter( Filter** filters, int* _array );

Modified: trunk/clucene/src/CLucene/search/Compare.h
===================================================================
--- trunk/clucene/src/CLucene/search/Compare.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/Compare.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_Compare_
 #define _lucene_search_Compare_
 
@@ -26,6 +17,8 @@
 
 
 class ScoreDocComparators:LUCENE_BASE {
+protected:
+	ScoreDocComparators(){}
 public:
     ~ScoreDocComparators(){
     }
@@ -41,7 +34,7 @@
 			return _CLNEW CL_NS(util)::Compare::Float (i->score);
 		}
 		int32_t sortType() {
-			return SortField::SCORE;
+			return SortField::DOCSCORE;
 		}
 	};
 

Modified: trunk/clucene/src/CLucene/search/ConjunctionScorer.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/ConjunctionScorer.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/ConjunctionScorer.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "ConjunctionScorer.h"
 #include "CLucene/util/Arrays.h"
@@ -31,12 +22,13 @@
 	 if ( scorers.end() == scorers.begin() )
 		return NULL;
 
-	CL_NS_STD(list)<Scorer*>::iterator i = scorers.end();
-	i--;
+	 CL_NS_STD(list)<Scorer*>::iterator i = scorers.end();
+	 --i;
 	 return *i; 
   } //get Last
 
   class _ScorerSorter:public CL_NS(util)::Arrays::_Arrays<Scorer*>{
+  public:
 	bool equals(Scorer* o1,Scorer* o2) const{
 		return o1->doc() == o2->doc();
 	}
@@ -84,7 +76,7 @@
 	CL_NS_STD(list)<Scorer*>::iterator i = scorers.begin();
     while (more && i!=scorers.end()) {
       more = ((Scorer*)*i)->next();
-	  i++;
+	  ++i;
     }
 
     if (more)
@@ -94,10 +86,11 @@
   }
 
 	ConjunctionScorer::ConjunctionScorer(Similarity* similarity):
+		Scorer(similarity),
+		scorers(false),
 		firstTime(true),
 		more(true),
-		Scorer(similarity),
-		scorers(false)
+		coord(0.0)
 	{
     }
 	ConjunctionScorer::~ConjunctionScorer(){
@@ -105,7 +98,7 @@
 	}
 
 	TCHAR *CL_NS(search)::Scorer::toString(void){
-		return _T("ConjunctionScorer");
+		return STRDUP_TtoT(_T("ConjunctionScorer"));
 	}
 	
 
@@ -129,8 +122,7 @@
     CL_NS_STD(list)<Scorer*>::iterator i = scorers.begin();
     while (more && i!=scorers.end()) {
       more = ((Scorer*)*i)->skipTo(target);
-
-	  i++;
+	  ++i;
     }
     if (more)
       sortScorers();                              // re-sort scorers
@@ -142,8 +134,7 @@
     CL_NS_STD(list)<Scorer*>::iterator i = scorers.begin();
 	while (i!=scorers.end()){
       score += (*i)->score();
-
-	  i++;
+	  ++i;
 	}
     score *= coord;
     return score;

Modified: trunk/clucene/src/CLucene/search/ConjunctionScorer.h
===================================================================
--- trunk/clucene/src/CLucene/search/ConjunctionScorer.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/ConjunctionScorer.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_ConjunctionScorer_
 #define _lucene_search_ConjunctionScorer_
 
@@ -41,7 +32,7 @@
   ConjunctionScorer(Similarity* similarity);
   virtual ~ConjunctionScorer();
   TCHAR* toString(void){
-	return _T("ConjunctionScorer");
+	return STRDUP_TtoT(_T("ConjunctionScorer"));
   }
   void add(Scorer* scorer);
   int32_t doc();

Modified: trunk/clucene/src/CLucene/search/DateFilter.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/DateFilter.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/DateFilter.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "DateFilter.h"
 

Modified: trunk/clucene/src/CLucene/search/DateFilter.h
===================================================================
--- trunk/clucene/src/CLucene/search/DateFilter.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/DateFilter.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_DateFilter_
 #define _lucene_search_DateFilter_
 
@@ -40,7 +31,8 @@
 
     TCHAR* start;
     TCHAR* end;
-    
+
+  protected:
     DateFilter(const DateFilter& copy);
   public:
     ~DateFilter();

Modified: trunk/clucene/src/CLucene/search/ExactPhraseScorer.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/ExactPhraseScorer.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/ExactPhraseScorer.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "ExactPhraseScorer.h"
 

Modified: trunk/clucene/src/CLucene/search/ExactPhraseScorer.h
===================================================================
--- trunk/clucene/src/CLucene/search/ExactPhraseScorer.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/ExactPhraseScorer.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_ExactPhraseScorer_
 #define _lucene_search_ExactPhraseScorer_
 

Modified: trunk/clucene/src/CLucene/search/Explanation.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/Explanation.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/Explanation.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "Explanation.h"
 #include "CLucene/util/StringBuffer.h"
@@ -21,6 +12,16 @@
 CL_NS_DEF(search)
 
 
+Explanation::Explanation(float_t value, const TCHAR* description) {
+ this->value = value;
+ _tcsncpy(this->description,description,LUCENE_SEARCH_EXPLANATION_DESC_LEN);
+}
+
+Explanation::Explanation() {
+ this->value = 0;
+ this->description[0]=0;
+}
+
 Explanation::Explanation(const Explanation& copy){
     this->value = copy.value;
     STRCPY_TtoT(description,copy.description,LUCENE_SEARCH_EXPLANATION_DESC_LEN);
@@ -29,14 +30,14 @@
     itr = details.begin();
     while ( itr != details.end() ){
         details.push_back( (*itr)->clone() );
-        itr++;
+        ++itr;
     }
 }
 
 Explanation::~Explanation(){
 }
 
-void Explanation::setDescription(TCHAR* description) {
+void Explanation::setDescription(const TCHAR* description) {
    _tcsncpy(this->description,description,LUCENE_SEARCH_EXPLANATION_DESC_LEN);
 }
 
@@ -45,7 +46,7 @@
    return _CLNEW Explanation(*this); 
 }
 
-float_t Explanation::getValue() { 
+float_t Explanation::getValue() const{ 
    return value; 
 }
   
@@ -53,7 +54,7 @@
    this->value = value; 
 }
 
-TCHAR* Explanation::getDescription() { 
+const TCHAR* Explanation::getDescription() const { 
    return description; 
 }
 
@@ -82,11 +83,6 @@
  return buffer.toString();
 }
 
-Explanation::Explanation(float_t value, TCHAR* description) {
- this->value = value;
- _tcsncpy(this->description,description,LUCENE_SEARCH_EXPLANATION_DESC_LEN);
-}
-
 /** The sub-nodes of this explanation node. */
 Explanation** Explanation::getDetails() {
  Explanation** ret = _CL_NEWARRAY(Explanation*,details.size()+1);

Modified: trunk/clucene/src/CLucene/search/Explanation.h
===================================================================
--- trunk/clucene/src/CLucene/search/Explanation.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/Explanation.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_Explanation
 #define _lucene_search_Explanation
 
@@ -30,26 +21,27 @@
       CL_NS(util)::CLArrayList<Explanation*,CL_NS(util)::Deletor::Object<Explanation> > details;                      // sub-explanations
 
       TCHAR* toString(int32_t depth);
+   protected:
       Explanation(const Explanation& copy);
    public:
-      Explanation() {}
+      Explanation();
       ~Explanation();
 
-      Explanation(float_t value, TCHAR* description);
+      Explanation(float_t value, const TCHAR* description);
 
       Explanation* clone() const;
 
       /** The value assigned to this explanation node. */
-      float_t getValue();
+      float_t getValue() const;
         
       /** Sets the value assigned to this explanation node. */
       void setValue(float_t value);
 
       /** A description of this explanation node. */
-      TCHAR* getDescription(); ///<returns reference
+      const TCHAR* getDescription() const; ///<returns reference
         
       /** Sets the description of this explanation node. */
-      void setDescription(TCHAR* description);
+      void setDescription(const TCHAR* description);
 
       /** The sub-nodes of this explanation node. */
       Explanation** getDetails();

Modified: trunk/clucene/src/CLucene/search/FieldCache.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/FieldCache.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/FieldCache.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "FieldCache.h"
 #include "FieldCacheImpl.h"
@@ -26,6 +17,14 @@
 	contentType = type;
 	contentLen = len;
 	ownContents = false;
+	
+	intArray=NULL;
+	floatArray=NULL;
+	stringIndex=NULL;
+	stringArray=NULL;
+	comparableArray=NULL;
+	sortComparator=NULL;
+	scoreDocComparator=NULL;
 }
 FieldCacheAuto::~FieldCacheAuto(){
 	if ( contentType == FieldCacheAuto::INT_ARRAY ){

Modified: trunk/clucene/src/CLucene/search/FieldCache.h
===================================================================
--- trunk/clucene/src/CLucene/search/FieldCache.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/FieldCache.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_FieldCache_
 #define _lucene_search_FieldCache_
 

Modified: trunk/clucene/src/CLucene/search/FieldCacheImpl.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/FieldCacheImpl.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/FieldCacheImpl.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "FieldCacheImpl.h"
 
@@ -530,7 +521,7 @@
 			if ( f->getType() != SortField::AUTO )
 				_CLDELETE( itr->second );
 			_CLDELETE( f );
-			itr++;
+			++itr;
 		}
 		clear();
 	}

Modified: trunk/clucene/src/CLucene/search/FieldCacheImpl.h
===================================================================
--- trunk/clucene/src/CLucene/search/FieldCacheImpl.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/FieldCacheImpl.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_FieldCacheImpl_
 #define _lucene_search_FieldCacheImpl_
 
@@ -49,10 +40,10 @@
 		FileEntry (const TCHAR* field, SortComparatorSource* custom);
 		~FileEntry();
 
-		int32_t getType(){ return type; }
+		int32_t getType() const{ return type; }
 	   
 		/** Two of these are equal iff they reference the same field and type. */
-		bool equals (FileEntry* other);
+		bool equals (FileEntry* other) const;
 	   
 		/** Composes a hashcode based on the field and type. */
 		size_t hashCode();

Modified: trunk/clucene/src/CLucene/search/FieldDoc.h
===================================================================
--- trunk/clucene/src/CLucene/search/FieldDoc.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/FieldDoc.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_FieldDoc_
 #define _lucene_search_FieldDoc_
 

Modified: trunk/clucene/src/CLucene/search/FieldDocSortedHitQueue.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/FieldDocSortedHitQueue.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/FieldDocSortedHitQueue.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "FieldDocSortedHitQueue.h"
 
@@ -31,22 +22,22 @@
 		int32_t type = fields[i]->getType();
 		if (fields[i]->getReverse()) {
 			switch (type) {
-				case SortField::SCORE:
-					r1 = ((Compare::Float*)docA->fields[i])->getValue();
-					r2 = ((Compare::Float*)docB->fields[i])->getValue();
+				case SortField::DOCSCORE:
+					r1 = __REINTERPRET_CAST(Compare::Float*, docA->fields[i])->getValue();
+					r2 = __REINTERPRET_CAST(Compare::Float*, docB->fields[i])->getValue();
 					if (r1 < r2) c = -1;
 					if (r1 > r2) c = 1;
 					break;
 				case SortField::DOC:
 				case SortField::INT:
-					i1 = ((Compare::Int32*)docA->fields[i])->getValue();
-					i2 = ((Compare::Int32*)docB->fields[i])->getValue();
+					i1 = __REINTERPRET_CAST(Compare::Int32*, docA->fields[i])->getValue();
+					i2 = __REINTERPRET_CAST(Compare::Int32*, docB->fields[i])->getValue();
 					if (i1 > i2) c = -1;
 					if (i1 < i2) c = 1;
 					break;
 				case SortField::STRING:
-					s1 = ((Compare::TChar*) docA->fields[i])->getValue();
-					s2 = ((Compare::TChar*) docB->fields[i])->getValue();
+					s1 = __REINTERPRET_CAST(Compare::TChar*, docA->fields[i])->getValue();
+					s2 = __REINTERPRET_CAST(Compare::TChar*, docB->fields[i])->getValue();
 					if (s2 == NULL) c = -1;      // could be NULL if there are
 					else if (s1 == NULL) c = 1;  // no terms in the given field
 					else c = _tcscmp(s2,s1); //else if (fields[i].getLocale() == NULL) {
@@ -57,8 +48,8 @@
 					}*/
 					break;
 				case SortField::FLOAT:
-					f1 = ((Compare::Float*)docA->fields[i])->getValue();
-					f2 = ((Compare::Float*)docB->fields[i])->getValue();
+					f1 = __REINTERPRET_CAST(Compare::Float*, docA->fields[i])->getValue();
+					f2 = __REINTERPRET_CAST(Compare::Float*, docB->fields[i])->getValue();
 					if (f1 > f2) c = -1;
 					if (f1 < f2) c = 1;
 					break;
@@ -76,22 +67,22 @@
 			}
 		} else {
 			switch (type) {
-				case SortField::SCORE:
-					r1 = ((Compare::Float*)docA->fields[i])->getValue();
-					r2 = ((Compare::Float*)docB->fields[i])->getValue();
+				case SortField::DOCSCORE:
+					r1 = __REINTERPRET_CAST(Compare::Float*, docA->fields[i])->getValue();
+					r2 = __REINTERPRET_CAST(Compare::Float*, docB->fields[i])->getValue();
 					if (r1 > r2) c = -1;
 					if (r1 < r2) c = 1;
 					break;
 				case SortField::DOC:
 				case SortField::INT:
-					i1 = ((Compare::Int32*)docA->fields[i])->getValue();
-					i2 = ((Compare::Int32*)docB->fields[i])->getValue();
+					i1 = __REINTERPRET_CAST(Compare::Int32*, docA->fields[i])->getValue();
+					i2 = __REINTERPRET_CAST(Compare::Int32*, docB->fields[i])->getValue();
 					if (i1 < i2) c = -1;
 					if (i1 > i2) c = 1;
 					break;
 				case SortField::STRING:
-					s1 = ((Compare::TChar*) docA->fields[i])->getValue();
-					s2 = ((Compare::TChar*) docB->fields[i])->getValue();
+					s1 = __REINTERPRET_CAST(Compare::TChar*, docA->fields[i])->getValue();
+					s2 = __REINTERPRET_CAST(Compare::TChar*, docB->fields[i])->getValue();
 					// NULL values need to be sorted first, because of how FieldCache.getStringIndex()
 					// works - in that routine, any documents without a value in the given field are
 					// put first.
@@ -104,8 +95,8 @@
 					}*/
 					break;
 				case SortField::FLOAT:
-					f1 = ((Compare::Float*)docA->fields[i])->getValue();
-					f2 = ((Compare::Float*)docB->fields[i])->getValue();
+					f1 = __REINTERPRET_CAST(Compare::Float*, docA->fields[i])->getValue();
+					f2 = __REINTERPRET_CAST(Compare::Float*, docB->fields[i])->getValue();
 					if (f1 < f2) c = -1;
 					if (f1 > f2) c = 1;
 					break;
@@ -126,7 +117,7 @@
 	return c > 0;
 }
 
-void FieldDocSortedHitQueue::setFields (SortField** fields) {
+void FieldDocSortedHitQueue::setFields (const SortField** fields) {
 	SCOPED_LOCK_MUTEX(THIS_LOCK)
 	if (this->fields == NULL) {
 		this->fields = fields;

Modified: trunk/clucene/src/CLucene/search/FieldDocSortedHitQueue.h
===================================================================
--- trunk/clucene/src/CLucene/search/FieldDocSortedHitQueue.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/FieldDocSortedHitQueue.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_FieldDocSortedHitQueue_
 #define _lucene_search_FieldDocSortedHitQueue_
 
@@ -44,7 +35,7 @@
 
 	// this cannot contain AUTO fields - any AUTO fields should
 	// have been resolved by the time this class is used.
-	SortField** fields; //volatile 
+	const SortField** fields; //volatile 
 	int32_t fieldsLen;
 	
 	void _countsize(){
@@ -64,7 +55,7 @@
 	 * @param fields Field names, in priority order (highest priority first).
 	 * @param size  The number of hits to retain.  Must be greater than zero.
 	 */
-	FieldDocSortedHitQueue (SortField** fields, int32_t size) {
+	FieldDocSortedHitQueue (const SortField** fields, int32_t size) {
 		this->fields = fields;
 		_countsize();
 		//this->collators = hasCollators (fields);
@@ -82,11 +73,11 @@
 	 * This method is thread safe.
 	 * @param fields
 	 */
-	void setFields (SortField** fields);
+	void setFields (const SortField** fields);
 
 
 	/** Returns the fields being used to sort. */
-	SortField** getFields() {
+	const SortField** getFields() {
 		return fields;
 	}
 

Modified: trunk/clucene/src/CLucene/search/FieldSortedHitQueue.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/FieldSortedHitQueue.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/FieldSortedHitQueue.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "FieldSortedHitQueue.h"
 #include "Compare.h"
@@ -23,24 +14,25 @@
 		
 FieldSortedHitQueue::hitqueueCacheType FieldSortedHitQueue::Comparators(false,true);
 
-FieldSortedHitQueue::FieldSortedHitQueue (IndexReader* reader, SortField** fields, int32_t size):
-	maxscore(1.0f),
-	fieldsLen(0)
+FieldSortedHitQueue::FieldSortedHitQueue (IndexReader* reader, SortField** _fields, int32_t size):
+	fieldsLen(0),
+	maxscore(1.0f)
 {
-	while ( fields[fieldsLen] != 0 )
+	while ( _fields[fieldsLen] != 0 )
 		fieldsLen++;
 
 	comparators = _CL_NEWARRAY(ScoreDocComparator*,fieldsLen+1);
-	this->fields = _CL_NEWARRAY(SortField*,fieldsLen+1);
+	SortField** tmp = _CL_NEWARRAY(SortField*,fieldsLen+1);
 	for (int32_t i=0; i<fieldsLen; ++i) {
-		const TCHAR* fieldname = fields[i]->getField();
+		const TCHAR* fieldname = _fields[i]->getField();
 		//todo: fields[i].getLocale(), not implemented
-		comparators[i] = getCachedComparator (reader, fieldname, fields[i]->getType(), fields[i]->getFactory());
-		this->fields[i] = _CLNEW SortField (fieldname, comparators[i]->sortType(), fields[i]->getReverse());
+		comparators[i] = getCachedComparator (reader, fieldname, _fields[i]->getType(), _fields[i]->getFactory());
+		tmp[i] = _CLNEW SortField (fieldname, comparators[i]->sortType(), _fields[i]->getReverse());
 	}
 	comparatorsLen = fieldsLen;
 	comparators[fieldsLen]=NULL;
-	this->fields[fieldsLen] = NULL;
+	tmp[fieldsLen] = NULL;
+	this->fields = tmp;
 
 	initialize(size,true);
 }
@@ -99,7 +91,7 @@
   ScoreDocComparator* FieldSortedHitQueue::getCachedComparator (IndexReader* reader, const TCHAR* fieldname, int32_t type, SortComparatorSource* factory){ 
 	if (type == SortField::DOC) 
 		return ScoreDocComparator::INDEXORDER;
-	if (type == SortField::SCORE) 
+	if (type == SortField::DOCSCORE) 
 		return ScoreDocComparator::RELEVANCE;
     ScoreDocComparator* comparator = lookup (reader, fieldname, type, factory);
     if (comparator == NULL) {
@@ -133,7 +125,7 @@
   }
   
   
-  FieldDoc* FieldSortedHitQueue::fillFields (FieldDoc* doc) {
+  FieldDoc* FieldSortedHitQueue::fillFields (FieldDoc* doc) const{
     int32_t n = comparatorsLen;
     Comparable** fields = _CL_NEWARRAY(Comparable*,n+1);
     for (int32_t i=0; i<n; ++i)
@@ -165,7 +157,7 @@
 	return sdc;
   }
 
-	void FieldSortedHitQueue::closeCallback(CL_NS(index)::IndexReader* reader, void* param){
+	void FieldSortedHitQueue::closeCallback(CL_NS(index)::IndexReader* reader, void*){
 		SCOPED_LOCK_MUTEX(Comparators.THIS_LOCK)
 		Comparators.remove(reader);
 	}

Modified: trunk/clucene/src/CLucene/search/FieldSortedHitQueue.h
===================================================================
--- trunk/clucene/src/CLucene/search/FieldSortedHitQueue.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/FieldSortedHitQueue.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_FieldSortedHitQueue_
 #define _lucene_search_FieldSortedHitQueue_
 
@@ -131,7 +122,7 @@
    * @return  The same FieldDoc passed in.
    * @see Searchable#search(Query,Filter,int32_t,Sort)
    */
-  FieldDoc* fillFields (FieldDoc* doc);
+  FieldDoc* fillFields (FieldDoc* doc) const;
 
 
   /** Returns the SortFields being used by this hit queue. */

Modified: trunk/clucene/src/CLucene/search/Filter.h
===================================================================
--- trunk/clucene/src/CLucene/search/Filter.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/Filter.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_Filter_
 #define _lucene_search_Filter_
 

Modified: trunk/clucene/src/CLucene/search/FilteredTermEnum.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/FilteredTermEnum.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/FilteredTermEnum.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 
 #include "FilteredTermEnum.h"
@@ -76,9 +67,8 @@
 					//Get a reference to the matched term
                     currentTerm = _CL_POINTER(term);
                     return true;
-                    }
                 }
-            else 
+            }else 
                 return false;
         }
         _CLDECDELETE(currentTerm);
@@ -87,17 +77,20 @@
         return false;
     }
 
-    Term* FilteredTermEnum::term(const bool pointer) {
+    Term* FilteredTermEnum::term() {
 	//Func - Returns the current Term in the enumeration.
 	//Pre  - next() must have been called at least once
 	//       pointer is true or false
 	//Post - if pre(pointer) is true the reference counter of currentTerm is increased
 	//       and current Term is returned otherwise currentTerm is only returned
 
-        if ( pointer && currentTerm!=NULL )
-            return _CL_POINTER(currentTerm);
+        return _CL_POINTER(currentTerm);
+    }
+    Term* FilteredTermEnum::term(bool pointer) {
+    	if ( pointer )
+        	return _CL_POINTER(currentTerm);
         else
-            return currentTerm;
+        	return currentTerm;
     }
 
     void FilteredTermEnum::close(){
@@ -137,7 +130,7 @@
             currentTerm = _CL_POINTER(term);
         }else{
             next();
-		  }
+		}
     }
 
 CL_NS_END

Modified: trunk/clucene/src/CLucene/search/FilteredTermEnum.h
===================================================================
--- trunk/clucene/src/CLucene/search/FilteredTermEnum.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/FilteredTermEnum.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_FilteredTermEnum_
 #define _lucene_search_FilteredTermEnum_
 
@@ -30,7 +21,7 @@
   //the enumeration is greater than all that precede it. 
   
   class FilteredTermEnum: public CL_NS(index)::TermEnum {
-    public:
+  public:
       //Constructor
       FilteredTermEnum();
 	  //Destructor
@@ -45,8 +36,9 @@
       //Increments the enumeration to the next element
       bool next() ;
         
-      //Returns the current Term in the enumeration.
-      CL_NS(index)::Term* term(const bool pointer=true) ;
+      //Returns a pointer to the current Term in the enumeration.
+      CL_NS(index)::Term* term();
+      CL_NS(index)::Term* term(bool pointer);
         
       //Closes the enumeration to further activity, freeing resources.
       void close();

Modified: trunk/clucene/src/CLucene/search/FuzzyQuery.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/FuzzyQuery.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/FuzzyQuery.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "FuzzyQuery.h"
 #ifndef NO_FUZZY_QUERY
@@ -32,11 +23,11 @@
      * @param prefixLength Length of required common prefix. Default value is 0.
      * @throws IOException
      */
-	 FuzzyTermEnum::FuzzyTermEnum(IndexReader* reader, Term* term, float_t minSimilarity, int32_t prefixLength): 
+	 FuzzyTermEnum::FuzzyTermEnum(const IndexReader* reader, Term* term, float_t minSimilarity, size_t prefixLength): 
+        distance(0),
         _endEnum(false),
 		prefix(LUCENE_BLANK_STRING),
 		prefixLength(0),
-        distance(0),
 
 		minimumSimilarity(minSimilarity)
 	{ //todo: check, used to pass (reader,term)
@@ -45,36 +36,36 @@
 	//       term != NULL
 	//Post - The instance has been created
 
-      CND_PRECONDITION(term != NULL,"term is NULL");
-
-		  scale_factor = 1.0f / (1.0f - minimumSimilarity);
-		  searchTerm = _CL_POINTER(term);
-
-		  text = STRDUP_TtoT(term->text());
-		  textLen = term->textLength();
-
-
-			//Initialize e to NULL
-			e          = NULL;
-			eWidth     = 0;
-			eHeight    = 0;
-
-			if(prefixLength > 0 && prefixLength < textLen){
-				this->prefixLength = prefixLength;
-	
-				prefix = _CL_NEWARRAY(TCHAR,prefixLength+1);
-				_tcsncpy(prefix,text,prefixLength);
-				prefix[prefixLength]='\0';
-	
-				textLen = prefixLength;
-				text[textLen]='\0';
-			}
-			
-
-			//Set the enumeration 
-		    Term* trm = _CLNEW Term(term->field(), prefix,false);
-			setEnum(reader->terms(trm));
-		    _CLDECDELETE(trm);
+		CND_PRECONDITION(term != NULL,"term is NULL");
+		
+		scale_factor = 1.0f / (1.0f - minimumSimilarity);
+		searchTerm = _CL_POINTER(term);
+		
+		text = STRDUP_TtoT(term->text());
+		textLen = term->textLength();
+		
+		
+		//Initialize e to NULL
+		e          = NULL;
+		eWidth     = 0;
+		eHeight    = 0;
+		
+		if(prefixLength > 0 && prefixLength < textLen){
+			this->prefixLength = prefixLength;
+		
+			prefix = _CL_NEWARRAY(TCHAR,prefixLength+1);
+			_tcsncpy(prefix,text,prefixLength);
+			prefix[prefixLength]='\0';
+		
+			textLen = prefixLength;
+			text[textLen]='\0';
+		}
+		
+		
+		//Set the enumeration 
+		Term* trm = _CLNEW Term(term->field(), prefix,false);
+		setEnum(reader->terms(trm));
+		_CLDECDELETE(trm);
   }
 
   FuzzyTermEnum::~FuzzyTermEnum(){
@@ -132,7 +123,7 @@
 		  	(prefixLength==0 || _tcsncmp(termText,prefix,prefixLength)==0 )) {
 
 			const TCHAR* target = termText+prefixLength;
-			int32_t targetLen = termTextLen-prefixLength;
+			size_t targetLen = termTextLen-prefixLength;
 
 		    //Calculate the Levenshtein distance
 			int32_t dist = editDistance(text, target, textLen, targetLen);
@@ -210,10 +201,10 @@
         s_i = s[i - 1];
         for (j = 1; j <= m; j++) {
 			if (s_i != t[j-1]){
-				min3(e[i-1 + (j*eWidth)], e[i + ((j-1)*eWidth)], e[i-1 + ((j-1)*eWidth)]);
+				min3(e[i + (j*eWidth) - 1], e[i + ((j-1)*eWidth)], e[i + ((j-1)*eWidth)-1]);
                 e[i + (j*eWidth)] = __t+1;
 			}else{
-				min3(e[i-1 + (j*eWidth)]+1, e[i + ((j-1)*eWidth)]+1, e[i-1 + ((j-1)*eWidth)]);
+				min3(e[i + (j*eWidth) -1]+1, e[i + ((j-1)*eWidth)]+1, e[i + ((j-1)*eWidth)-1]);
                 e[i + (j*eWidth)] = __t;
 			}
         }
@@ -240,7 +231,7 @@
    * @throws IllegalArgumentException if minimumSimilarity is &gt; 1 or &lt; 0
    * or if prefixLength &lt; 0 or &gt; <code>term.text().length()</code>.
    */
-  FuzzyQuery::FuzzyQuery(Term* term, float_t minimumSimilarity, int32_t prefixLength):
+  FuzzyQuery::FuzzyQuery(Term* term, float_t minimumSimilarity, size_t prefixLength):
 	MultiTermQuery(term)
   {
   //Func - Constructor
@@ -256,9 +247,7 @@
     
 	    this->minimumSimilarity = minimumSimilarity;
     
-		if(prefixLength < 0)
-			_CLTHROWA(CL_ERR_IllegalArgument,"prefixLength < 0");
-		else if(prefixLength >= term->textLength())
+		if(prefixLength >= term->textLength())
 			_CLTHROWA(CL_ERR_IllegalArgument,"prefixLength >= term.textLength()");
 		this->prefixLength = prefixLength;
 
@@ -322,9 +311,10 @@
 	  this->minimumSimilarity = clone.getMinSimilarity();
 	  this->prefixLength = clone.getPrefixLength();
     
-		if(prefixLength < 0)
-			_CLTHROWA(CL_ERR_IllegalArgument,"prefixLength < 0");
-		else if(prefixLength >= clone.getTerm()->textLength())
+		//if(prefixLength < 0)
+		//	_CLTHROWA(CL_ERR_IllegalArgument,"prefixLength < 0");
+		//else 
+		if(prefixLength >= clone.getTerm()->textLength())
 			_CLTHROWA(CL_ERR_IllegalArgument,"prefixLength >= term.textLength()");
 
 	}
@@ -356,7 +346,7 @@
    * of a term that must be identical (not fuzzy) to the query term if the query
    * is to match that term. 
    */
-  int32_t FuzzyQuery::getPrefixLength() const {
+  size_t FuzzyQuery::getPrefixLength() const {
     return prefixLength;
   }
 

Modified: trunk/clucene/src/CLucene/search/FuzzyQuery.h
===================================================================
--- trunk/clucene/src/CLucene/search/FuzzyQuery.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/FuzzyQuery.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_FuzzyQuery_
 #define _lucene_search_FuzzyQuery_
 
@@ -33,7 +24,7 @@
   class FuzzyQuery: public MultiTermQuery {
     private:
 	  float_t minimumSimilarity;
-	  int32_t prefixLength;
+	  size_t prefixLength;
   protected:
 	  FuzzyQuery(const FuzzyQuery& clone);
    public:
@@ -55,11 +46,10 @@
 	* @throws IllegalArgumentException if minimumSimilarity is &gt; 1 or &lt; 0
 	* or if prefixLength &lt; 0 or &gt; <code>term.text().length()</code>.
 	*/
-     FuzzyQuery(CL_NS(index)::Term* term, float_t minimumSimilarity=defaultMinSimilarity, int32_t prefixLength=0);
+     FuzzyQuery(CL_NS(index)::Term* term, float_t minimumSimilarity=defaultMinSimilarity, size_t prefixLength=0);
 	 //Destructor
      ~FuzzyQuery();
 
-	 //Prepares a fuzzy query
      TCHAR* toString(const TCHAR* field) const;
 
 	  //Returns the name "FuzzyQuery"
@@ -81,7 +71,7 @@
 		* of a term that must be identical (not fuzzy) to the query term if the query
 		* is to match that term. 
 		*/
-		int32_t getPrefixLength() const;
+		size_t getPrefixLength() const;
 
   protected:
 	  FilteredTermEnum* getEnum(CL_NS(index)::IndexReader* reader);
@@ -100,9 +90,9 @@
 
 		CL_NS(index)::Term* searchTerm; 
 		TCHAR* text;
-		int32_t textLen;
+		size_t textLen;
 		TCHAR* prefix;
-		int32_t prefixLength;
+		size_t prefixLength;
 		float_t minimumSimilarity;
 		double scale_factor;
 
@@ -131,34 +121,35 @@
 		int32_t editDistance(const TCHAR* s, const TCHAR* t, const int32_t n, const int32_t m) ;
 
     protected:
-      /**
+		/**
 		The termCompare method in FuzzyTermEnum uses Levenshtein distance to 
 		calculate the distance between the given term and the comparing term. 
 		*/
-      bool termCompare(CL_NS(index)::Term* term) ;
-
-	  /** Returns the difference between the distance and the fuzzy threshold
-       *  multiplied by the scale factor
-	   */
-      float_t difference();
-	  
+		bool termCompare(CL_NS(index)::Term* term) ;
+		
+		///Returns the fact if the current term in the enumeration has reached the end
+		bool endEnum();
     public:
-	
-	/**
-	* Empty prefix and minSimilarity of 0.5f are used.
-	* 
-	* @param reader
-	* @param term
-	* @throws IOException
-	* @see #FuzzyTermEnum(IndexReader, Term, float_t, int32_t)
-	*/
-      FuzzyTermEnum(CL_NS(index)::IndexReader* reader, CL_NS(index)::Term* term, float_t minSimilarity=FuzzyQuery::defaultMinSimilarity, int32_t prefixLength=0);
-	  /** Destructor */
-      ~FuzzyTermEnum();
-      //Returns the fact if the current term in the enumeration has reached the end
-      bool endEnum();
-      /** Close the enumeration */
-      void close();
+		
+		/**
+		* Empty prefix and minSimilarity of 0.5f are used.
+		* 
+		* @param reader
+		* @param term
+		* @throws IOException
+		* @see #FuzzyTermEnum(IndexReader, Term, float_t, int32_t)
+		*/
+		FuzzyTermEnum(const CL_NS(index)::IndexReader* reader, CL_NS(index)::Term* term, float_t minSimilarity=FuzzyQuery::defaultMinSimilarity, size_t prefixLength=0);
+		/** Destructor */
+		~FuzzyTermEnum();
+		/** Close the enumeration */
+		void close();
+		
+		/** Returns the difference between the distance and the fuzzy threshold
+		*  multiplied by the scale factor
+		*/
+		float_t difference();
+	  
   };
 CL_NS_END
 #endif

Modified: trunk/clucene/src/CLucene/search/HitQueue.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/HitQueue.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/HitQueue.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "HitQueue.h"
 

Modified: trunk/clucene/src/CLucene/search/HitQueue.h
===================================================================
--- trunk/clucene/src/CLucene/search/HitQueue.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/HitQueue.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_HitQueue_
 #define _lucene_search_HitQueue_
 

Modified: trunk/clucene/src/CLucene/search/Hits.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/Hits.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/Hits.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 
 #include "SearchHeader.h"
@@ -76,12 +67,6 @@
 		return _length;
 	}
 
-	/** Returns the stored fields of the n<sup>th</sup> document in this set.
-	<p>Documents are cached, so that repeated requests for the same element may
-	return the same Document object. 
-    *
-    * @memory Memory belongs to the hits object. Don't delete the return value.
-    */
 	Document& Hits::doc(const int32_t n){
 		HitDoc* hitDoc = getHitDoc(n);
 
@@ -102,7 +87,6 @@
 		return *hitDoc->doc;
 	}
 
-	/** Returns the id for the nth document in this set. */
 	int32_t Hits::id (const int32_t n){
 		return getHitDoc(n)->id;
 	}
@@ -173,7 +157,7 @@
 		numDocs++;
 	}
 
-	void Hits::remove(HitDoc* hitDoc) {	  // remove from cache
+	void Hits::remove(const HitDoc* hitDoc) {	  // remove from cache
 		if (hitDoc->doc == NULL)			  // it's not in the list
 			return;					  // abort
 

Modified: trunk/clucene/src/CLucene/search/IndexSearcher.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/IndexSearcher.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/IndexSearcher.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "IndexSearcher.h"
 
@@ -34,12 +25,12 @@
 CL_NS_DEF(search)
 
 
-	SimpleTopDocsCollector::SimpleTopDocsCollector(const CL_NS(util)::BitSet* bs, HitQueue* hitQueue, int32_t* totalhits,const int32_t ndocs, const float_t minScore):
+	SimpleTopDocsCollector::SimpleTopDocsCollector(const CL_NS(util)::BitSet* bs, HitQueue* hitQueue, int32_t* totalhits, size_t ndocs, const float_t ms):
+		minScore(ms),
 		bits(bs),
 		hq(hitQueue),
 		nDocs(ndocs),
-		totalHits(totalhits),
-		ms(minScore)
+		totalHits(totalhits)
 	{
 	}
 	SimpleTopDocsCollector::~SimpleTopDocsCollector(){
@@ -48,20 +39,20 @@
 		if (score > 0.0f &&			  // ignore zeroed buckets
 			(bits==NULL || bits->get(doc))) {	  // skip docs not in bits
 			totalHits[0]++;
-			if (hq->size() < nDocs || (ms==-1.0f || score >= ms)) {
+			if (hq->size() < nDocs || (minScore==-1.0f || score >= minScore)) {
 				//todo: could use a struct for scoredoc and then
 				//set the value, then call reorder...?
 			   ScoreDoc* sd = _CLNEW ScoreDoc(doc, score);
 				if ( !hq->insert(sd) )	  // update hit queue
 					_CLDELETE(sd);
-				if ( ms != -1.0f )
-					minScore = ((ScoreDoc*)hq->top())->score; // maintain minScore
+				if ( minScore != -1.0f )
+					minScore = hq->top()->score; // maintain minScore
 			}
 		}
 	}
 
 
-	SortedTopDocsCollector::SortedTopDocsCollector(const CL_NS(util)::BitSet* bs, FieldSortedHitQueue* hitQueue, int32_t* totalhits,const int32_t ndocs):
+	SortedTopDocsCollector::SortedTopDocsCollector(const CL_NS(util)::BitSet* bs, FieldSortedHitQueue* hitQueue, int32_t* totalhits,const size_t ndocs):
 		bits(bs),
 		hq(hitQueue),
 		nDocs(ndocs),
@@ -233,14 +224,14 @@
   }
 
   // inherit javadoc
-  TopFieldDocs* IndexSearcher::_search(Query* query, Filter* filter, int32_t nDocs,
+  TopFieldDocs* IndexSearcher::_search(Query* query, Filter* filter, const int32_t nDocs,
          const Sort* sort) {
     Weight* weight = query->weight(this);
     Scorer* scorer = weight->scorer(reader);
     if (scorer == NULL){
 		ScoreDoc** sds = _CL_NEWARRAY(ScoreDoc*,1);
 		sds[0]=NULL;
-		return _CLNEW TopFieldDocs(0, sds, 0, sort->getSort());
+		return _CLNEW TopFieldDocs(0, sds, 0, __CONST_CAST(const SortField**,sort->getSort()) );
 	}
 
     BitSet* bits = filter != NULL ? filter->bits(reader) : NULL;
@@ -270,7 +261,7 @@
 	if ( bits != NULL && filter->shouldDeleteBitSet(bits) )
 	_CLDELETE(bits);
     _CLDELETE_ARRAY(totalHits);
-    return _CLNEW TopFieldDocs(totalHits0, scoreDocs, hqLen, hqFields);
+    return _CLNEW TopFieldDocs(totalHits0, scoreDocs, hqLen, __CONST_CAST(const SortField**,hqFields) );
   }
 
   void IndexSearcher::_search(Query* query, Filter* filter, HitCollector* results){

Modified: trunk/clucene/src/CLucene/search/IndexSearcher.h
===================================================================
--- trunk/clucene/src/CLucene/search/IndexSearcher.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/IndexSearcher.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_IndexSearcher_
 #define _lucene_search_IndexSearcher_
 
@@ -37,11 +28,10 @@
 		float_t minScore;
 		const CL_NS(util)::BitSet* bits;
 		HitQueue* hq;
-		const int32_t nDocs;
+		size_t nDocs;
 		int32_t* totalHits;
-		const float_t ms;
 	public:
-		SimpleTopDocsCollector(const CL_NS(util)::BitSet* bs, HitQueue* hitQueue, int32_t* totalhits,const int32_t ndocs, const float_t minScore=-1.0f);
+		SimpleTopDocsCollector(const CL_NS(util)::BitSet* bs, HitQueue* hitQueue, int32_t* totalhits, size_t ndocs, const float_t minScore=-1.0f);
 		~SimpleTopDocsCollector();
 		void collect(const int32_t doc, const float_t score);
 	};
@@ -50,10 +40,10 @@
 	private:
 		const CL_NS(util)::BitSet* bits;
 		FieldSortedHitQueue* hq;
-		const int32_t nDocs;
+		size_t nDocs;
 		int32_t* totalHits;
 	public:
-		SortedTopDocsCollector(const CL_NS(util)::BitSet* bs, FieldSortedHitQueue* hitQueue, int32_t* totalhits,const int32_t ndocs);
+		SortedTopDocsCollector(const CL_NS(util)::BitSet* bs, FieldSortedHitQueue* hitQueue, int32_t* totalhits, size_t ndocs);
 		~SortedTopDocsCollector();
 		void collect(const int32_t doc, const float_t score);
 	};

Modified: trunk/clucene/src/CLucene/search/MultiSearcher.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/MultiSearcher.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/MultiSearcher.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "MultiSearcher.h"
 
@@ -74,13 +65,13 @@
     return searchables[i]->doc(n - starts[i]);	  // dispatch to searcher
   }
 
-  int32_t MultiSearcher::searcherIndex(int32_t n){
+  int32_t MultiSearcher::searcherIndex(int32_t n) const{
 	 return subSearcher(n);
   }
 
   /** Returns index of the searcher for document <code>n</code> in the array
    * used to construct this searcher. */
-  int32_t MultiSearcher::subSearcher(int32_t n) {
+  int32_t MultiSearcher::subSearcher(int32_t n) const{
     // replace w/ call to Arrays.binarySearch in Java 1.2
     int32_t lo = 0;					  // search starts array
     int32_t hi = searchablesLen - 1;		  // for first element less
@@ -104,7 +95,7 @@
 
   /** Returns the document number of document <code>n</code> within its
    * sub-index. */
-  int32_t MultiSearcher::subDoc(int32_t n) {
+  int32_t MultiSearcher::subDoc(int32_t n)  const{
     return n - starts[subSearcher(n)];
   }
 
@@ -217,7 +208,7 @@
       scoreDocs[j] = hq->pop();
     scoreDocs[hqlen]=NULL;
 
-	SortField** hqFields = hq->getFields();
+	const SortField** hqFields = hq->getFields();
     _CLDELETE(hq);
     return _CLNEW TopFieldDocs (totalHits, scoreDocs, hqlen, hqFields);
   }

Modified: trunk/clucene/src/CLucene/search/MultiSearcher.h
===================================================================
--- trunk/clucene/src/CLucene/search/MultiSearcher.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/MultiSearcher.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_multisearcher
 #define _lucene_search_multisearcher
 
@@ -70,12 +61,12 @@
 
       /** For use by {@link HitCollector} implementations to identify the
        * index of the sub-searcher that a particular hit came from. */
-      int32_t searcherIndex(int32_t n);
-    
-		  int32_t subSearcher(int32_t n);
-	
-		  int32_t subDoc(int32_t n);
+      int32_t searcherIndex(int32_t n) const;
 
+	  int32_t subSearcher(int32_t n) const;
+
+	  int32_t subDoc(int32_t n) const;
+
       int32_t maxDoc() const;
     
       TopDocs* _search(Query* query, Filter* filter, const int32_t nDocs) ;

Modified: trunk/clucene/src/CLucene/search/MultiTermQuery.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/MultiTermQuery.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/MultiTermQuery.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "MultiTermQuery.h"
 

Modified: trunk/clucene/src/CLucene/search/MultiTermQuery.h
===================================================================
--- trunk/clucene/src/CLucene/search/MultiTermQuery.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/MultiTermQuery.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_MultiTermQuery_
 #define _lucene_search_MultiTermQuery_
 

Modified: trunk/clucene/src/CLucene/search/PhrasePositions.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/PhrasePositions.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/PhrasePositions.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "PhrasePositions.h"
 

Modified: trunk/clucene/src/CLucene/search/PhrasePositions.h
===================================================================
--- trunk/clucene/src/CLucene/search/PhrasePositions.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/PhrasePositions.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_PhrasePositions_
 #define _lucene_search_PhrasePositions_
 

Modified: trunk/clucene/src/CLucene/search/PhraseQuery.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/PhraseQuery.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/PhraseQuery.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "PhraseQuery.h"
 
@@ -202,8 +193,8 @@
     TermPositions* p = NULL;
 
 	//Iterate through all terms
-	uint32_t size = _this->terms.size();
-    for (uint32_t i = 0; i < size; i++) {
+	int32_t size = _this->terms.size();
+    for (int32_t i = 0; i < size; i++) {
         //Get the termPostitions for the i-th term
         p = reader->termPositions(_this->terms[i]);
       
@@ -215,7 +206,7 @@
 			}
             _CLDELETE_ARRAY(tps); 
             return NULL;
-            }
+        }
 
         //Store p at i in tps
         tps[i] = p;

Modified: trunk/clucene/src/CLucene/search/PhraseQuery.h
===================================================================
--- trunk/clucene/src/CLucene/search/PhraseQuery.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/PhraseQuery.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_PhraseQuery_
 #define _lucene_search_PhraseQuery_
 
@@ -106,11 +97,11 @@
         void setSlop(const int32_t s) { slop = s; }
         
         //Returns the slop.  See setSlop(). 
-        int32_t getSlop() { return slop; }
+        int32_t getSlop() const { return slop; }
         
         //Adds a term to the end of the query phrase. 
         void add(CL_NS(index)::Term* term);
-			  void add(CL_NS(index)::Term* term, int32_t position);
+		void add(CL_NS(index)::Term* term, int32_t position);
 
 
         
@@ -130,7 +121,6 @@
         //Prints a user-readable version of this query. 
         TCHAR* toString(const TCHAR* f) const;
 
-		void prepare(CL_NS(index)::IndexReader* reader){}
 		Query* clone() const;
 		bool equals(CL_NS(search)::Query *) const;
 		

Modified: trunk/clucene/src/CLucene/search/PhraseQueue.h
===================================================================
--- trunk/clucene/src/CLucene/search/PhraseQueue.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/PhraseQueue.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_PriorityQueue_
 #define _lucene_search_PriorityQueue_
 

Modified: trunk/clucene/src/CLucene/search/PhraseScorer.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/PhraseScorer.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/PhraseScorer.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "PhraseScorer.h"
 

Modified: trunk/clucene/src/CLucene/search/PhraseScorer.h
===================================================================
--- trunk/clucene/src/CLucene/search/PhraseScorer.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/PhraseScorer.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_PhraseScorer_
 #define _lucene_search_PhraseScorer_
 

Modified: trunk/clucene/src/CLucene/search/PrefixQuery.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/PrefixQuery.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/PrefixQuery.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,28 +1,13 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #ifndef NO_PREFIX_QUERY
 #include "PrefixQuery.h"
-/*
-- reader set to NULL in constructor
-- delete query protected in destructor
-- delete query in prepare
 
-
-*/
 CL_NS_USE(index)
 CL_NS_DEF(search)
 

Modified: trunk/clucene/src/CLucene/search/PrefixQuery.h
===================================================================
--- trunk/clucene/src/CLucene/search/PrefixQuery.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/PrefixQuery.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_PrefixQuery
 #define _lucene_search_PrefixQuery
 #if defined(_LUCENE_PRAGMA_ONCE)

Modified: trunk/clucene/src/CLucene/search/QueryFilter.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/QueryFilter.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/QueryFilter.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "QueryFilter.h"
 #include "IndexSearcher.h"
@@ -22,7 +13,7 @@
 CL_NS_USE(index)
 
 
-QueryFilter::QueryFilter( Query* query )
+QueryFilter::QueryFilter( const Query* query )
 {
 	this->query = query->clone();
 }

Modified: trunk/clucene/src/CLucene/search/QueryFilter.h
===================================================================
--- trunk/clucene/src/CLucene/search/QueryFilter.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/QueryFilter.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_QueryFilter_
 #define _lucene_search_QueryFilter_
 
@@ -27,7 +18,6 @@
 {
 private:
 	Query* query;
-	QueryFilter( const QueryFilter& copy );
 
 	class QFHitCollector: public HitCollector{
 		CL_NS(util)::BitSet* bits;
@@ -35,8 +25,11 @@
 		QFHitCollector(CL_NS(util)::BitSet* bits);
 		void collect(const int32_t doc, const float_t score);
     };
+
+protected:
+	QueryFilter( const QueryFilter& copy );
 public:
-	QueryFilter( Query* query );
+	QueryFilter( const Query* query );
 	
 	~QueryFilter();
 	

Modified: trunk/clucene/src/CLucene/search/RangeFilter.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/RangeFilter.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/RangeFilter.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "RangeFilter.h"
 

Modified: trunk/clucene/src/CLucene/search/RangeFilter.h
===================================================================
--- trunk/clucene/src/CLucene/search/RangeFilter.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/RangeFilter.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 
 #ifndef _lucene_search_RangeFilter_
 #define _lucene_search_RangeFilter_
@@ -35,14 +26,15 @@
 	bool   includeLower;
 	bool   includeUpper;
 	
+protected:
 	RangeFilter( const RangeFilter& copy );
 	
 public:
 	RangeFilter( const TCHAR* fieldName, const TCHAR* lowerTerm, const TCHAR* upperTerm, bool includeLower, bool includeUpper );
 	
-	static RangeFilter* RangeFilter::Less( TCHAR* fieldName, TCHAR* upperTerm );
+	static RangeFilter* Less( TCHAR* fieldName, TCHAR* upperTerm );
 	
-	static RangeFilter* RangeFilter::More( TCHAR* fieldName, TCHAR* lowerTerm );
+	static RangeFilter* More( TCHAR* fieldName, TCHAR* lowerTerm );
 	
 	~RangeFilter();
 	

Modified: trunk/clucene/src/CLucene/search/RangeQuery.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/RangeQuery.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/RangeQuery.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #ifndef NO_RANGE_QUERY
 #include "RangeQuery.h"

Modified: trunk/clucene/src/CLucene/search/RangeQuery.h
===================================================================
--- trunk/clucene/src/CLucene/search/RangeQuery.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/RangeQuery.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_RangeQuery_
 #define _lucene_search_RangeQuery_
 #if defined(_LUCENE_PRAGMA_ONCE)

Modified: trunk/clucene/src/CLucene/search/ScoreDoc.h
===================================================================
--- trunk/clucene/src/CLucene/search/ScoreDoc.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/ScoreDoc.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_ScoreDoc_
 #define _lucene_search_ScoreDoc_
 

Modified: trunk/clucene/src/CLucene/search/Scorer.h
===================================================================
--- trunk/clucene/src/CLucene/search/Scorer.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/Scorer.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_Scorer_
 #define _lucene_search_Scorer_
 

Modified: trunk/clucene/src/CLucene/search/SearchHeader.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/SearchHeader.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/SearchHeader.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "SearchHeader.h"
 #include "BooleanQuery.h"
@@ -50,7 +41,6 @@
 }
 Weight* Query::createWeight(Searcher* searcher){
 	_CLTHROWA(CL_ERR_UnsupportedOperation,"UnsupportedOperationException");
-	return NULL;
 }
 
 Query::Query():
@@ -68,7 +58,6 @@
 
 Query* Query::combine(Query** queries){
    _CLTHROWA(CL_ERR_UnsupportedOperation,"UnsupportedOperationException");
-   return NULL;
 }
 Similarity* Query::getSimilarity(Searcher* searcher) {
    return searcher->getSimilarity();

Modified: trunk/clucene/src/CLucene/search/SearchHeader.h
===================================================================
--- trunk/clucene/src/CLucene/search/SearchHeader.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/SearchHeader.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_SearchHeader_
 #define _lucene_search_SearchHeader_
 
@@ -34,7 +25,6 @@
 
 	//predefine classes
 	class Scorer;
-	class Searcher;
 	class Query;
 	class Hits;
 	class Sort;
@@ -105,14 +95,14 @@
    class TopFieldDocs: public TopDocs {
    public:
 	   /// The fields which were used to sort results by.
-	   SortField** fields;
+	   const SortField** fields;
 
 	   /** Creates one of these objects.
 	   * @param totalHits  Total number of hits for the query.
 	   * @param scoreDocs  The top hits for the query.
 	   * @param fields     The sort criteria used to find the top hits.
 	   */
-      TopFieldDocs (int32_t totalHits, ScoreDoc** scoreDocs, int32_t scoreDocsLen, SortField** fields):
+      TopFieldDocs (int32_t totalHits, ScoreDoc** scoreDocs, int32_t scoreDocsLen, const SortField** fields):
          TopDocs (totalHits, scoreDocs, scoreDocsLen)
       {
 	      this->fields = fields;
@@ -153,7 +143,7 @@
       virtual Explanation* explain(CL_NS(index)::IndexReader* reader, int32_t doc) = 0;
 
       virtual TCHAR* toString(){
-         return _T("Weight");
+         return STRDUP_TtoT(_T("Weight"));
       }
    };
 
@@ -193,14 +183,21 @@
 		Hits(Searcher* s, Query* q, Filter* f, const Sort* sort=NULL);
 		~Hits();
 
-		// Returns the total number of hits available in this set. 
+		/** Returns the total number of hits available in this set. */
 		int32_t length() const;
 	    
+		/** Returns the stored fields of the n<sup>th</sup> document in this set.
+		<p>Documents are cached, so that repeated requests for the same element may
+		return the same Document object. 
+		*
+		* @memory Memory belongs to the hits object. Don't delete the return value.
+		*/
 		CL_NS(document)::Document& doc(const int32_t n);
 	      
+		/** Returns the id for the nth document in this set. */
 		int32_t id (const int32_t n);
 	    
-		// Returns the score for the nth document in this set.  
+		/** Returns the score for the nth document in this set. */
 		float_t score(const int32_t n);
 	      
 	private:
@@ -212,7 +209,7 @@
 	    
 		void addToFront(HitDoc* hitDoc);
 	    
-		void remove(HitDoc* hitDoc);
+		void remove(const HitDoc* hitDoc);
 
   };
 
@@ -371,7 +368,7 @@
 		*
 		* <p>This defaults to the current value of {@link Similarity#getDefault()}.
 		*/
-		Similarity* getSimilarity() {
+		Similarity* getSimilarity(){
 			return this->similarity;
 		}
 	};
@@ -400,17 +397,8 @@
 		// query boost factor
 		float_t boost;
 	protected:
-	   
 		Query(const Query& clone);
 	public:
-#ifndef LUCENE_HIDE_INTERNAL
-		/** Expert: Constructs an appropriate Weight implementation for this query.
-		*
-		* <p>Only implemented by primitive queries, which re-write to themselves.
-		* <i>Internal, should be protected</i>
-		*/
-		virtual Weight* createWeight(Searcher* searcher);
-#endif
 		Query();
 		virtual ~Query();
 
@@ -426,6 +414,15 @@
 		*/
 		float_t getBoost() const;
 
+		/** Expert: Constructs an appropriate Weight implementation for this query.
+		*
+		* <p>Only implemented by primitive queries, which re-write to themselves.
+		* <i>Internal, should be protected</i>
+		* 
+		* todo: this should actually be protected...
+		*/
+		virtual Weight* createWeight(Searcher* searcher);
+		
       /** Expert: Constructs an initializes a Weight for a top-level query. */
       Weight* weight(Searcher* searcher);
 

Modified: trunk/clucene/src/CLucene/search/Similarity.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/Similarity.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/Similarity.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "Similarity.h"
 

Modified: trunk/clucene/src/CLucene/search/Similarity.h
===================================================================
--- trunk/clucene/src/CLucene/search/Similarity.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/Similarity.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_Similarity_
 #define _lucene_search_Similarity_
 

Modified: trunk/clucene/src/CLucene/search/SloppyPhraseScorer.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/SloppyPhraseScorer.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/SloppyPhraseScorer.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #ifndef NO_FUZZY_QUERY
 #include "SloppyPhraseScorer.h"

Modified: trunk/clucene/src/CLucene/search/SloppyPhraseScorer.h
===================================================================
--- trunk/clucene/src/CLucene/search/SloppyPhraseScorer.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/SloppyPhraseScorer.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_SloppyPhraseScorer_
 #define _lucene_search_SloppyPhraseScorer_
 #if defined(_LUCENE_PRAGMA_ONCE)

Modified: trunk/clucene/src/CLucene/search/Sort.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/Sort.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/Sort.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "Sort.h"
 #include "Compare.h"
@@ -23,7 +14,7 @@
 
 		
   /** Represents sorting by document score (relevancy). */
-  SortField* SortField::FIELD_SCORE = _CLNEW SortField (NULL, SCORE,false);
+  SortField* SortField::FIELD_SCORE = _CLNEW SortField (NULL, DOCSCORE,false);
 
   /** Represents sorting by document number (index order). */
   SortField* SortField::FIELD_DOC = _CLNEW SortField (NULL, DOC,false);
@@ -127,11 +118,34 @@
   SortField::~SortField(){
 	  CLStringIntern::unintern(field);
   }
+  
+  const TCHAR* SortField::toString() const {
+	CL_NS(util)::StringBuffer buffer;
+    switch (type) {
+      case DOCSCORE: buffer.append(_T("<score>"));
+                  break;
 
+      case DOC: buffer.append(_T("<doc>"));
+                break;
 
+      case CUSTOM: buffer.append (_T("<custom:\""));
+         buffer.append( field );
+         buffer.append( _T("\": "));
+         buffer.append(factory->getName());
+         buffer.append(_T(">"));
+         break;
 
+      default: buffer.append( _T("\""));
+            buffer.append( field );
+            buffer.append( _T("\"") );
+               break;
+    }
 
+    //if (locale != null) buffer.append ("("+locale+")"); todo:
+    if (reverse) buffer.appendChar('!');
 
+    return buffer.toString();
+  }
 
 
 
@@ -140,6 +154,11 @@
 
 
 
+
+
+
+
+
    /** Sorts by computed relevance.  This is the same sort criteria as
 	 * calling {@link Searcher#search(Query) Searcher#search()} without a sort criteria, only with
 	 * slightly more overhead. */
@@ -292,5 +311,11 @@
   }*/
 
 
+	SortComparator::SortComparator(ScoreDocComparator* _this):SortComparatorSource(){
+		this->_this = _this;
+	}
+	SortComparator::~SortComparator(){
+	}
 
+
 CL_NS_END

Modified: trunk/clucene/src/CLucene/search/Sort.h
===================================================================
--- trunk/clucene/src/CLucene/search/Sort.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/Sort.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_Sort_
 #define _lucene_search_Sort_
 
@@ -34,6 +25,8 @@
  *
  */
  class ScoreDocComparator:LUCENE_BASE {
+ protected:
+	 ScoreDocComparator(){}
  public:
 	 virtual ~ScoreDocComparator();
 //    CL_NS(util)::Comparable** cachedValues;
@@ -85,8 +78,10 @@
    virtual ~SortComparatorSource(){
    }
 
-   //return a reference to a string describing the name of the comparator
-   //this is used in the explanation
+   /**
+   * return a reference to a string describing the name of the comparator
+   * this is used in the explanation
+   */
    virtual TCHAR* getName() = 0;
 
    virtual size_t hashCode() = 0;
@@ -120,11 +115,8 @@
 public:
 	ScoreDocComparator* newComparator (CL_NS(index)::IndexReader* reader, TCHAR* fieldname);
   
-	SortComparator(ScoreDocComparator* _this):SortComparatorSource(){
-		this->_this = _this;
-	}
-	virtual ~SortComparator(){
-	}
+	SortComparator(ScoreDocComparator* _this);
+	virtual ~SortComparator();
 
   /**
    * Returns an object which, when sorted according to natural order,
@@ -151,12 +143,24 @@
  *
  */
 class SortField:LUCENE_BASE {
+private:
+  const TCHAR* field;
+  int32_t type;  // defaults to determining type dynamically
+  //Locale* locale;    // defaults to "natural order" (no Locale)
+  bool reverse;  // defaults to natural order
+  SortComparatorSource* factory;
+
+protected:
+  SortField (const SortField& clone);
 public:
    virtual ~SortField();
 
   /** Sort by document score (relevancy).  Sort values are Float and higher
-   * values are at the front. */
-   LUCENE_STATIC_CONSTANT(int32_t, SCORE=0);
+   * values are at the front. 
+   * PORTING: this is the same as SCORE in java, it had to be renamed because
+   * SCORE is a system macro on some platforms (AIX).
+   */
+   LUCENE_STATIC_CONSTANT(int32_t, DOCSCORE=0);
    
   /** Sort by document number (index order).  Sort values are Integer and lower
    * values are at the front. */
@@ -194,16 +198,6 @@
   /** Represents sorting by document number (index order). */
   static SortField* FIELD_DOC;
 
-
-private:
-  const TCHAR* field;
-  int32_t type;  // defaults to determining type dynamically
-  //Locale* locale;    // defaults to "natural order" (no Locale)
-  bool reverse;  // defaults to natural order
-  SortComparatorSource* factory;
-
-  SortField (const SortField& clone);
-public:
   SortField (const TCHAR* field);
   //SortField (const TCHAR* field, bool reverse);
   //todo: we cannot make reverse use default field of =false.
@@ -220,18 +214,14 @@
    * if the sort is by SCORE or DOC.
    * @return Name of field, possibly <code>null</code>.
    */
-  const TCHAR* getField() {
-    return field;
-  }
+  const TCHAR* getField() const { return field; }
   
   SortField* clone() const;
 
   /** Returns the type of contents in the field.
    * @return One of the constants SCORE, DOC, AUTO, STRING, INT or FLOAT.
    */
-  int32_t getType() {
-    return type;
-  }
+  int32_t getType() const { return type; }
 
   /** Returns the Locale by which term values are interpreted.
    * May return <code>null</code> if no Locale was specified.
@@ -244,41 +234,11 @@
   /** Returns whether the sort should be reversed.
    * @return  True if natural order should be reversed.
    */
-  bool getReverse() {
-    return reverse;
-  }
+  bool getReverse() const { return reverse; }
 
-  SortComparatorSource* getFactory() {
-    return factory;
-  }
+  SortComparatorSource* getFactory() { return factory; }
 
-  const TCHAR* toString() const {
-	CL_NS(util)::StringBuffer buffer;
-    switch (type) {
-      case SCORE: buffer.append(_T("<score>"));
-                  break;
-
-      case DOC: buffer.append(_T("<doc>"));
-                break;
-
-      case CUSTOM: buffer.append (_T("<custom:\""));
-         buffer.append( field );
-         buffer.append( _T("\": "));
-         buffer.append(factory->getName());
-         buffer.append(_T(">"));
-         break;
-
-      default: buffer.append( _T("\""));
-            buffer.append( field );
-            buffer.append( _T("\"") );
-               break;
-    }
-
-    //if (locale != null) buffer.append ("("+locale+")"); todo:
-    if (reverse) buffer.appendChar('!');
-
-    return buffer.toString();
-  }
+  const TCHAR* toString() const;
 };
 
 
@@ -383,13 +343,11 @@
 
    const TCHAR* toString() const;
  
-  /**
+   /**
    * Representation of the sort criteria.
    * @return a pointer to the of SortField array used in this sort criteria
    */
-   SortField** getSort() const{
-	   return fields;
-   }
+   SortField** getSort() const{ return fields; }
 };
 
 

Modified: trunk/clucene/src/CLucene/search/TermQuery.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/TermQuery.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/TermQuery.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "TermQuery.h"
 
@@ -109,7 +100,7 @@
 	TCHAR* TermQuery::TermWeight::toString() { 
 		int32_t size=_tcslen(_this->getQueryName()) + 10;
 		TCHAR* tmp = _CL_NEWARRAY(TCHAR, size);//_tcslen(weight())
-		_sntprintf(_T("weight(%s)"),size,_this->getQueryName());
+		_sntprintf(tmp,size,_T("weight(%s)"),_this->getQueryName());
 		return tmp;
 	}
 

Modified: trunk/clucene/src/CLucene/search/TermQuery.h
===================================================================
--- trunk/clucene/src/CLucene/search/TermQuery.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/TermQuery.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_TermQuery_
 #define _lucene_search_TermQuery_
 

Modified: trunk/clucene/src/CLucene/search/TermScorer.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/TermScorer.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/TermScorer.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "TermScorer.h"
 
@@ -24,27 +15,21 @@
 
 	//TermScorer takes TermDocs and delets it when TermScorer is cleaned up
 	TermScorer::TermScorer(Weight* w, CL_NS(index)::TermDocs* td, 
-		Similarity* similarity,uint8_t* _norms):
+			Similarity* similarity,uint8_t* _norms):
 	    Scorer(similarity),
 	    termDocs(td),
 	    norms(_norms),
 	    weight(w),
 	    weightValue(w->getValue()),
+	    _doc(0),
 	    pointer(0),
-	    pointerMax(0),
-	    _doc(0)
+	    pointerMax(0)
 	{
+		memset(docs,0,32*sizeof(int32_t));
+		memset(freqs,0,32*sizeof(int32_t));
+
 		for (int32_t i = 0; i < LUCENE_SCORE_CACHE_SIZE; i++)
 			scoreCache[i] = getSimilarity()->tf(i) * weightValue;
-
-		/*pointerMax = termDocs->read(docs, freqs);	  // fill buffers
-
-		if (pointerMax != 0)
-			doc = docs[0];
-		else {
-			termDocs->close();				  // close stream
-			doc = INT_MAX;			  // set to sentinel value
-		}*/
 	}
 
 	TermScorer::~TermScorer(){

Modified: trunk/clucene/src/CLucene/search/TermScorer.h
===================================================================
--- trunk/clucene/src/CLucene/search/TermScorer.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/TermScorer.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_TermScorer_
 #define _lucene_search_TermScorer_
 

Modified: trunk/clucene/src/CLucene/search/WildcardQuery.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/WildcardQuery.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/WildcardQuery.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #ifndef NO_WILDCARD_QUERY
 #include "WildcardQuery.h"

Modified: trunk/clucene/src/CLucene/search/WildcardQuery.h
===================================================================
--- trunk/clucene/src/CLucene/search/WildcardQuery.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/WildcardQuery.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_WildcardQuery_
 #define _lucene_search_WildcardQuery_
 #if defined(_LUCENE_PRAGMA_ONCE)

Modified: trunk/clucene/src/CLucene/search/WildcardTermEnum.cpp
===================================================================
--- trunk/clucene/src/CLucene/search/WildcardTermEnum.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/WildcardTermEnum.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #ifndef NO_WILDCARD_QUERY
 #include "WildcardTermEnum.h"
@@ -34,10 +25,10 @@
 
     /** Creates new WildcardTermEnum */
     WildcardTermEnum::WildcardTermEnum(IndexReader* reader, Term* term):
-		FilteredTermEnum(),
+	    FilteredTermEnum(),
+		__term(_CL_POINTER(term)),
 		fieldMatch(false),
-		_endEnum(false),
-	    __term(_CL_POINTER(term))
+		_endEnum(false)
     {
        
 		pre = stringDuplicate(term->text());

Modified: trunk/clucene/src/CLucene/search/WildcardTermEnum.h
===================================================================
--- trunk/clucene/src/CLucene/search/WildcardTermEnum.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/search/WildcardTermEnum.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_search_WildcardTermEnum_
 #define _lucene_search_WildcardTermEnum_
 #if defined(_LUCENE_PRAGMA_ONCE)

Modified: trunk/clucene/src/CLucene/store/Directory.h
===================================================================
--- trunk/clucene/src/CLucene/store/Directory.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/Directory.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_store_Directory
 #define _lucene_store_Directory
 
@@ -64,14 +55,23 @@
 		virtual int64_t fileLength(const char* name) const = 0;
 
 		// Returns a stream reading an existing file. 
-		virtual IndexInput* openFile(const char* name) = 0;
-		virtual IndexInput* openFile(const char* name, int32_t bufferSize){ return openFile(name); }
+		virtual IndexInput* openInput(const char* name) = 0;
+		virtual IndexInput* openInput(const char* name, int32_t bufferSize){ 
+			return openInput(name); //todo: bufferSize was ignored!
+		}
 
 		/// Set the modified time of an existing file to now. */
 		virtual void touchFile(const char* name) = 0;
 
 		// Removes an existing file in the directory. 
-		virtual void deleteFile(const char* name, const bool throwError = true) = 0;
+		virtual bool deleteFile(const char* name) = 0;
+		virtual void deleteFile(const char* name, const bool throwError){
+			if ( !deleteFile(name) && throwError ){
+		      char buffer[200];
+		      _snprintf(buffer,200,"couldn't delete %s",name);
+		      _CLTHROWA(CL_ERR_IO, buffer );
+		    }
+		}
 
 		// Renames an existing file in the directory.
 		//	If a file already exists with the new name, then it is replaced.
@@ -80,7 +80,7 @@
 
 		// Creates a new, empty file in the directory with the given name.
 		//	Returns a stream writing this file. 
-		virtual IndexOutput* createFile(const char* name) = 0;
+		virtual IndexOutput* createOutput(const char* name) = 0;
 
 		// Construct a {@link Lock}.
 		// @param name the name of the lock file

Modified: trunk/clucene/src/CLucene/store/FSDirectory.cpp
===================================================================
--- trunk/clucene/src/CLucene/store/FSDirectory.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/FSDirectory.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "FSDirectory.h"
 #include "CLucene/util/Misc.h"
@@ -30,8 +21,8 @@
    */
 	static CL_NS(util)::CLHashMap<const char*,FSDirectory*,CL_NS(util)::Compare::Char> DIRECTORIES(false,false);
 
-	FSDirectory::FSIndexInput::FSIndexInput(const char* path, int32_t bufferSize):
-		BufferedIndexInput(bufferSize)	
+	FSDirectory::FSIndexInput::FSIndexInput(const char* path, int32_t __bufferSize):
+		BufferedIndexInput(__bufferSize)	
     {
 	//Func - Constructor.
 	//       Opens the file named path
@@ -40,7 +31,7 @@
 
 	  CND_PRECONDITION(path != NULL, "path is NULL");
 
-	  handle = _CLNEW SharedHandle;
+	  handle = _CLNEW SharedHandle();
 	  strcpy(handle->path,path);
 
 	  //Open the file
@@ -63,18 +54,26 @@
 	  this->_pos = 0;
   }
 
-  FSDirectory::FSIndexInput::FSIndexInput(const FSIndexInput& clone): BufferedIndexInput(clone){
+  FSDirectory::FSIndexInput::FSIndexInput(const FSIndexInput& other): BufferedIndexInput(other){
   //Func - Constructor
   //       Uses clone for its initialization
   //Pre  - clone is a valide instance of FSIndexInput
   //Post - The instance has been created and initialized by clone
+	if ( other.handle == NULL )
+		_CLTHROWA(CL_ERR_NullPointer, "other handle is null");
 
-	SCOPED_LOCK_MUTEX(clone.handle->THIS_LOCK)
-	handle = _CL_POINTER(clone.handle);
-	_pos = handle->_fpos; //note where we are currently...
+	SCOPED_LOCK_MUTEX(other.handle->THIS_LOCK)
+	handle = _CL_POINTER(other.handle);
+	_pos = other.handle->_fpos; //note where we are currently...
   }
 
-  FSDirectory::FSIndexInput::SharedHandle::~SharedHandle(){
+  FSDirectory::FSIndexInput::SharedHandle::SharedHandle(){
+  	fhandle = 0;
+    _length = 0;
+    _fpos = 0;
+    path[0]=0;
+  }
+  FSDirectory::FSIndexInput::SharedHandle::~SharedHandle() throw(CLuceneError&){
     if ( fhandle >= 0 ){
       if ( _close(fhandle) != 0 )
         _CLTHROWA(CL_ERR_IO, "File IO Close error");
@@ -89,7 +88,7 @@
   //Post - The file for which this instance is responsible has been closed.
   //       The instance has been destroyed
 
-	  close();
+	  FSIndexInput::close();
   }
 
   IndexInput* FSDirectory::FSIndexInput::clone() const
@@ -153,7 +152,7 @@
   FSDirectory::FSIndexOutput::~FSIndexOutput(){
 	if ( fhandle >= 0 ){
 	  try {
-        close();
+        FSIndexOutput::close();
 	  }catch(...){ //todo: only catch IO Err???
 	  }
 	}
@@ -184,14 +183,14 @@
       _CLTHROWA(CL_ERR_IO, "File IO Seek error");
 	}
   }
-  int64_t FSDirectory::FSIndexOutput::Length(){
+  int64_t FSDirectory::FSIndexOutput::length(){
 	  CND_PRECONDITION(fhandle>=0,"file is not open");
 	  return fileSize(fhandle);
   }
 
 
-	char* FSDirectory::LOCK_DIR=NULL;
-	char* FSDirectory::getLockDir(){
+	const char* FSDirectory::LOCK_DIR=NULL;
+	const char* FSDirectory::getLockDir(){
 		#ifdef LUCENE_LOCK_DIR
 		LOCK_DIR = LUCENE_LOCK_DIR	
 		#else	
@@ -218,9 +217,9 @@
    refCount(0),
    useMMap(false)
   {
-    strcpy(directory,path);
+  	_realpath(path,directory);//set a realpath so that if we change directory, we can still function
     
-	char* tmplockdir = getLockDir();
+	const char* tmplockdir = getLockDir();
     if ( tmplockdir == NULL ) {
       strcpy(lockDir,directory);
     } else {
@@ -274,7 +273,7 @@
     closedir(dir);
 
 	char* lockPrefix = getLockPrefix(); // clear old locks
-	int32_t lockPrefixLen = strlen(lockPrefix);
+	size_t lockPrefixLen = strlen(lockPrefix);
 	
     dir = opendir(lockDir);
 	fl = readdir(dir);
@@ -300,12 +299,6 @@
       strcat(buffer,name);
   }
 
-  int32_t FSDirectory::priv_getStat(const char* name, struct fileStat* ret) const{
-    char buffer[CL_MAX_DIR];
-    priv_getFN(buffer,name);
-    return fileStat( buffer, ret );
-  }
-
   FSDirectory::~FSDirectory(){
   }
 
@@ -332,12 +325,12 @@
     }
     closedir(dir);
 
-    int32_t size = names.size();
-    char** list = _CL_NEWARRAY(char*,size+1);
-    for ( int32_t i=0;i<size;i++ )
-      list[i] = names[i];
-    list[size]=NULL;
-    return list;
+    size_t size = names.size();
+    char** ret = _CL_NEWARRAY(char*,size+1);
+    for ( size_t i=0;i<size;i++ )
+      ret[i] = names[i];
+    ret[size]=NULL;
+    return ret;
   }
 
   bool FSDirectory::fileExists(const char* name) const {
@@ -352,16 +345,19 @@
   }
 
   //static
-  FSDirectory* FSDirectory::getDirectory(const char* file, const bool create){
+  FSDirectory* FSDirectory::getDirectory(const char* file, const bool _create){
     FSDirectory* dir = NULL;
 	{
+		if ( !file || !*file )
+			_CLTHROWA(CL_ERR_IO,"Invalid directory");
+
 		SCOPED_LOCK_MUTEX(DIRECTORIES.THIS_LOCK)
 		dir = DIRECTORIES.get(file);
 		if ( dir == NULL  ){
-			dir = _CLNEW FSDirectory(file,create);
+			dir = _CLNEW FSDirectory(file,_create);
 			DIRECTORIES.put( dir->directory, dir);
-		}else if ( create ){
-	    dir->create();
+		}else if ( _create ){
+	    	dir->create();
 		}
 	}
 
@@ -376,7 +372,9 @@
   int64_t FSDirectory::fileModified(const char* name) const {
 	CND_PRECONDITION(directory[0]!=0,"directory is not open");
     struct fileStat buf;
-    if ( priv_getStat(name,&buf) == -1 )
+    char buffer[CL_MAX_DIR];
+    priv_getFN(buffer,name);
+    if (fileStat( buffer, &buf ) == -1 )
       return 0;
     else
       return buf.st_mtime;
@@ -406,14 +404,16 @@
   int64_t FSDirectory::fileLength(const char* name) const {
 	  CND_PRECONDITION(directory[0]!=0,"directory is not open");
     struct fileStat buf;
-    if ( priv_getStat(name, &buf) == -1 )
+    char buffer[CL_MAX_DIR];
+    priv_getFN(buffer,name);
+    if ( fileStat( buffer, &buf ) == -1 )
       return 0;
     else
       return buf.st_size;
   }
 
-  IndexInput* FSDirectory::openFile(const char* name ) {
-  	return openFile(name, LUCENE_STREAM_BUFFER_SIZE);
+  IndexInput* FSDirectory::openInput(const char* name ) {
+  	return openInput(name, LUCENE_STREAM_BUFFER_SIZE);
   }
   
 #ifdef LUCENE_FS_MMAP
@@ -427,7 +427,7 @@
   }
 #endif
 
-  IndexInput* FSDirectory::openFile(const char* name, int32_t bufferSize ){
+  IndexInput* FSDirectory::openInput(const char* name, int32_t bufferSize ){
 	CND_PRECONDITION(directory[0]!=0,"directory is not open")
     char fl[CL_MAX_DIR];
     priv_getFN(fl, name);
@@ -463,37 +463,32 @@
 	char HEX_DIGITS[] =
 	{'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
 
-	char* FSDirectory::getLockPrefix() {
+	char* FSDirectory::getLockPrefix() const{
 		char dirName[CL_MAX_PATH]; // name to be hashed
-		if ( _fullpath(dirName,directory,CL_MAX_PATH) == NULL ){
+		if ( _realpath(directory,dirName) == NULL ){
 			_CLTHROWA(CL_ERR_Runtime,"Invalid directory path");
 		}
-		int dirNameLen = strlen(dirName);
 
 		//to make a compatible name with jlucene, we need to make some changes...
 		if ( dirName[1] == ':' )
 			dirName[0] = (char)_totupper((char)dirName[0]);
 
-		char* md5 = MD5String(dirName);
+		char* smd5 = MD5String(dirName);
 
 		char* ret=_CL_NEWARRAY(char,32+7+1); //32=2*16, 7=strlen("lucene-")
 		strcpy(ret,"lucene-");
-		strcat(ret,md5);
+		strcat(ret,smd5);
 		
-		_CLDELETE_CaARRAY(md5);
+		_CLDELETE_CaARRAY(smd5);
 
 	    return ret; 
   }
 
-  void FSDirectory::deleteFile(const char* name, const bool throwError)  {
+  bool FSDirectory::deleteFile(const char* name)  {
 	CND_PRECONDITION(directory[0]!=0,"directory is not open");
     char fl[CL_MAX_DIR];
     priv_getFN(fl, name);
-	if ( _unlink(fl) == -1 && throwError){
-      char buffer[200];
-      _snprintf(buffer,200,"couldn't delete %s",name);
-      _CLTHROWA(CL_ERR_IO, buffer );
-    }
+	return _unlink(fl) != -1;
   }
 
   void FSDirectory::renameFile(const char* from, const char* to){
@@ -529,7 +524,7 @@
     }
   }
 
-  IndexOutput* FSDirectory::createFile(const char* name) {
+  IndexOutput* FSDirectory::createOutput(const char* name) {
 	CND_PRECONDITION(directory[0]!=0,"directory is not open");
     char fl[CL_MAX_DIR];
     priv_getFN(fl, name);
@@ -554,10 +549,10 @@
 
 
 
-  FSDirectory::FSLock::FSLock ( const char* lockDir, const char* name )
+  FSDirectory::FSLock::FSLock ( const char* _lockDir, const char* name )
   {
-	  this->lockDir = STRDUP_AtoA(lockDir);
-	  strcpy(lockFile,lockDir);
+	  this->lockDir = STRDUP_AtoA(_lockDir);
+	  strcpy(lockFile,_lockDir);
 	  strcat(lockFile,PATH_DELIMITERA);
 	  strcat(lockFile,name);
   }
@@ -565,7 +560,7 @@
     _CLDELETE_LCaARRAY( lockDir );
   }
   TCHAR* FSDirectory::FSLock::toString(){
-	  int lflen = strlen(lockFile);
+	  size_t lflen = strlen(lockFile);
 	  TCHAR* ret = _CL_NEWARRAY(TCHAR,lflen+6);
 	  _tcscpy(ret,_T("Lock@"));
 	  STRCPY_AtoT(ret+5,lockFile,lflen+1);

Modified: trunk/clucene/src/CLucene/store/FSDirectory.h
===================================================================
--- trunk/clucene/src/CLucene/store/FSDirectory.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/FSDirectory.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_store_FSDirectory_
 #define _lucene_store_FSDirectory_
 
@@ -74,7 +65,7 @@
 			int32_t readVInt();
 			void readBytes(uint8_t* b, const int32_t offset, const int32_t len);
 			void close();
-			int64_t getFilePointer();
+			int64_t getFilePointer() const;
 			void seek(const int64_t pos);
 			int64_t length(){ return _length; }
 		};
@@ -94,13 +85,13 @@
 				int64_t _fpos;
     			DEFINE_MUTEX(THIS_LOCK)
     			char path[CL_MAX_DIR]; //todo: this is only used for cloning, better to get information from the fhandle
-				~SharedHandle();
+    			SharedHandle();
+				~SharedHandle() throw(CLuceneError&);
 			};
 			SharedHandle* handle;
 			int64_t _pos;
     	protected:
     		FSIndexInput(const FSIndexInput& clone);
-    		DEFINE_MUTEX(THIS_LOCK)
     	public:
     		FSIndexInput(const char* path, int32_t bufferSize=LUCENE_STREAM_BUFFER_SIZE);
     		~FSIndexInput();
@@ -118,17 +109,19 @@
     	class FSIndexOutput: public IndexOutput {
     	private:
     		int32_t fhandle;
+    	protected:
+    		// output methods: 
+    		void flushBuffer(const uint8_t* b, const int32_t size);
     	public:
     		FSIndexOutput(const char* path);
     		~FSIndexOutput();
 
-    		// output methods: 
-    		void flushBuffer(const uint8_t* b, const int32_t size);
+    		// output methods:
     		void close();
     
     		// Random-access methods 
     		void seek(const int64_t pos);
-    		int64_t Length();
+    		int64_t length();
       };
 #endif //LUCENE_HIDE_INTERNAL
 
@@ -136,19 +129,16 @@
 	protected:
 		FSDirectory(const char* path, const bool createDir);
 	private:
-		char directory[CL_MAX_DIR];
+		char directory[CL_MAX_PATH];
 		int refCount;
 		void create();
 		
-		static char* LOCK_DIR;
-		static char* getLockDir();
+		static const char* LOCK_DIR;
+		static const char* getLockDir();
 		char lockDir[CL_MAX_PATH];
-		char* getLockPrefix();
+		char* getLockPrefix() const;
 
 		void priv_getFN(char* buffer, const char* name) const;
-		int32_t priv_getStat(const char* name, struct fileStat* ret) const;
-		
-
 		bool useMMap;
 	public:
 	  ///Destructor - only call this if you are sure the directory
@@ -194,15 +184,15 @@
 		int64_t fileLength(const char* name) const;
 
 		/// Returns a stream reading an existing file. 
-		IndexInput* openFile(const char* name);
-		IndexInput* openFile(const char* name, int32_t bufferSize);
+		IndexInput* openInput(const char* name);
+		IndexInput* openInput(const char* name, int32_t bufferSize);
 
 #ifdef LUCENE_FS_MMAP
 		IndexInput* openMMapFile(const char* name, int32_t bufferSize=LUCENE_STREAM_BUFFER_SIZE);
 #endif
 
 		/// Removes an existing file in the directory. 
-		void deleteFile(const char* name, const bool throwError=true);
+		bool deleteFile(const char* name);
 
 		/// Renames an existing file in the directory. 
 		void renameFile(const char* from, const char* to);
@@ -212,7 +202,7 @@
 
 		/// Creates a new, empty file in the directory with the given name.
 		///	Returns a stream writing this file. 
-		IndexOutput* createFile(const char* name);
+		IndexOutput* createOutput(const char* name);
 
 		/// Construct a {@link Lock}.
 		/// @param name the name of the lock file
@@ -231,7 +221,7 @@
 	  /** 
 	  * Gets whether the directory is using MMap for inputstreams.
 	  */
-	  bool getUseMMap(){ return useMMap; }
+	  bool getUseMMap() const{ return useMMap; }
 
 	  TCHAR* toString() const;
 

Modified: trunk/clucene/src/CLucene/store/IndexInput.cpp
===================================================================
--- trunk/clucene/src/CLucene/store/IndexInput.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/IndexInput.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,21 +1,11 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+ /*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "IndexInput.h"
-#include "CLucene/util/Arrays.h"
 
 CL_NS_USE(util)
 CL_NS_DEF(store)
@@ -23,7 +13,7 @@
 	IndexInput::IndexInput()
 	{
 	}
-	IndexInput::IndexInput(const IndexInput& clone)
+	IndexInput::IndexInput(const IndexInput& other)
 	{
 	}
 
@@ -47,9 +37,9 @@
   }
 
   int64_t IndexInput::readLong() {
-    int32_t i1 = readInt();
-    int32_t i2 = readInt();
-    return (((int64_t)i1) << 32) | (i2 & 0xFFFFFFFFL);
+    int64_t i1 = readInt();
+    int64_t i2 = readInt();
+    return (i1 << 32) | (i2 & 0xFFFFFFFFL);
   }
 
   int64_t IndexInput::readVLong() {
@@ -79,11 +69,11 @@
     }
   }
 
-   TCHAR* IndexInput::readString(const bool unique){
+   TCHAR* IndexInput::readString(const bool _unique){
     int32_t len = readVInt();
       
-   if ( len == 0){
-      if ( unique )
+    if ( len == 0){
+      if ( _unique ) //todo: does non unique ever occur?
          return stringDuplicate(LUCENE_BLANK_STRING);
       else
          return LUCENE_BLANK_STRING;
@@ -121,28 +111,29 @@
 
 
 
-	BufferedIndexInput::BufferedIndexInput(int32_t _bufferSize):
+BufferedIndexInput::BufferedIndexInput(int32_t _bufferSize):
+		buffer(NULL),
+		bufferSize(_bufferSize),
 		bufferStart(0),
 		bufferLength(0),
-		bufferPosition(0),
-		bufferSize(_bufferSize),
-		buffer(NULL)
+		bufferPosition(0)
   {
   }
 
-  BufferedIndexInput::BufferedIndexInput(const BufferedIndexInput& clone):
-    bufferStart(clone.bufferStart),
-    bufferLength(clone.bufferLength),
-    bufferPosition(clone.bufferPosition),
-	bufferSize(clone.bufferSize),
-    buffer(NULL)
+  BufferedIndexInput::BufferedIndexInput(const BufferedIndexInput& other):
+  	IndexInput(other),
+    buffer(NULL),
+	bufferSize(other.bufferSize),
+    bufferStart(other.bufferStart),
+    bufferLength(other.bufferLength),
+    bufferPosition(other.bufferPosition)
   {
     /* DSR: Does the fact that sometime clone.buffer is not NULL even when
     ** clone.bufferLength is zero indicate memory corruption/leakage?
     **   if ( clone.buffer != NULL) { */
-    if (clone.bufferLength != 0 && clone.buffer != NULL) {
+    if (other.bufferLength != 0 && other.buffer != NULL) {
       buffer = _CL_NEWARRAY(uint8_t,bufferLength);
-	  memcpy(buffer,clone.buffer,bufferLength * sizeof(uint8_t));
+	  memcpy(buffer,other.buffer,bufferLength * sizeof(uint8_t));
     }
   }
 
@@ -161,7 +152,7 @@
     }
   }
 
-  int64_t BufferedIndexInput::getFilePointer() {
+  int64_t BufferedIndexInput::getFilePointer() const{
     return bufferStart + bufferPosition;
   }
 
@@ -178,10 +169,7 @@
     }
   }
   void BufferedIndexInput::close(){
-      if ( buffer != NULL ) {
-      _CLDELETE_ARRAY(buffer);
-      }
-
+	_CLDELETE_ARRAY(buffer);
     bufferLength = 0;
     bufferPosition = 0;
     bufferStart = 0;
@@ -189,7 +177,7 @@
 
 
   BufferedIndexInput::~BufferedIndexInput(){
-    close();
+    BufferedIndexInput::close();
   }
 
   void BufferedIndexInput::refill() {

Modified: trunk/clucene/src/CLucene/store/IndexInput.h
===================================================================
--- trunk/clucene/src/CLucene/store/IndexInput.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/IndexInput.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_store_IndexInput_
 #define _lucene_store_IndexInput_
 
@@ -105,7 +96,7 @@
 		* occur.
 		* @see #seek(long)
 		*/
-		virtual int64_t getFilePointer() =0;
+		virtual int64_t getFilePointer() const =0;
 		
 		/** Sets current position in this file, where the next read will occur.
 		* @see #getFilePointer()
@@ -149,12 +140,12 @@
 		void close();
 		inline uint8_t readByte(){
 			if (bufferPosition >= bufferLength)
-			refill();
+				refill();
 
 			return buffer[bufferPosition++];
 		}
 		void readBytes(uint8_t* b, const int32_t offset, const int32_t len);
-		int64_t getFilePointer();
+		int64_t getFilePointer() const;
 		void seek(const int64_t pos);
 
 	protected:

Modified: trunk/clucene/src/CLucene/store/IndexOutput.cpp
===================================================================
--- trunk/clucene/src/CLucene/store/IndexOutput.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/IndexOutput.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,23 +1,12 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "IndexOutput.h"
 
-#include "CLucene/util/Arrays.h"
-
 CL_NS_USE(util)
 CL_NS_DEF(store)
 
@@ -30,6 +19,8 @@
   }
 
   IndexOutput::~IndexOutput(){
+  	if ( buffer != NULL )
+  		close();
   }
 
   bool IndexOutput::isClosed() const { /* DSR:PROPOSED */
@@ -45,6 +36,7 @@
   }
 
   void IndexOutput::writeByte(const uint8_t b) {
+  	CND_PRECONDITION(buffer!=NULL,"IndexOutput is closed")
     if (bufferPosition >= LUCENE_STREAM_BUFFER_SIZE)
       flush();
     buffer[bufferPosition++] = b;
@@ -116,7 +108,7 @@
   }
 
 
-  int64_t IndexOutput::getFilePointer() {
+  int64_t IndexOutput::getFilePointer() const{
     return bufferStart + bufferPosition;
   }
 

Modified: trunk/clucene/src/CLucene/store/IndexOutput.h
===================================================================
--- trunk/clucene/src/CLucene/store/IndexOutput.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/IndexOutput.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_store_IndexOutput_
 #define _lucene_store_IndexOutput_
 #if defined(_LUCENE_PRAGMA_ONCE)
@@ -97,7 +88,7 @@
 	* occur.
 	* @see #seek(long)
 	*/
-	int64_t getFilePointer();
+	int64_t getFilePointer() const;
 
 	/** Sets current position in this file, where the next write will occur.
 	* @see #getFilePointer()
@@ -105,7 +96,7 @@
 	virtual void seek(const int64_t pos);
 
 	/** The number of bytes in the file. */
-	virtual int64_t Length() = 0;
+	virtual int64_t length() = 0;
 
 	/** Forces any buffered output to be written. */
 	void flush();

Modified: trunk/clucene/src/CLucene/store/InputStream.h
===================================================================
--- trunk/clucene/src/CLucene/store/InputStream.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/InputStream.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_store_InputStream_
 #define _lucene_store_InputStream_
 

Modified: trunk/clucene/src/CLucene/store/Lock.cpp
===================================================================
--- trunk/clucene/src/CLucene/store/Lock.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/Lock.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "Lock.h"
 

Modified: trunk/clucene/src/CLucene/store/Lock.h
===================================================================
--- trunk/clucene/src/CLucene/store/Lock.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/Lock.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_store_Lock_
 #define _lucene_store_Lock_
 

Modified: trunk/clucene/src/CLucene/store/MMapInput.cpp
===================================================================
--- trunk/clucene/src/CLucene/store/MMapInput.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/MMapInput.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #if defined(LUCENE_FS_MMAP)
 
@@ -152,7 +143,7 @@
 	  }
 	  return i;
   }
-  int64_t FSDirectory::MMapIndexInput::getFilePointer(){
+  int64_t FSDirectory::MMapIndexInput::getFilePointer() const{
 	return pos;
   }
   void FSDirectory::MMapIndexInput::seek(const int64_t pos){

Modified: trunk/clucene/src/CLucene/store/OutputStream.h
===================================================================
--- trunk/clucene/src/CLucene/store/OutputStream.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/OutputStream.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_store_IndexOutput_
 #define _lucene_store_IndexOutput_
 #if defined(_LUCENE_PRAGMA_ONCE)

Modified: trunk/clucene/src/CLucene/store/RAMDirectory.cpp
===================================================================
--- trunk/clucene/src/CLucene/store/RAMDirectory.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/RAMDirectory.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "RAMDirectory.h"
 
@@ -36,13 +27,14 @@
 
 
   RAMDirectory::RAMLock::RAMLock(const char* name, RAMDirectory* dir):
-    fname ( STRDUP_AtoA(name) ),
     directory(dir)
   {
+  	fname = STRDUP_AtoA(name);
   }
   RAMDirectory::RAMLock::~RAMLock()
   {
     _CLDELETE_LCaARRAY( fname );
+    directory = NULL;
   }
   TCHAR* RAMDirectory::RAMLock::toString(){
 	  return STRDUP_TtoT(_T("LockFile at RAM"));
@@ -53,7 +45,7 @@
   bool RAMDirectory::RAMLock::obtain(){
     SCOPED_LOCK_MUTEX(directory->files_mutex);
     if (!directory->fileExists(fname)) {
-        IndexOutput* tmp = directory->createFile(fname);
+        IndexOutput* tmp = directory->createOutput(fname);
         tmp->close();
         _CLDELETE(tmp);
 
@@ -68,8 +60,10 @@
 
 
   RAMIndexOutput::~RAMIndexOutput(){
-     if ( deleteFile )
+	if ( deleteFile ){
         _CLDELETE(file);
+	}else
+     	file = NULL;
   }
   RAMIndexOutput::RAMIndexOutput(RAMFile* f):file(f) {
     pointer = 0;
@@ -87,49 +81,43 @@
     flush();
     int64_t end = file->length;
     int64_t pos = 0;
-    int32_t buffer = 0;
+    int32_t p = 0;
     while (pos < end) {
       int32_t length = LUCENE_STREAM_BUFFER_SIZE;
       int64_t nextPos = pos + length;
       if (nextPos > end) {                        // at the last buffer
         length = (int32_t)(end - pos);
       }
-      out->writeBytes((uint8_t*)file->buffers[buffer++], length);
+      out->writeBytes((uint8_t*)file->buffers[p++], length);
       pos = nextPos;
     }
   }
 
   void RAMIndexOutput::reset(){
-	seek(0);
-    file->length = 0;
+	seek(_ILONGLONG(0));
+    file->length = _ILONGLONG(0);
   }
 
   void RAMIndexOutput::flushBuffer(const uint8_t* src, const int32_t len) {
-    uint32_t bufferNumber = pointer/LUCENE_STREAM_BUFFER_SIZE;
-    int32_t bufferOffset = pointer%LUCENE_STREAM_BUFFER_SIZE;
-    int32_t bytesInBuffer = LUCENE_STREAM_BUFFER_SIZE - bufferOffset;
-    int32_t bytesToCopy = bytesInBuffer >= len ? len : bytesInBuffer;
-
+    uint8_t* b = NULL;
+    int32_t bufferPos = 0;
+    while (bufferPos != len) {
+	    uint32_t bufferNumber = pointer/LUCENE_STREAM_BUFFER_SIZE;
+	    int32_t bufferOffset = pointer%LUCENE_STREAM_BUFFER_SIZE;
+	    int32_t bytesInBuffer = LUCENE_STREAM_BUFFER_SIZE - bufferOffset;
+	    int32_t remainInSrcBuffer = len - bufferPos;
+      	int32_t bytesToCopy = bytesInBuffer >= remainInSrcBuffer ? remainInSrcBuffer : bytesInBuffer;
+	
 		if (bufferNumber == file->buffers.size()){
-		  	uint8_t* tmp = _CL_NEWARRAY(uint8_t,LUCENE_STREAM_BUFFER_SIZE);
-	      file->buffers.push_back( tmp );
+		  b = _CL_NEWARRAY(uint8_t, LUCENE_STREAM_BUFFER_SIZE);
+	      file->buffers.push_back( b );
+		}else{
+		  b = file->buffers[bufferNumber];	
 		}
-
-    uint8_t* buffer = file->buffers[bufferNumber];
-	memcpy(buffer+bufferOffset, src,bytesToCopy * sizeof(uint8_t));
-
-    if (bytesToCopy < len) {			  // not all in one buffer
-      int32_t srcOffset = bytesToCopy;
-      bytesToCopy = len - bytesToCopy;		  // remaining bytes
-      bufferNumber++;
-	  if (bufferNumber == file->buffers.size()){
-	    uint8_t* tmp = _CL_NEWARRAY(uint8_t,LUCENE_STREAM_BUFFER_SIZE);
-        file->buffers.push_back(tmp);
-	  }
-      buffer = file->buffers[bufferNumber];
-	  memcpy(buffer,src+srcOffset,bytesToCopy * sizeof(uint8_t));
-    }
-    pointer += len;
+		memcpy(b+bufferOffset, src+bufferPos, bytesToCopy * sizeof(uint8_t));
+		bufferPos += bytesToCopy;
+        pointer += bytesToCopy;
+	}
     if (pointer > file->length)
       file->length = pointer;
 
@@ -145,24 +133,25 @@
     IndexOutput::seek(pos);
     pointer = (int32_t)pos;
   }
-  int64_t RAMIndexOutput::Length() {
+  int64_t RAMIndexOutput::length() {
     return file->length;
   }
 
 
-  RAMIndexInput::RAMIndexInput(RAMFile* f):file(f) {
+  RAMIndexInput::RAMIndexInput(RAMFile* f):
+  	file(f) {
     pointer = 0;
     _length = f->length;
   }
-  RAMIndexInput::RAMIndexInput(const RAMIndexInput& clone):
-    file(clone.file),
-    BufferedIndexInput(clone)
+  RAMIndexInput::RAMIndexInput(const RAMIndexInput& other):
+    BufferedIndexInput(other)
   {
-    pointer = clone.pointer;
-    _length = clone._length;
+  	file = other.file;
+    pointer = other.pointer;
+    _length = other._length;
   }
   RAMIndexInput::~RAMIndexInput(){
-      close();
+      RAMIndexInput::close();
   }
   IndexInput* RAMIndexInput::clone() const
   {
@@ -187,10 +176,9 @@
       ** buffer won't exceed the the capacity of int32_t.  Therefore, the
       ** int64_t->int32_t cast on the next line is safe. */
       int32_t bytesToCopy = bytesInBuffer >= remainder ? static_cast<int32_t>(remainder) : bytesInBuffer;
-      uint8_t* buffer = (uint8_t*)file->buffers[bufferNumber];
+      uint8_t* b = file->buffers[bufferNumber];
+	  memcpy(dest+destOffset,b+bufferOffset,bytesToCopy * sizeof(uint8_t));
 
-	  memcpy(dest+destOffset,buffer+bufferOffset,bytesToCopy * sizeof(uint8_t));
-
       destOffset += bytesToCopy;
       start += bytesToCopy;
       remainder -= bytesToCopy;
@@ -215,16 +203,16 @@
   char** RAMDirectory::list() const{
     SCOPED_LOCK_MUTEX(files_mutex);
     int32_t size = 0;
-    char** list = _CL_NEWARRAY(char*,files.size()+1);
+    char** lst = _CL_NEWARRAY(char*,files.size()+1);
 
 	FileMap::const_iterator itr = files.begin();
     while (itr != files.end()){
-	  list[size] = lucenestrdup((char*)itr->first CL_FILELINE);
-      itr++;
+	  lst[size] = STRDUP_AtoA(itr->first);
+      ++itr;
       size++;
     }
-    list[size]=NULL;
-    return list;
+    lst[size]=NULL;
+    return lst;
   }
 
   RAMDirectory::RAMDirectory():
@@ -238,22 +226,25 @@
 
   void RAMDirectory::_copyFromDir(Directory* dir, bool closeDir)
   {
-    char** files = dir->list();
+    char** fls = dir->list();
     int i=0;
-    while ( files[i] != NULL ){
+    uint8_t* buf = _CL_NEWARRAY(uint8_t, LUCENE_STREAM_BUFFER_SIZE);
+    
+    while ( fls[i] != NULL ){
       // make place on ram disk
-      IndexOutput* os = createFile(files[i]);
+      IndexOutput* os = createOutput(fls[i]);
       // read current file
-      IndexInput* is = dir->openFile(files[i]);
+      IndexInput* is = dir->openInput(fls[i]);
       // and copy to ram disk
-      //todo: this could be a problem when copying from big indexes... but what's 
-      //the chance that someone's going to copy more than 2gb from disk into RAM...
-      //actually, it is possible...
-      int32_t len = is->length();
-      uint8_t* buf = _CL_NEWARRAY(uint8_t,len);
-      is->readBytes(buf, 0, len);
-      os->writeBytes(buf, len);
-      _CLDELETE_ARRAY(buf);
+      //todo: this could be a problem when copying from big indexes... 
+      int64_t len = is->length();
+      int64_t readCount = 0;
+      while (readCount < len) {
+		int32_t toRead = (int32_t)(readCount + LUCENE_STREAM_BUFFER_SIZE > len ? len - readCount : LUCENE_STREAM_BUFFER_SIZE);
+	    is->readBytes(buf, 0, toRead);
+	    os->writeBytes(buf, toRead);
+        readCount += toRead;
+      }
 
       // graceful cleanup
       is->close();
@@ -261,10 +252,11 @@
       os->close();
       _CLDELETE(os);
 
-      _CLDELETE_LCaARRAY(files[i]);
+      _CLDELETE_LCaARRAY(fls[i]);
       i++;
     }
-    _CLDELETE_ARRAY(files);
+    _CLDELETE_ARRAY(buf);
+    _CLDELETE_ARRAY(fls);
 
     if (closeDir)
        dir->close();
@@ -304,7 +296,7 @@
   }
 
 
-  IndexInput* RAMDirectory::openFile(const char* name) {
+  IndexInput* RAMDirectory::openInput(const char* name) {
     SCOPED_LOCK_MUTEX(files_mutex);
     RAMFile* file = files.get(name);
     if (file == NULL) { /* DSR:PROPOSED: Better error checking. */
@@ -318,9 +310,10 @@
       files.clear();
   }
 
-  void RAMDirectory::deleteFile(const char* name, const bool throwError) {
+  bool RAMDirectory::deleteFile(const char* name) {
     SCOPED_LOCK_MUTEX(files_mutex);
     files.remove(name);
+    return true;
   }
 
   void RAMDirectory::renameFile(const char* from, const char* to) {
@@ -335,7 +328,13 @@
     if (files.exists(to)) {
       files.remove(to);
     }
-		RAMFile* file = itr->second;
+	if ( itr == files.end() ){
+		char tmp[1024];
+		_snprintf(tmp,1024,"cannot rename %s, file does not exist");
+		_CLTHROWT(CL_ERR_IO,tmp);
+	}
+	CND_PRECONDITION(itr != files.end(), "itr==files.end()")
+	RAMFile* file = itr->second;
     files.removeitr(itr,false,true);
     files.put(STRDUP_AtoA(to), file);
   }
@@ -359,7 +358,7 @@
     file->lastModified = ts2;
   }
 
-  IndexOutput* RAMDirectory::createFile(const char* name) {
+  IndexOutput* RAMDirectory::createOutput(const char* name) {
     /* Check the $files VoidMap to see if there was a previous file named
     ** $name.  If so, delete the old RAMFile object, but reuse the existing
     ** char buffer ($n) that holds the filename.  If not, duplicate the

Modified: trunk/clucene/src/CLucene/store/RAMDirectory.h
===================================================================
--- trunk/clucene/src/CLucene/store/RAMDirectory.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/RAMDirectory.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_store_RAMDirectory_
 #define _lucene_store_RAMDirectory_
 
@@ -46,21 +37,20 @@
 		RAMFile* file;
 		int32_t pointer;
 		bool deleteFile;
+		
+		// output methods: 
+		void flushBuffer(const uint8_t* src, const int32_t len);
 	public:
-
 		RAMIndexOutput(RAMFile* f);
 		RAMIndexOutput();
   	    /** Construct an empty output buffer. */
 		virtual ~RAMIndexOutput();
 
-		// output methods: 
-		void flushBuffer(const uint8_t* src, const int32_t len);
-
 		virtual void close();
 
 		// Random-at methods
 		virtual void seek(const int64_t pos);
-		int64_t Length();
+		int64_t length();
         /** Resets this to an empty buffer. */
         void reset();
   	    /** Copy the current contents of this buffer to the named output. */
@@ -71,14 +61,10 @@
 	private:
 		RAMFile* file;
 		int32_t pointer;
-		RAMIndexInput(const RAMIndexInput& clone);
 		int64_t _length;
-	public:
-		RAMIndexInput(RAMFile* f);
-		~RAMIndexInput();
-		IndexInput* clone() const;
-
+	protected:
 		/** IndexInput methods */
+		RAMIndexInput(const RAMIndexInput& clone);
 		/** DSR:CL_BUG:
 		** The CLucene 0.8.11 implementation of readInternal caused invalid memory
 		** ops if fewer than the requested number of bytes were available and the
@@ -91,12 +77,15 @@
 		** it only segfaulted occasionally.
 		** I replaced the dysfunctional CLucene 0.8.11 impl with a fixed version. */
 		void readInternal(uint8_t *dest, const int32_t idestOffset, const int32_t len);
-
-		void close();
-
+		
         /** Random-at methods */
 		void seekInternal(const int64_t pos);
+	public:
+		RAMIndexInput(RAMFile* f);
+		~RAMIndexInput();
+		IndexInput* clone() const;
 
+		void close();
 		int64_t length();
 	};
 
@@ -109,7 +98,7 @@
 		class RAMLock: public LuceneLock{
 		private:
 			RAMDirectory* directory;
-			const char* fname;
+			char* fname;
 		public:
 			RAMLock(const char* name, RAMDirectory* dir);
 			virtual ~RAMLock();
@@ -138,7 +127,7 @@
 	  FileMap files; // unlike the java Hashtable, FileMap is not synchronized, and all access must be protected by a lock
 	public:
 #ifndef _CL_DISABLE_MULTITHREADING //do this so that the mutable keyword still works without mt enabled
-	    mutable DEFINE_MUTEX(files_mutex); // mutable: const methods must also be able to synchronize properly
+	    mutable DEFINE_MUTEX(files_mutex) // mutable: const methods must also be able to synchronize properly
 #endif
 
 		/// Returns a null terminated array of strings, one for each file in the directory. 
@@ -173,21 +162,21 @@
 		virtual void renameFile(const char* from, const char* to);
 
 		/// Removes an existing file in the directory. 
-		virtual void deleteFile(const char* name, const bool throwError = true);
+		virtual bool deleteFile(const char* name);
 
 		/** Set the modified time of an existing file to now. */
 		void touchFile(const char* name);
 
 		/// Creates a new, empty file in the directory with the given name.
 		///	Returns a stream writing this file. 
-		virtual IndexOutput* createFile(const char* name);
+		virtual IndexOutput* createOutput(const char* name);
 
 		/// Construct a {@link Lock}.
 		/// @param name the name of the lock file
 		LuceneLock* makeLock(const char* name);
 
 		/// Returns a stream reading an existing file. 
-		IndexInput* openFile(const char* name);
+		IndexInput* openInput(const char* name);
 
 		virtual void close();
 		

Modified: trunk/clucene/src/CLucene/store/TransactionalRAMDirectory.cpp
===================================================================
--- trunk/clucene/src/CLucene/store/TransactionalRAMDirectory.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/TransactionalRAMDirectory.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,21 +1,14 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
+#include "CLucene/StdHeader.h"
 #include "TransactionalRAMDirectory.h"
 
 CL_NS_DEF(store)
+CL_NS_USE(util)
 
   TransactionalRAMDirectory::TransactionalRAMDirectory():
     RAMDirectory(),
@@ -60,7 +53,7 @@
     filesToRestoreOnAbort.remove(name, true, true);
     files.put(origName, origFile);
   }
-  bool TransactionalRAMDirectory::transIsOpen() {
+  bool TransactionalRAMDirectory::transIsOpen() const {
     return transOpen;
   }
 
@@ -109,7 +102,7 @@
       )
     {
       const char* name = itrDel->first;
-      const int32_t nameLength = strlen(name);
+      size_t nameLength = strlen(name);
 
       // Special exception:
       // Refrain from deleting a lock's flag file, as that would interfere with
@@ -125,8 +118,8 @@
     // Now that any new-since-trans-start files with the same names as
     // already-present-at-trans-start files are out of the way, restore each
     // file in filesToRestoreOnAbort.
-	CL_NS(util)::AStringArrayConst removeTheseWithoutDeletingMem;
-    for (FileMap::const_iterator itr = filesToRestoreOnAbort.begin();
+	AStringArrayConst removeTheseWithoutDeletingMem;
+    for (TransFileMap::const_iterator itr = filesToRestoreOnAbort.begin();
          itr != filesToRestoreOnAbort.end();
          ++itr
       )
@@ -140,8 +133,7 @@
       removeTheseWithoutDeletingMem.push_back(name);
     }
 
-	CL_NS(util)::AStringArrayConst::iterator itrRem;
-    for (itrRem = removeTheseWithoutDeletingMem.begin();
+    for (AStringArrayConst::iterator itrRem = removeTheseWithoutDeletingMem.begin();
          itrRem != removeTheseWithoutDeletingMem.end();
          ++itrRem
       )
@@ -153,11 +145,9 @@
     transResolved();
   }
 
-  void TransactionalRAMDirectory::deleteFile(const char* name, const bool throwError) {
+  bool TransactionalRAMDirectory::deleteFile(const char* name) {
     if (!transOpen) {
-
-      RAMDirectory::deleteFile(name, throwError);
-      return;
+      return RAMDirectory::deleteFile(name);
     }
 
     bool wasOriginalAndWasArchived = archiveOrigFileIfNecessary(name);
@@ -167,8 +157,9 @@
       // erase its record in filesToRemoveOnAbort if it was listed there.
       filesToRemoveOnAbort.remove(name);
 
-      RAMDirectory::deleteFile(name, throwError);
+      return RAMDirectory::deleteFile(name);
     }
+    return true;
   }
 
   void TransactionalRAMDirectory::renameFile(const char* from, const char* to) {
@@ -192,14 +183,14 @@
     RAMDirectory::renameFile(from, to);
   }
 
-  IndexOutput* TransactionalRAMDirectory::createFile(const char* name) {
+  IndexOutput* TransactionalRAMDirectory::createOutput(const char* name) {
     if (!transOpen) {
-      return RAMDirectory::createFile(name);
+      return RAMDirectory::createOutput(name);
     }
 
     bool wasOriginalAndWasArchived = archiveOrigFileIfNecessary(name);
     try {
-      IndexOutput* ret = RAMDirectory::createFile(name);
+      IndexOutput* ret = RAMDirectory::createOutput(name);
       // Importantly, we store a pointer to the filename memory managed by
       // files, rather than that passed in by the client (name).  We don't make
       // an additional copy of the filename's memory because the transactional

Modified: trunk/clucene/src/CLucene/store/TransactionalRAMDirectory.h
===================================================================
--- trunk/clucene/src/CLucene/store/TransactionalRAMDirectory.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/store/TransactionalRAMDirectory.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,19 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "CLucene/StdHeader.h"
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_store_TransactionalRAMDirectory_
 #define _lucene_store_TransactionalRAMDirectory_
 
@@ -40,8 +30,8 @@
 	typedef CL_NS(util)::CLSet<const char*, void*, CL_NS(util)::Compare::Char> FilenameSet;
     FilenameSet filesToRemoveOnAbort;
 
-	typedef CL_NS(util)::CLSet<const char*, RAMFile*, CL_NS(util)::Compare::Char,CL_NS(util)::Deletor::acArray,CL_NS(util)::Deletor::Object<RAMFile> > FileMap;
-    FileMap filesToRestoreOnAbort;
+	typedef CL_NS(util)::CLSet<const char*, RAMFile*, CL_NS(util)::Compare::Char,CL_NS(util)::Deletor::acArray,CL_NS(util)::Deletor::Object<RAMFile> > TransFileMap;
+    TransFileMap filesToRestoreOnAbort;
 
     bool transOpen;
 
@@ -53,15 +43,15 @@
     TransactionalRAMDirectory();
     virtual ~TransactionalRAMDirectory();
 
-    bool transIsOpen();
+    bool transIsOpen() const;
     void transStart();
     void transCommit();
     void transAbort();
 
     // Constrained operations:
-    void deleteFile(const char* name, const bool throwError = true);
+    bool deleteFile(const char* name);
     void renameFile(const char* from, const char* to);
-    IndexOutput* createFile(const char* name);
+    IndexOutput* createOutput(const char* name);
 
     void close();
   };

Modified: trunk/clucene/src/CLucene/util/Arrays.h
===================================================================
--- trunk/clucene/src/CLucene/util/Arrays.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/Arrays.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_util_Arrays_
 #define _lucene_util_Arrays_
 

Modified: trunk/clucene/src/CLucene/util/BitSet.h
===================================================================
--- trunk/clucene/src/CLucene/util/BitSet.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/BitSet.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_util_BitSet_
 #define _lucene_util_BitSet_
 
@@ -20,62 +11,42 @@
 # pragma once
 #endif
 
+#include "CLucene/store/Directory.h"
 
 CL_NS_DEF(util)
-  class BitSet:LUCENE_BASE {
-	typedef unsigned long wordType;	// base type for a storage word
-	int32_t bitsperword; // bits in each word
+class BitSet:LUCENE_BASE {
+	int32_t _size;
+	int32_t _count;
+	uint8_t *bits;
+	
+protected:
+	BitSet( const BitSet& copy );
 
-    int32_t _size;
-	BitSet::wordType *bits;
-		
-	BitSet( const BitSet& copy ) :
-		bitsperword( copy.bitsperword ),
-		_size( copy._size )
-	{
-		int32_t nwords = _size == 0 ? 0 : (_size - 1) / bitsperword;
-		bits = _CL_NEWARRAY(BitSet::wordType, nwords+1);
-		memcpy( bits, copy.bits, sizeof(BitSet::wordType)*(nwords+1) );
+public:
+	///Create a bitset with the specified size
+	BitSet ( int32_t size );
+	BitSet(CL_NS(store)::Directory* d, const char* name);
+	void write(CL_NS(store)::Directory* d, const char* name);
+	
+	///Destructor for the bit set
+	~BitSet();
+	
+	///get the value of the specified bit
+	inline bool get(const int32_t bit) const{
+		return (bits[bit >> 3] & (1 << (bit & 7))) != 0;
 	}
-
-  public:
-    ///Create a bitset with the specified size
-    BitSet ( int32_t size ):
-      _size(size)
-    {
-		bitsperword = sizeof(char) * sizeof (BitSet::wordType);
-    	int32_t nwords = size == 0 ? 0 : (size - 1) / bitsperword;
-		bits = _CL_NEWARRAY(BitSet::wordType,nwords+1);
-		memset(bits,0,sizeof(BitSet::wordType) * nwords+1);
-    }
-    ///Destructor for the bit set
-    ~BitSet(){
-		_CLDELETE_ARRAY(bits);
-    }
-    ///get the value of the specified bit
-    inline bool get(const int32_t bit) const{
-        if ( bit < 0 || bit > _size-1 )
-          _CLTHROWA(CL_ERR_IllegalArgument, "bit out of range" );
-
-		return ((bits[bit / bitsperword] & ((BitSet::wordType)1 << bit % bitsperword)) != 0);
-    }
-    ///set the value of the specified bit
-    void set(const int32_t bit, bool val=true){
-		if ( bit < 0 || bit >= _size )
-			_CLTHROWA(CL_ERR_IllegalArgument, "bit out of range" );
-
-		if (val)
-			bits[bit / bitsperword] |= (BitSet::wordType)1 << bit % bitsperword;
-		else
-			bits[bit / bitsperword] &= ~((BitSet::wordType)1 << bit % bitsperword);
-    }
-    ///returns the size of the bitset
-    int32_t size() const {
-      return _size;
-    }
-    BitSet *clone() const {
-		return _CLNEW BitSet( *this );
-	}
-  };
+	
+	///set the value of the specified bit
+	void set(const int32_t bit, bool val=true);
+	
+	///returns the size of the bitset
+	int32_t size() const;
+	
+	/// Returns the total number of one bits in this BitSet.  This is efficiently
+	///	computed and cached, so that, if the BitSet is not changed, no
+	///	recomputation is done for repeated calls. 
+	int32_t count();
+	BitSet *clone() const;
+};
 CL_NS_END
 #endif

Modified: trunk/clucene/src/CLucene/util/Equators.cpp
===================================================================
--- trunk/clucene/src/CLucene/util/Equators.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/Equators.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "Equators.h"
 CL_NS_DEF(util)
@@ -43,7 +34,7 @@
 // Comparors
 ////////////////////////////////////////////////////////////////////////////////
 
-int32_t Compare::Int32::getValue(){ return value; }
+int32_t Compare::Int32::getValue() const{ return value; }
 Compare::Int32::Int32(int32_t val){
 	value = val;
 }
@@ -70,7 +61,7 @@
 }
 
 
-float_t Compare::Float::getValue(){
+float_t Compare::Float::getValue() const{
 	return value;
 }
 Compare::Float::Float(float_t val){
@@ -111,7 +102,7 @@
 }
 #endif
 
-const TCHAR* Compare::TChar::getValue(){ return s; }
+const TCHAR* Compare::TChar::getValue() const{ return s; }
 Compare::TChar::TChar(){
 	s=NULL;
 }

Modified: trunk/clucene/src/CLucene/util/Equators.h
===================================================================
--- trunk/clucene/src/CLucene/util/Equators.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/Equators.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_util_Equators_
 #define _lucene_util_Equators_
 
@@ -94,9 +85,9 @@
 	};
 
 	class Int32:public _base, public Comparable{
-	int32_t value;
+		int32_t value;
 	public:
-		int32_t getValue();
+		int32_t getValue() const;
 		Int32(int32_t val);
 		Int32();
 		int32_t compareTo(void* o);
@@ -108,7 +99,7 @@
 	class Float:public Comparable{
 		float_t value;
 	public:
-		float_t getValue();
+		float_t getValue() const;
 		Float(float_t val);
 		int32_t compareTo(void* o);
 	};
@@ -133,7 +124,7 @@
 	class TChar: public _base, public Comparable{
 	  const TCHAR* s;
 	public:
-		const TCHAR* getValue();
+		const TCHAR* getValue() const;
 
 		TChar();
 		TChar(const TCHAR* str);

Modified: trunk/clucene/src/CLucene/util/FastCharStream.cpp
===================================================================
--- trunk/clucene/src/CLucene/util/FastCharStream.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/FastCharStream.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "FastCharStream.h"
 
@@ -20,22 +11,23 @@
 
 CL_NS_DEF(util)
 
-const int32_t FastCharStream::maxRewindSize = 8;
+const int32_t FastCharStream::maxRewindSize = LUCENE_MAX_WORD_LEN*2;
 
   FastCharStream::FastCharStream(Reader* reader):
-	input(reader),
+    pos(0),
+    rewindPos(0),
+	resetPos(0),
 	col(1),
-	line(1)
+	line(1),
+	input(reader)
   {
-    pos = 0;
-    rewindPos = 0;
     input->mark(maxRewindSize);
   }
   void FastCharStream::readChar(TCHAR &c) {
 	try{
-		int r = input->read();
+		int32_t r = input->read();
 		if ( r == -1 )
-			input = 0;
+			input = NULL;
 		c = r;
 	}catch(CLuceneError& err){
 		if ( err.number() == CL_ERR_IO )
@@ -53,17 +45,19 @@
     // this is rather inefficient
     // implementing the functions from the java version of
     // charstream will be much more efficient.
-    if (++pos > maxRewindSize && rewindPos == 0) {
+	++pos;
+    if ( pos > resetPos + maxRewindSize && rewindPos == 0) {
         // move the marker one position (~expensive)
-        input->reset();
-        input->skip(1);
+        resetPos = pos-(maxRewindSize/2);
+		if ( resetPos != input->reset(resetPos) )
+			_CLTHROWA(CL_ERR_IO,"Unexpected reset() result");
         input->mark(maxRewindSize);
-        input->skip(maxRewindSize - 1);
+        input->skip((maxRewindSize/2) - 1);
     }
     TCHAR ch;
     readChar(ch);
 
-    if (input == 0) { // eof
+    if (input == NULL) { // eof
         return -1;
     }
     if (rewindPos == 0) {
@@ -86,12 +80,8 @@
       _CLTHROWA(CL_ERR_IO,"error : No character can be UnGet");
     }
     rewindPos++;
-    input->reset();
-    if (pos > maxRewindSize) {
-    	input->skip(maxRewindSize - 1);
-    } else {
-        input->skip(pos - 1);
-    }
+
+	input->reset(pos-1);
     pos--;
   }
 
@@ -101,15 +91,15 @@
     return c;
   }
 
-  bool FastCharStream::Eos() {
+  bool FastCharStream::Eos() const {
 	return input==NULL;
   }
 
-  int32_t FastCharStream::Column() {
+  int32_t FastCharStream::Column() const {
 	return col;
   }
 
-  int32_t FastCharStream::Line() {
+  int32_t FastCharStream::Line() const {
 	return line;
   }
 CL_NS_END

Modified: trunk/clucene/src/CLucene/util/FastCharStream.h
===================================================================
--- trunk/clucene/src/CLucene/util/FastCharStream.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/FastCharStream.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_util_FastCharStream_
 #define _lucene_util_FastCharStream_
 
@@ -30,6 +21,7 @@
 		static const int32_t maxRewindSize;
 		int32_t pos;
 		int32_t rewindPos;
+		int64_t resetPos;
 		int32_t col;
 		int32_t line;
 		// read character from stream return false on error
@@ -50,13 +42,13 @@
 		
 		
 		/// Returns <b>True</b> if the end of stream was reached.
-		bool Eos();
+		bool Eos() const;
 
 		/// Gets the current column.
-		int32_t Column();
+		int32_t Column() const;
 
 		/// Gets the current line.
-		int32_t Line();
+		int32_t Line() const;
 	};
 CL_NS_END
 #endif

Modified: trunk/clucene/src/CLucene/util/MD5Digester.cpp
===================================================================
--- trunk/clucene/src/CLucene/util/MD5Digester.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/MD5Digester.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -32,6 +32,14 @@
 // These notices must be retained in any copies of any part of this
 // documentation and/or software.
 /////////////////////////////////////////////////////////////////////////
+
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
+
 #include "CLucene/StdHeader.h"
 #include "MD5Digester.h"
 CL_NS_DEF(util)
@@ -174,7 +182,8 @@
 		i = 0;
 
   // Buffer remaining input
-  memcpy( &m_Buffer[index], &chInput[i], nInputLen-i );
+  if (nInputLen > i)
+          memcpy( &m_Buffer[index], &chInput[i], nInputLen-i );
 }
 
 // md5::Finalize

Modified: trunk/clucene/src/CLucene/util/MD5Digester.h
===================================================================
--- trunk/clucene/src/CLucene/util/MD5Digester.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/MD5Digester.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -33,24 +33,13 @@
 // documentation and/or software.
 /////////////////////////////////////////////////////////////////////////
 
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 
-/* Copyright 2003-2006 The Apache Software Foundation or its licensors, as
- * applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
 #ifndef _lucene_util_MD5Digester_H
 #define _lucene_util_MD5Digester_H
 

Modified: trunk/clucene/src/CLucene/util/Misc.cpp
===================================================================
--- trunk/clucene/src/CLucene/util/Misc.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/Misc.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,22 +1,13 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "Misc.h"
 
-#if _CL_TIME_WITH_SYS_TIME
+#ifdef _CL_TIME_WITH_SYS_TIME
 # include <sys/time.h>
 # include <time.h>
 #else
@@ -31,9 +22,6 @@
 # include <sys/timeb.h>
 #endif
 
-#include "CLucene/util/StringIntern.h"
-#include "StringBuffer.h"
-
 CL_NS_DEF(util)
 
 size_t Misc::ahashCode(const char* str){
@@ -83,12 +71,12 @@
 void Misc::_cpywideToChar(const wchar_t* s, char* d, size_t len){
     size_t sLen = wcslen(s);
     for ( uint32_t i=0;i<len&&i<sLen+1;i++ )
-        d[i] = ((uint32_t)s[i]>0x80?LUCENE_OOR_CHAR:(char)s[i]);
+        d[i] = LUCENE_OOR_CHAR(s[i]);
 }
 void Misc::_cpycharToWide(const char* s, wchar_t* d, size_t len){
     size_t sLen = strlen(s);
     for ( uint32_t i=0;i<len&&i<sLen+1;i++ )
-      d[i] = (TCHAR)s[i];
+      d[i] = s[i];
 }
 #endif
 

Modified: trunk/clucene/src/CLucene/util/Misc.h
===================================================================
--- trunk/clucene/src/CLucene/util/Misc.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/Misc.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_util_Misc_H
 #define _lucene_util_Misc_H
 

Modified: trunk/clucene/src/CLucene/util/PriorityQueue.h
===================================================================
--- trunk/clucene/src/CLucene/util/PriorityQueue.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/PriorityQueue.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_util_PriorityQueue_
 #define _lucene_util_PriorityQueue_
 

Modified: trunk/clucene/src/CLucene/util/Reader.cpp
===================================================================
--- trunk/clucene/src/CLucene/util/Reader.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/Reader.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "Reader.h"
 
@@ -26,11 +17,169 @@
   Reader(NULL,true){
 	  reader = new jstreams::StringReader<TCHAR>(value,length);
 }
-StringReader::StringReader ( TCHAR* value, const int32_t length, bool copyData ):
+StringReader::StringReader ( const TCHAR* value, const int32_t length, bool copyData ):
   Reader(NULL,true){
 	  reader = new jstreams::StringReader<TCHAR>(value,length, copyData);
 }
 StringReader::~StringReader(){
 }
 
+
+FileReader::FileReader ( const char* path, const char* enc,
+						 const int32_t cachelen, const int32_t /*cachebuff*/ ):
+	Reader(NULL, true)
+{
+	this->input = new jstreams::FileInputStream(path, cachelen);
+	this->reader = new SimpleInputStreamReader(this->input,enc); //(this is a jstream object)
+}
+
+FileReader::~FileReader (){
+    if (input) 
+		delete input;
+}
+int32_t FileReader::read(const TCHAR*& start, int32_t _min, int32_t _max) {
+    return reader->read(start, _min, _max);
+}
+int64_t FileReader::mark(int32_t readlimit) {
+    return reader->mark(readlimit);
+}
+int64_t FileReader::reset(int64_t newpos) {
+    return reader->reset(newpos);
+}
+
+
+
+SimpleInputStreamReader::SimpleInputStreamReader(jstreams::StreamBase<char> *i, const char* enc)
+{
+    finishedDecoding = false;
+    input = i;
+    charbuf.setSize(262);
+	mark(262);
+    charsLeft = 0;
+
+	if ( strcmp(enc,"ASCII")==0 )
+		encoding = ASCII;
+#ifdef _UCS2
+	else if ( strcmp(enc,"UTF-8")==0 )
+		encoding = UTF8;
+	else if ( strcmp(enc,"UCS-2LE")==0 )
+		encoding = UCS2_LE;
+#endif
+	else
+		_CLTHROWA(CL_ERR_IllegalArgument,"Unsupported encoding, use jstreams iconv based instead");
+}
+SimpleInputStreamReader::~SimpleInputStreamReader(){
+	input = NULL;
+}
+int32_t SimpleInputStreamReader::decode(TCHAR* start, int32_t space){
+	// decode from charbuf
+    const char *inbuf = charbuf.readPos;
+    const char *inbufend = charbuf.readPos + charbuf.avail;
+    TCHAR *outbuf = start;
+	const TCHAR *outbufend = outbuf + space;
+
+	if ( encoding == ASCII ){
+		while ( outbuf<outbufend && inbuf<inbufend ){
+			*outbuf = *inbuf;
+			outbuf++;
+			inbuf++;
+		}
+		
+#ifdef _UCS2
+	}
+	else if ( encoding == UCS2_LE ){
+		while ( outbuf<outbufend && (inbuf+1)<inbufend ){
+			uint8_t c1 = *inbuf;
+			uint8_t c2 = *(inbuf+1);
+			unsigned short c = c1 | (c2<<8);
+			
+			#ifdef _UCS2
+				*outbuf = c;
+			#else
+				*outbuf = LUCENE_OOR_CHAR(c);
+			#endif
+			outbuf++;
+			inbuf+=2;
+		}
+
+	}else if ( encoding == UTF8 ){
+		while ( outbuf<outbufend && inbuf<inbufend ){
+			size_t utflen = lucene_utf8charlen(inbuf);
+			if ( utflen==0 ){
+				error = "Invalid multibyte sequence.";
+				status = jstreams::Error;
+				return -1;
+			}else if ( inbuf+utflen > inbufend ){
+				break; //character incomplete
+			}else{
+				size_t rd = lucene_utf8towc(outbuf,inbuf,inbufend-inbuf);
+				if ( rd == 0 ){
+					error = "Invalid multibyte sequence.";
+					status = jstreams::Error;
+					return -1;
+				}else{
+					inbuf+=rd;
+					outbuf++;
+				}
+			}
+		}
+#endif //_UCS2
+	}else
+		_CLTHROWA(CL_ERR_Runtime,"Unexpected encoding");
+
+	if ( outbuf < outbufend ) { 
+		//we had enough room to convert the entire input
+		if ( inbuf < inbufend ) {
+			// last character is incomplete
+			// move from inbuf to the end to the start of
+			// the buffer
+			memmove(charbuf.start, inbuf, inbufend-inbuf);
+			charbuf.readPos = charbuf.start;
+			charbuf.avail = inbufend-inbuf;
+		} else if ( outbuf < outbufend ) { //input sequence was completely converted
+			charbuf.readPos = charbuf.start;
+			charbuf.avail = 0;
+			if (input == NULL) {
+				finishedDecoding = true;
+			}
+		}
+	} else {
+        charbuf.readPos += charbuf.avail - (inbufend-inbuf);
+        charbuf.avail = inbufend-inbuf;
+	}
+    return outbuf-start;
+}
+
+int32_t SimpleInputStreamReader::fillBuffer(TCHAR* start, int32_t space) {
+    // fill up charbuf
+    if (input && charbuf.readPos == charbuf.start) {
+        const char *begin;
+        int32_t numRead;
+        numRead = input->read(begin, 1, charbuf.size - charbuf.avail);
+        //printf("filled up charbuf\n");
+        if (numRead < -1) {
+            error = input->getError();
+            status = jstreams::Error;
+            input = 0;
+            return numRead;
+        }
+        if (numRead < 1) {
+            // signal end of input buffer
+            input = 0;
+            if (charbuf.avail) {
+                error = "stream ends on incomplete character";
+                status = jstreams::Error;
+            }
+            return -1;
+        }
+        // copy data into other buffer
+        memmove( charbuf.start + charbuf.avail, begin, numRead * sizeof(char));
+        charbuf.avail = numRead + charbuf.avail;
+    }
+    // decode
+    int32_t n = decode(start, space);
+    //printf("decoded %i\n", n);
+    return n;
+}
+
 CL_NS_END

Modified: trunk/clucene/src/CLucene/util/Reader.h
===================================================================
--- trunk/clucene/src/CLucene/util/Reader.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/Reader.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_util_Reader_
 #define _lucene_util_Reader_
 
@@ -22,6 +13,8 @@
 
 #include "streambase.h"
 #include "stringreader.h"
+#include "fileinputstream.h"
+#include "bufferedstream.h"
 
 CL_NS_DEF(util)
 /**
@@ -32,7 +25,7 @@
 public:
 	bool deleteReader;
 	jsReader* reader;
-	
+
 	Reader(jsReader* reader, bool deleteReader){
 		this->reader = reader;
 		this->deleteReader = deleteReader;
@@ -44,47 +37,51 @@
 	}
 	inline int read(){
 		const TCHAR*b;
-		int32_t nread = reader->read(b, 1);
-		if ( nread == 0 ) {
+		int32_t nread = reader->read(b, 1,1);
+		if ( nread < -1 ) //if not eof
+			_CLTHROWA(CL_ERR_IO,reader->getError() );
+		else if ( nread == -1 )
 			return -1;
-		} else if ( nread == -1 ) {
-			_CLTHROWA(CL_ERR_IO,reader->getError());
-		} else {
+		else
 			return b[0];
-		}
 	}
+	/**
+	* Read at least 1 character, and as much as is conveniently available
+	*/
 	inline int32_t read(const TCHAR*& start){
-		int32_t nread = reader->read(start);
-		if ( nread == 0 )
-			return -1;
-		else if ( nread == -1 )
+		int32_t nread = reader->read(start,1,0);
+		if ( nread < -1 ) //if not eof
 			_CLTHROWA(CL_ERR_IO,reader->getError());
 		else
 			return nread;
 	}
 	inline int32_t read(const TCHAR*& start, int32_t len){
-		int32_t nread = reader->read(start, len);
-		if ( nread == 0 )
-			return -1;
-		else if ( nread == -1 )
+		int32_t nread = reader->read(start, len, len);
+		if ( nread < -1 ) //if not eof
 			_CLTHROWA(CL_ERR_IO,reader->getError());
 		else
 			return nread;
 	}
 	inline int64_t skip(int64_t ntoskip){
 		int64_t skipped = reader->skip(ntoskip);
-		if ( skipped == -1 )
+		if ( skipped < 0 ) 
 			_CLTHROWA(CL_ERR_IO,reader->getError());
-		return skipped;
+		else
+			return skipped;
 	}
-	inline void mark(int32_t readAheadlimit){
-		reader->mark(readAheadlimit);
+	inline int64_t mark(int32_t readAheadlimit){
+		int64_t pos = reader->mark(readAheadlimit);
+		if ( pos < 0 )
+			_CLTHROWA(CL_ERR_IO,reader->getError());
+		else
+			return pos;
 	}
-	jstreams::StreamStatus reset(){
-		jstreams::StreamStatus s = reader->reset();
-		if ( s == jstreams::Error )
+	int64_t reset(int64_t pos){
+		int64_t r = reader->reset(pos);
+		if ( r < 0 )
 			_CLTHROWA(CL_ERR_IO,reader->getError());
-		return s;
+		else
+			return r;
 	}
 };
 
@@ -93,9 +90,49 @@
 public:
 	StringReader ( const TCHAR* value );
     StringReader ( const TCHAR* value, const int32_t length );
-    StringReader ( TCHAR* value, const int32_t length, bool copyData );
+    StringReader ( const TCHAR* value, const int32_t length, bool copyData );
 	~StringReader();
 };
 
+/** A very simple inputstreamreader implementation. For a
+* more complete InputStreamReader, use the jstreams version
+* located in the contrib package
+*/
+class SimpleInputStreamReader: public jstreams::BufferedInputStream<TCHAR>{
+    int32_t decode(TCHAR* start, int32_t space);
+	int encoding;
+	enum{
+		ASCII=1,
+		UTF8=2,
+		UCS2_LE=3
+	};
+    bool finishedDecoding;
+    jstreams::StreamBase<char>* input;
+    int32_t charsLeft;
+
+    jstreams::InputStreamBuffer<char> charbuf;
+    int32_t fillBuffer(TCHAR* start, int32_t space);
+public:
+	SimpleInputStreamReader(jstreams::StreamBase<char> *i, const char* encoding);
+	~SimpleInputStreamReader();
+};
+
+/**
+* A helper class which constructs a FileReader with a specified
+* simple encodings, or a given inputstreamreader
+*/
+class FileReader: public Reader{
+	jstreams::FileInputStream* input;
+public:
+	FileReader ( const char* path, const char* enc,
+        const int32_t cachelen = 13,
+        const int32_t cachebuff = 14 ); //todo: optimise these cache values
+	~FileReader ();
+
+    int32_t read(const TCHAR*& start, int32_t _min, int32_t _max);
+    int64_t mark(int32_t readlimit);
+    int64_t reset(int64_t);
+};
+
 CL_NS_END
 #endif

Modified: trunk/clucene/src/CLucene/util/StringBuffer.cpp
===================================================================
--- trunk/clucene/src/CLucene/util/StringBuffer.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/StringBuffer.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "StringBuffer.h"
 #include "Misc.h"
@@ -80,10 +71,11 @@
   // Func - Destructor
   // Pre  - true
   // Post - Instanc has been destroyed
-	  
-	  if(buffer!=NULL && bufferOwner){
-		  _CLDELETE_CARRAY(buffer);
-	  }
+
+	if( bufferOwner ){
+		_CLDELETE_CARRAY(buffer);
+	}else
+		buffer = NULL;
   }
   void StringBuffer::clear(){
   //Func - Clears the Stringbuffer and resets it to it default empty state
@@ -91,14 +83,8 @@
   //Post - pre(buffer) has been destroyed and a new one has been allocated
 
       //Destroy the current buffer if present
-	  if(buffer!=NULL && bufferOwner){
-	      _CLDELETE_CARRAY(buffer);
-	  }else if ( bufferOwner ){
-		buffer[0]=0;
-        len = 0;
-		return;
-	  }
-	  
+	  _CLDELETE_CARRAY(buffer);
+
 	  //Initialize 
       len = 0;
       bufferLength = LUCENE_DEFAULT_TOKEN_BUFFER_SIZE;
@@ -131,7 +117,7 @@
   
       append(value, _tcslen(value));
   }
-  void StringBuffer::append(const TCHAR* value, const int32_t appendedLength) {
+  void StringBuffer::append(const TCHAR* value, size_t appendedLength) {
   //Func - Appends a copy of the string value
   //Pre  - value != NULL
   //       appendedLength contains the length of the string value which is to be appended
@@ -141,7 +127,7 @@
       if (len + appendedLength + 1 > bufferLength){
           //Have the size of the current string buffer increased because it is too small	
           growBuffer(len + appendedLength + 1);
-          }
+      }
 
       //Copy the string value into the buffer at postion len
       _tcsncpy(buffer + len, value, appendedLength);
@@ -204,7 +190,7 @@
       prepend(value, _tcslen(value));
   }
 
-  void StringBuffer::prepend(const TCHAR* value, const int32_t prependedLength) {
+  void StringBuffer::prepend(const TCHAR* value, const size_t prependedLength) {
   //Func - Puts a copy of the string value in front of the string in the StringBuffer
   //Pre  - value != NULL
   //       prependedLength contains the length of the string value which is to be prepended
@@ -226,14 +212,14 @@
       len += prependedLength;
   }
 
-  int32_t StringBuffer::length() {
+  int32_t StringBuffer::length() const{
   //Func - Returns the length of the string in the StringBuffer
   //Pre  - true
   //Post - The length len of the string in the buffer has been returned
 
       return len;
   }
-  TCHAR* StringBuffer::toString() {
+  TCHAR* StringBuffer::toString(){
   //Func - Returns a copy of the current string in the StringBuffer sized equal to the length of the string 
   //       in the StringBuffer.
   //Pre  - true
@@ -246,7 +232,7 @@
 	      _tcsncpy(ret, buffer, len);
 		  //terminate the string
           ret[len] = '\0';
-	      }
+	  }
       //return the the copy  
       return ret;
   }

Modified: trunk/clucene/src/CLucene/util/StringBuffer.h
===================================================================
--- trunk/clucene/src/CLucene/util/StringBuffer.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/StringBuffer.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_util_StringBuffer_
 #define _lucene_util_StringBuffer_
 
@@ -44,7 +35,7 @@
    ///Appends a copy of the string value 
    void append(const TCHAR* value);
    ///Appends a copy of the string value
-   void append(const TCHAR* value, const int32_t appendedLength);
+   void append(const TCHAR* value, size_t appendedLength);
    ///Appends an integer (after conversion to a character string)
    void appendInt(const int32_t value);
    ///Appends a float_t (after conversion to a character string)
@@ -52,13 +43,13 @@
    ///Puts a copy of the string value in front of the current string in the StringBuffer
    void prepend(const TCHAR* value);
    ///Puts a copy of the string value in front of the current string in the StringBuffer
-   void prepend(const TCHAR* value, const int32_t prependedLength);
+   void prepend(const TCHAR* value, size_t prependedLength);
    
    ///Contains the length of string in the StringBuffer
    ///Public so that analyzers can edit the length directly
    int32_t len;
    ///Returns the length of the string in the StringBuffer
-   int32_t length();
+   int32_t length() const;
    ///Returns a copy of the current string in the StringBuffer
    TCHAR* toString(); 
    ///Returns a null terminated reference to the StringBuffer's text

Modified: trunk/clucene/src/CLucene/util/StringIntern.cpp
===================================================================
--- trunk/clucene/src/CLucene/util/StringIntern.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/StringIntern.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 #include "StringIntern.h"
 CL_NS_DEF(util)
@@ -31,7 +22,7 @@
             __strintrntype::iterator itr = stringaPool.begin();
             while ( itr != stringaPool.end() ){
                 printf(" %s (%d)\n",(itr->first), (itr->second));
-                itr++;
+                ++itr;
             }
         }
         
@@ -40,7 +31,7 @@
             __wcsintrntype::iterator itr = stringPool.begin();
             while ( itr != stringPool.end() ){
                 _tprintf(_T(" %s (%d)\n"),(itr->first), (itr->second));
-                itr++;
+                ++itr;
             }
         }
     #endif

Modified: trunk/clucene/src/CLucene/util/StringIntern.h
===================================================================
--- trunk/clucene/src/CLucene/util/StringIntern.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/StringIntern.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_util_StringIntern_H
 #define _lucene_util_StringIntern_H
 
@@ -22,8 +13,8 @@
 
 #include "VoidMap.h"
 CL_NS_DEF(util)
-typedef CL_NS(util)::CLHashMap<const TCHAR*,int,Compare::TChar,Deletor::tcArray ,Deletor::DummyInt32 > __wcsintrntype;
-typedef CL_NS(util)::CLHashMap<const char*,int,Compare::Char,Deletor::acArray ,Deletor::DummyInt32 > __strintrntype;
+typedef CL_NS(util)::CLHashMap<const TCHAR*,int,CL_NS(util)::Compare::TChar,CL_NS(util)::Deletor::tcArray, CL_NS(util)::Deletor::DummyInt32 > __wcsintrntype;
+typedef CL_NS(util)::CLHashMap<const char*,int,CL_NS(util)::Compare::Char,CL_NS(util)::Deletor::acArray, CL_NS(util)::Deletor::DummyInt32 > __strintrntype;
 
   /** Functions for intern'ing strings. This
   is a process of pooling strings thus using less memory,

Modified: trunk/clucene/src/CLucene/util/VoidList.h
===================================================================
--- trunk/clucene/src/CLucene/util/VoidList.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/VoidList.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_util_VoidList_
 #define _lucene_util_VoidList_
 
@@ -20,6 +11,8 @@
 # pragma once
 #endif
 
+#include "Equators.h"
+
 CL_NS_DEF(util)
 
 	template<typename _kt,typename _base,typename _valueDeletor> 
@@ -89,7 +82,7 @@
 				iterator itr = base::begin();
 				while ( itr != base::end() ){
 					_valueDeletor::doDelete(*itr);
-					itr++;
+					++itr;
 				}
 			}
 			base::clear();

Modified: trunk/clucene/src/CLucene/util/VoidMap.h
===================================================================
--- trunk/clucene/src/CLucene/util/VoidMap.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/VoidMap.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef _lucene_util_VoidMap_
 #define _lucene_util_VoidMap_
 
@@ -37,7 +28,7 @@
 
 	typedef typename _base::iterator iterator;
 	typedef typename _base::const_iterator const_iterator;
-	typedef pair<_kt, _vt> _pair;
+	typedef CL_NS_STD(pair)<_kt, _vt> _pair;
 
 	///Default constructor for the __CLMap
 	__CLMap ():
@@ -135,7 +126,7 @@
 					_KeyDeletor::doDelete(itr->first);
 				if ( dv ) 
 					_ValueDeletor::doDelete(itr->second);
-				itr++;
+				++itr;
 			}
 		}
 		base::clear();

Modified: trunk/clucene/src/CLucene/util/dirent.cpp
===================================================================
--- trunk/clucene/src/CLucene/util/dirent.cpp	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/dirent.cpp	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,30 +1,19 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #include "CLucene/StdHeader.h"
 
 #if !defined(_CL_HAVE_DIRENT_H) && !defined(_CL_HAVE_SYS_NDIR_H) && !defined(_CL_HAVE_SYS_DIR_H) && !defined(_CL_HAVE_NDIR_H)
 #include "dirent.h"
 
-CL_NS_DEF(util)
-
 DIR * 
 opendir (const char *szPath)
 {
 	DIR *nd;
-	char szFullPath[CL_MAX_DIR];
+	char szFullPath[CL_MAX_PATH];
 
 	errno = 0;
 
@@ -56,7 +45,7 @@
 	}
 
 	/* Make an absolute pathname.  */
-	_fullpath (szFullPath, szPath, CL_MAX_DIR);
+	_realpath(szPath,szFullPath);
 
 	/* Allocate enough space to store DIR structure and the complete
 	* directory path given. */
@@ -215,6 +204,5 @@
 
 	return rc;
 }
-CL_NS_END
 #endif //HAVE_DIRENT_H
 

Modified: trunk/clucene/src/CLucene/util/dirent.h
===================================================================
--- trunk/clucene/src/CLucene/util/dirent.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/dirent.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef lucene_util_dirent_H
 #define lucene_util_dirent_H
 
@@ -22,7 +13,6 @@
 
 #if !defined(_CL_HAVE_DIRENT_H) && !defined(_CL_HAVE_SYS_NDIR_H) && !defined(_CL_HAVE_SYS_DIR_H) && !defined(_CL_HAVE_NDIR_H)
 
-CL_NS_DEF(util)
 /**
 \unit
  * dirent.c
@@ -94,8 +84,6 @@
 int32_t	closedir (DIR* dir);
 
 
-CL_NS_END
-
 #elif defined (_CL_HAVE_DIRENT_H)
 # include <dirent.h>
 # define NAMLEN(dirent) strlen((dirent)->d_name)

Modified: trunk/clucene/src/CLucene/util/jstreamsconfig.h
===================================================================
--- trunk/clucene/src/CLucene/util/jstreamsconfig.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/jstreamsconfig.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 
 //this is just a compatibility header for jstreams
 #include "CLucene/StdHeader.h"

Modified: trunk/clucene/src/CLucene/util/streambase.h
===================================================================
--- trunk/clucene/src/CLucene/util/streambase.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/streambase.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Jos van den Oever
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 #ifndef STREAMBASE_H
 #define STREAMBASE_H
 
@@ -67,9 +58,9 @@
      *         end of the stream has been reached. If -1 is returned, an error
      *         has occured.
      **/
-    virtual int32_t read(const T*& start) = 0;
+ //   virtual int32_t read(const T*& start) = 0;
     /** 
-     * @brief Reads @p ntoread characters from the stream and sets \a start to
+     * @brief Reads characters from the stream and sets \a start to
      * the first character that was read.
      *
      * If @p ntoread is @c 0, then at least one character will be read.
@@ -80,11 +71,15 @@
      *              is undefined.
      * @param ntoread The number of characters to read from the stream. If
      *                @p is @c 0 the stream reads at least 1 character.
-     * @return the number of characters that were read. If 0 is returned, the
-     *         end of the stream has been reached. If -1 is returned, an error
+     * @return the number of characters that were read. If -1 is returned, the
+     *         end of the stream has been reached. If -2 is returned, an error
      *         has occured.
      **/
-    virtual int32_t read(const T*& start, int32_t ntoread) = 0;
+    virtual int32_t read(const T*& start, int32_t min, int32_t max) = 0;
+    /**
+     * Same as read(const T*& start, int32_t ntoread), but may read more.
+     **/
+//    virtual int32_t readAtLeast(const T*& start, int32_t ntoread) = 0;
     /* the available value may be greater than the actual value if
       the encoding is a variable one (such as utf8 or unicode) */
     /**
@@ -111,12 +106,17 @@
       * When calling the method mark more than once at the same position in the
       * stream, the call with the largest value for \p readlimit is defining.
       **/
-    virtual StreamStatus mark(int32_t readlimit) = 0;
+    virtual int64_t mark(int32_t readlimit) = 0;
       /**
-       * \short Repositions this stream to the position at the time the mark
-       * method was last called on this input stream.
+       * \short Repositions this stream to given requested position.
        * The general contract of reset is:
-       * - If the method mark has not been called since the stream was created,
+       * - Reset is guaranteed to work after a successfull call to read(),
+       *   when new position is in the range of the data returned by read().
+       *   This means that @p pos must lie between than the position
+       *   corresponding to the @p start parameter (x) of the @r read function
+       *   and the position corresponding to the last position in the returned
+       *   buffer (x + @p nread).
+       * if If the method mark has not been called since the stream was created,
        *   or the number of bytes read from the stream since mark was last
        *   called is larger than the argument to mark at that last call, then
        *   Error is returned.
@@ -127,28 +127,27 @@
        *   would have been the next input data as of the time of the call to
        *   reset.
        **/
-    virtual StreamStatus reset() = 0;
+    virtual int64_t reset(int64_t pos) = 0;
 };
-
+#define SKIPSTEP 1024
 template <class T>
 int64_t
 StreamBase<T>::skip(int64_t ntoskip) {
-    static const int32_t skipstep = 1024;
     const T *begin;
     int32_t nread;
     int64_t skipped = 0;
     while (ntoskip) {
-        int32_t step = (int32_t)((ntoskip > skipstep) ?skipstep :ntoskip);
-        nread = read(begin, step);
-        if (nread < 0) {
-            return skipped;
-        } else if (nread < step) {
-            status = Eof;
+        int32_t step = (int32_t)((ntoskip > SKIPSTEP) ?SKIPSTEP :ntoskip);
+        nread = read(begin, 1, step);
+        if (nread < -1 ) {
+            // an error occurred
+            return nread;
+        } else if (nread < 1) {
             ntoskip = 0;
         } else {
+            skipped += nread;
             ntoskip -= nread;
         }
-        skipped += nread;
     }
     return skipped;
 }

Modified: trunk/clucene/src/CLucene/util/stringreader.h
===================================================================
--- trunk/clucene/src/CLucene/util/stringreader.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene/util/stringreader.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,123 +1,103 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef STRINGREADER_H
-#define STRINGREADER_H
-
-#include "streambase.h"
-
-namespace jstreams {
-
-template <class T>
-class StringReader : public StreamBase<T> {
-private:
-    int64_t markpt;
-    T* data;
-    bool dataowner;
-    StringReader(const StringReader<T>&);
-    void operator=(const StringReader<T>&);
-public:
-    StringReader(const T* value, int32_t length = -1, bool copy = true);
-    ~StringReader();
-    int32_t read(const T*& start);
-    int32_t read(const T*& start, int32_t ntoread);
-    int64_t skip(int64_t ntoskip);
-    StreamStatus mark(int32_t readlimit);
-    StreamStatus reset();
-};
-
-template <class T>
-StringReader<T>::StringReader(const T* value, int32_t length, bool copy)
-        : markpt(0), dataowner(copy) {
-    if (length < 0) {
-        if (sizeof(T) > 1) {
-            length = wcslen((const wchar_t*)value);
-        } else {
-            length = strlen((const char*)value);
-        }
-    }
-    StreamBase<T>::size = length;
-    if (copy) {
-        data = new T[length+1];
-        size_t s = (size_t)(length*sizeof(T));
-        memcpy(data, value, s);
-        data[length] = 0;
-    } else {
-        // casting away const is ok, because we don't write anyway
-        data = (T*)value;
-    }
-}
-template <class T>
-StringReader<T>::~StringReader() {
-    if (dataowner) {
-        delete [] data;
-    }
-}
-template <class T>
-int32_t
-StringReader<T>::read(const T*& start) {
-    StreamBase<T>::status = Eof;
-    int64_t left = StreamBase<T>::size - StreamBase<T>::position;
-    if (left == 0) {
-        return 0;
-    }
-    int32_t nread = (int32_t)((left > INT32MAX) ?INT32MAX :left);
-    start = data + StreamBase<T>::position;
-    StreamBase<T>::position = StreamBase<T>::size;
-    return nread;
-}
-template <class T>
-int32_t
-StringReader<T>::read(const T*& start, int32_t ntoread) {
-    int64_t left = StreamBase<T>::size - StreamBase<T>::position;
-    if (left == 0) {
-        StreamBase<T>::status = Eof;
-        return 0;
-    }
-    int32_t nread = (int32_t)(ntoread > left) ?left :ntoread;
-    start = data + StreamBase<T>::position;
-    StreamBase<T>::position += nread;
-    if (StreamBase<T>::position == StreamBase<T>::size) {
-        StreamBase<T>::status = Eof;
-    }
-    return nread;
-}
-template <class T>
-int64_t
-StringReader<T>::skip(int64_t ntoskip) {
-    const T* start;
-    return read(start, ntoskip);
-}
-template <class T>
-StreamStatus
-StringReader<T>::mark(int32_t /*readlimit*/) {
-    markpt = StreamBase<T>::position;
-    return Ok;
-}
-template <class T>
-StreamStatus
-StringReader<T>::reset() {
-    StreamBase<T>::position = markpt;
-    if (markpt == StreamBase<T>::size) {
-        StreamBase<T>::status = Eof;
-    } else {
-        StreamBase<T>::status = Ok;
-    }
-    return Ok;
-}
-
-} // end namespace jstreams
-
-#endif
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Jos van den Oever
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
+#ifndef STRINGREADER_H
+#define STRINGREADER_H
+
+#include "streambase.h"
+
+namespace jstreams {
+
+template <class T>
+class StringReader : public StreamBase<T> {
+private:
+    int64_t markpt;
+    T* data;
+    bool dataowner;
+    StringReader(const StringReader<T>&);
+    void operator=(const StringReader<T>&);
+public:
+    StringReader(const T* value, int32_t length = -1, bool copy = true);
+    ~StringReader();
+    int32_t read(const T*& start, int32_t min, int32_t max);
+    int64_t skip(int64_t ntoskip);
+    int64_t mark(int32_t readlimit);
+    int64_t reset(int64_t pos);
+};
+
+template <class T>
+StringReader<T>::StringReader(const T* value, int32_t length, bool copy)
+        : markpt(0), dataowner(copy) {
+    if (length < 0) {
+    	length = 0;
+    	while ( value[length] != '\0' )
+    		length++;
+    }
+    StreamBase<T>::size = length;
+    if (copy) {
+        data = new T[length+1];
+        size_t s = (size_t)(length*sizeof(T));
+        memcpy(data, value, s);
+        data[length] = 0;
+    } else {
+        // casting away const is ok, because we don't write anyway
+        data = (T*)value;
+    }
+}
+template <class T>
+StringReader<T>::~StringReader() {
+    if (dataowner) {
+        delete [] data;
+    }
+}
+template <class T>
+int32_t
+StringReader<T>::read(const T*& start, int32_t min, int32_t max) {
+    int64_t left = StreamBase<T>::size - StreamBase<T>::position;
+    if (left == 0) {
+        StreamBase<T>::status = Eof;
+        return -1;
+    }
+    if (min < 0) min = 0;
+    int32_t nread = (int32_t)(max > left || max < 1) ?left :max;
+    start = data + StreamBase<T>::position;
+    StreamBase<T>::position += nread;
+    if (StreamBase<T>::position == StreamBase<T>::size) {
+        StreamBase<T>::status = Eof;
+    }
+    return nread;
+}
+template <class T>
+int64_t
+StringReader<T>::skip(int64_t ntoskip) {
+    const T* start;
+    return read(start, ntoskip, ntoskip);
+}
+template <class T>
+int64_t
+StringReader<T>::mark(int32_t /*readlimit*/) {
+    markpt = StreamBase<T>::position;
+    return markpt;
+}
+template <class T>
+int64_t
+StringReader<T>::reset(int64_t newpos) {
+    if (newpos < 0) {
+        StreamBase<T>::status = Ok;
+        StreamBase<T>::position = 0;
+    } else if (newpos < StreamBase<T>::size) {
+        StreamBase<T>::status = Ok;
+        StreamBase<T>::position = newpos;
+    } else {
+        StreamBase<T>::position = StreamBase<T>::size;
+        StreamBase<T>::status = Eof;
+    }
+    return StreamBase<T>::position;
+}
+
+} // end namespace jstreams
+
+#endif

Modified: trunk/clucene/src/CLucene.h
===================================================================
--- trunk/clucene/src/CLucene.h	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/clucene/src/CLucene.h	2006-06-26 00:39:24 UTC (rev 428)
@@ -1,18 +1,9 @@
-/**
- * Copyright 2003-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+* 
+* Distributable under the terms of either the Apache License (Version 2.0) or 
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
 //Includes some standard headers for searching and indexing.
 #ifndef _lucene_CLucene_
 #define _lucene_CLucene_

Modified: trunk/stage/layout.conf
===================================================================
--- trunk/stage/layout.conf	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/stage/layout.conf	2006-06-26 00:39:24 UTC (rev 428)
@@ -7,17 +7,20 @@
 
 [History]
 LastComModule=JFB
-LastLDKey=5485
+LastLDKey=ABRAM
 LastLDModule=CBC
 LastParaMod01=
 LastParaMod02=
 LastParaMod03=
-LastTextModule=ChiNCVs
-LastVerse=James 1:19
+LastTextModule=WLC
+LastVerse=Genesis 1:1
 LookupSaveCount=5
 LookupText=James 1:19
 LookupText=John 1:1
 SearchSaveCount=5
+SearchText=物*
+SearchText=各*
+SearchText=我*
 
 [LDView]
 CBC=
@@ -30,7 +33,7 @@
 
 [ModuleOptions]
 Cross-references=On
-Footnotes=Off
+Footnotes=On
 Headings=Off
 Hebrew Cantillation=Off
 Hebrew Vowel Points=On
@@ -42,16 +45,16 @@
 
 [Screen]
 MainHeight=749
-MainLeft=22
-MainTop=22
+MainLeft=254
+MainTop=252
 MainWidth=1050
 Maximized=false
 SearchHeight=566
-SearchLeft=675
+SearchLeft=224
 SearchMaximized=false
 SearchResCol0Width=175
-SearchTop=312
-SearchWidth=545
+SearchTop=351
+SearchWidth=759
 TextComHeight=195
 TextWidth=368
 
@@ -62,6 +65,7 @@
 ChiUn=
 ChiUns=
 GerNEU=
+Jub=
 KJV=
 NASB=
 PARALLEL=

Modified: trunk/sword.bpr
===================================================================
--- trunk/sword.bpr	2006-06-11 07:16:00 UTC (rev 427)
+++ trunk/sword.bpr	2006-06-26 00:39:24 UTC (rev 428)
@@ -43,7 +43,7 @@
     <DEBUGLIBPATH value="$(BCB)\lib\debug"/>
     <RELEASELIBPATH value="$(BCB)\lib\release"/>
     <LINKER value="ilink32"/>
-    <USERDEFINES value="_ICU_;_ICUSWORD_;USBINARY;U_HAVE_PLACEMENT_NEW=0;USELUCENE;_CL_DISABLE_MULTITHREADING"/>
+    <USERDEFINES value="_ICU_;_ICUSWORD_;USBINARY;U_HAVE_PLACEMENT_NEW=0;USELUCENE;_CL_DISABLE_MULTITHREADING;_DEBUG"/>
     <SYSDEFINES value="NO_STRICT"/>
     <MAINSOURCE value="sword.cpp"/>
     <INCLUDEPATH value="..\sword\src\modules\filters;D:\;TntUnicodeControls;..\icu-sword\source\common;..\icu-sword\source\i18n;..\sword\include;$(BCB)\include;$(BCB)\include\vcl;rxlib"/>
@@ -57,16 +57,16 @@
       -I$(BCB)\include -I$(BCB)\include\vcl -Irxlib -src_suffix cpp -D_ICU_ 
       -D_ICUSWORD_ -DUSBINARY -DU_HAVE_PLACEMENT_NEW=0 -DUSELUCENE 
       -D_CL_DISABLE_MULTITHREADING"/>
-    <CFLAG1 value="-O2 -Vx -X- -a8 -4 -b- -k- -vi -c -tW -tWM"/>
-    <PFLAGS value="-N2obj -N0obj -$Y- -$L- -$D- -v -M -JPHNE"/>
+    <CFLAG1 value="-vGc -vGt -vGd -Od -Vx -X- -r- -a8 -4 -b- -k -y -v -vi- -c -tW -tWM"/>
+    <PFLAGS value="-N2obj -N0obj -$Y+ -$W -$O- -v -M -JPHNE"/>
     <RFLAGS value=""/>
-    <AFLAGS value="/mx /w2 /zn"/>
-    <LFLAGS value="-Iobj -D&quot;&quot; -aa -Tpe -GD -s -Gn"/>
+    <AFLAGS value="/mx /w2 /zi"/>
+    <LFLAGS value="-Iobj -D&quot;&quot; -aa -Tpe -GD -s -Gn -v"/>
   </OPTIONS>
   <LINKER>
     <ALLOBJ value="c0w32.obj $(OBJFILES)"/>
     <ALLRES value="$(RESFILES)"/>
-    <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib"/>
+    <ALLLIB value="cg32.lib $(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib"/>
   </LINKER>
   <IDEOPTIONS>
 [Version Info]
@@ -75,7 +75,7 @@
 MajorVer=1
 MinorVer=5
 Release=8
-Build=2
+Build=3
 Debug=0
 PreRelease=0
 Special=0
@@ -87,7 +87,7 @@
 [Version Info Keys]
 CompanyName=CrossWire Software &amp; Bible Society
 FileDescription=Windows 32bit User Interface to The SWORD Project
-FileVersion=1.5.8.2
+FileVersion=1.5.8.3
 InternalName=biblecs
 LegalCopyright=(c) 1990-2005 CrossWire Bible Society under the terms of the GNU General Public License
 LegalTrademarks=
@@ -140,22 +140,23 @@
 Item2=$(BCB)\source\vcl
 
 [HistoryLists\hlConditionals]
-Count=15
-Item0=_ICU_;_ICUSWORD_;USBINARY;U_HAVE_PLACEMENT_NEW=0;USELUCENE;_CL_DISABLE_MULTITHREADING
-Item1=_ICU_;_ICUSWORD_;USBINARY;U_HAVE_PLACEMENT_NEW=0;USELUCENE
-Item2=_ICU_;_ICUSWORD_;USBINARY;U_HAVE_PLACEMENT_NEW=0;USELUCENE;_DEBUG
-Item3=_ICU_;_ICUSWORD_;USBINARY;U_HAVE_PLACEMENT_NEW=0;_DEBUG;USELUCENE
-Item4=_ICU_;_ICUSWORD_;USBINARY;U_HAVE_PLACEMENT_NEW=0;_DEBUG
-Item5=_ICU_;_ICUSWORD_;USBINARY;U_HAVE_PLACEMENT_NEW=0
-Item6=_ICU_;_ICUSWORD_;USBINARY;_DEBUG;U_HAVE_PLACEMENT_NEW=0
-Item7=_ICU_;_ICUSWORD_;USBINARY;_DEBUG
-Item8=_ICU_;_ICUSWORD_;USBINARY
-Item9=_ICU_;_ICUSWORD_;_DEBUG;USBINARY
-Item10=_ICU_;_ICUSWORD_;_DEBUG
-Item11=_ICU_;_ICUSWORD_
-Item12=_ICU_
-Item13=_ICU_;_DEBUG
-Item14=_DEBUG
+Count=16
+Item0=_ICU_;_ICUSWORD_;USBINARY;U_HAVE_PLACEMENT_NEW=0;USELUCENE;_CL_DISABLE_MULTITHREADING;_DEBUG
+Item1=_ICU_;_ICUSWORD_;USBINARY;U_HAVE_PLACEMENT_NEW=0;USELUCENE;_CL_DISABLE_MULTITHREADING
+Item2=_ICU_;_ICUSWORD_;USBINARY;U_HAVE_PLACEMENT_NEW=0;USELUCENE
+Item3=_ICU_;_ICUSWORD_;USBINARY;U_HAVE_PLACEMENT_NEW=0;USELUCENE;_DEBUG
+Item4=_ICU_;_ICUSWORD_;USBINARY;U_HAVE_PLACEMENT_NEW=0;_DEBUG;USELUCENE
+Item5=_ICU_;_ICUSWORD_;USBINARY;U_HAVE_PLACEMENT_NEW=0;_DEBUG
+Item6=_ICU_;_ICUSWORD_;USBINARY;U_HAVE_PLACEMENT_NEW=0
+Item7=_ICU_;_ICUSWORD_;USBINARY;_DEBUG;U_HAVE_PLACEMENT_NEW=0
+Item8=_ICU_;_ICUSWORD_;USBINARY;_DEBUG
+Item9=_ICU_;_ICUSWORD_;USBINARY
+Item10=_ICU_;_ICUSWORD_;_DEBUG;USBINARY
+Item11=_ICU_;_ICUSWORD_;_DEBUG
+Item12=_ICU_;_ICUSWORD_
+Item13=_ICU_
+Item14=_ICU_;_DEBUG
+Item15=_DEBUG
 
 [HistoryLists\hlIntOutputDir]
 Count=2
@@ -182,13 +183,8 @@
 [Compiler]
 ShowInfoMsgs=0
 LinkDebugVcl=0
-LinkCGLIB=0
+LinkCGLIB=1
 
-[CORBA]
-AddServerUnit=1
-AddClientUnit=1
-PrecompiledHeaders=1
-
 [Language]
 ActiveLang=
 ProjectLang=

Modified: trunk/sword.res
===================================================================
(Binary files differ)



More information about the sword-cvs mailing list