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

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Feb 23 22:23:11 CET 2012


On Thu, 23 Feb 2012 12:48:41 -0500
Andrew Haines <AndrewD207 at aol.com> wrote:

> 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 Length(Trim(NewWord)) looks suspicious too me. Is this correct?

 
> 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.

Now it stops earlier on my files:

Exception at 0000000000473837: ERangeError:
Range check error.
Backtrace does not help much:

#0  0x00000000004120d0 in fpc_raiseexception ()
#1  0x000000000045fc38 in SYSUTILS_$$_RUNERRORTOEXCEPT$LONGINT$POINTER$POINTER ()
#2  0x0000000000000000 in ?? ()

Mattias



More information about the fpc-pascal mailing list