[fpc-pascal] How create a full text search with TChmWriter?

Andrew Haines AndrewD207 at aol.com
Thu Feb 23 18:48:41 CET 2012


On 02/22/12 18:01, Mattias Gaertner wrote:
> On Wed, 22 Feb 2012 12:06:08 -0500
> I tried with only 500 files and it worked. That means I get a help and
> it finds files. But choosing a page just shows black. And after that
> any page is black.
> Note: If I don't use the search but the Index, then I see the pages.
> 
> I compiled the chm units with -Criot and found various range check
> errors and uninitialized variables which I can fix myself. But then I
> came to a point where don't know what to do:
> 
> chmfiftimain.pas(361,49) Warning: Constructing a class "TLeafNode" with abstract method "ChildIsFull"
> chmfiftimain.pas(72,15) Hint: Found abstract method: TFIftiNode.ChildIsFull(<TFIftiNode>,AnsiString,LongWord);
> 
> And I get an exception in:
> #5  0x00000000005552aa in CHILDISFULL (this=0x415906, 
>     AWORD=0x409d0c "\311\303f\220H\203\354(H\211\\$\bL\211d$\020L\211l$\030L\211t$ I\211\376I\211\365f\211\323L\211\350H\203", <incomplete sequence \370>, ANODEOFFSET=8234056) at chmfiftimain.pas:688
> #6  0x00000000005552aa in CHILDISFULL (this=0x7fffdd9a0b40, AWORD=0x0, ANODEOFFSET=3579960) at chmfiftimain.pas:688
> 
> 

Not sure about this exception but I found an error in TLeafNode.AddWord.
It could possibly cause memory corruption and cause your error....

Replace the line

FBlockStream.Write(NewWord[1], Length(Trim(NewWord)));

with

if Length(NewWord) > 0 then
    FBlockStream.Write(NewWord[1], Length(Trim(NewWord)));



The same word can exists twice, once for title results and once for body
results. NewWord is the difference between the last word and the new
word. So it's length could be 0.

I compiled a chm using the lcl html docs in a folder. Compiled with
-Criot I am able to build it with a search index with no exceptions.

Andrew



More information about the fpc-pascal mailing list