Browse Source

--- Merging r13767 into '.':
U packages/chm/src/chmfilewriter.pas
U packages/chm/src/chmwriter.pas
--- Merging r13805 into '.':
U utils/fpdoc/dw_htmlchm.inc
--- Merging r13806 into '.':
U packages/chm/src/paslzxcomp.pas
--- Merging r13807 into '.':
U packages/chm/src/chmfiftimain.pas
--- Merging r13808 into '.':
U packages/chm/src/chmreader.pas
--- Merging r13810 into '.':
U packages/chm/src/chmtypes.pas
--- Merging r13819 into '.':
U packages/chm/fpmake.pp
U packages/chm/Makefile.fpc
G packages/chm/src/paslzxcomp.pas
G packages/chm/src/chmwriter.pas
A packages/chm/src/lzxcompressthread.pas
U packages/chm/Makefile
--- Merging r13835 into '.':
G packages/chm/src/chmfilewriter.pas
G packages/chm/src/chmwriter.pas
G packages/chm/src/chmreader.pas
--- Merging r13836 into '.':
U utils/fpdoc/Makefile.fpc
U utils/fpdoc/Makefile
--- Merging r13837 into '.':
G utils/fpdoc/dw_htmlchm.inc
--- Merging r13839 into '.':
G utils/fpdoc/dw_htmlchm.inc
--- Merging r13840 into '.':
G packages/chm/src/chmwriter.pas
--- Merging r13844 into '.':
G packages/chm/src/chmreader.pas
--- Merging r13845 into '.':
U ide/wchmhwrap.pas

chm and fpdoc/chm related:
13767,13805,13806,13807,13808,13810,13819,13835,13836,13837,13839,13840,13844,13845

------------------------------------------------------------------------
r13767 | marco | 2009-09-27 18:03:08 +0200 (Sun, 27 Sep 2009) | 2 lines

* deduping #urlstr and #strings

------------------------------------------------------------------------
------------------------------------------------------------------------
r13805 | marco | 2009-10-05 20:19:36 +0200 (Mon, 05 Oct 2009) | 1 line

* check for css-file existance
------------------------------------------------------------------------
------------------------------------------------------------------------
r13806 | marco | 2009-10-05 22:45:46 +0200 (Mon, 05 Oct 2009) | 2 lines

* memleak fixed

------------------------------------------------------------------------
------------------------------------------------------------------------
r13807 | marco | 2009-10-05 23:10:47 +0200 (Mon, 05 Oct 2009) | 1 line

* more memory leaks fixed. Fpdoc is now memsafe except for the fcl-passrc bits
------------------------------------------------------------------------
------------------------------------------------------------------------
r13808 | marco | 2009-10-06 12:59:04 +0200 (Tue, 06 Oct 2009) | 5 lines

* skeleton function for binary index reading.
* toc and index now have a boolean parameter that allows to force reading
the XML components. E.g. in case binary reading is broken in a release,
Lazarus can simply switch to textual for a while.

------------------------------------------------------------------------
------------------------------------------------------------------------
r13810 | marco | 2009-10-06 13:14:24 +0200 (Tue, 06 Oct 2009) | 2 lines

* Some structures for BTree purposes.

------------------------------------------------------------------------
------------------------------------------------------------------------
r13819 | andrew | 2009-10-09 12:50:41 +0200 (Fri, 09 Oct 2009) | 3 lines

* added multithreaded lzx compression for lzx. Must be enabled with -dLZX_USETHREADS
* Updated makefile.fpc and Makefile for packages/chm

------------------------------------------------------------------------
------------------------------------------------------------------------
r13835 | marco | 2009-10-10 20:07:31 +0200 (Sat, 10 Oct 2009) | 2 lines

* Binary Index support

------------------------------------------------------------------------
------------------------------------------------------------------------
r13836 | marco | 2009-10-10 20:10:24 +0200 (Sat, 10 Oct 2009) | 2 lines

* added some non-cleaned units to be cleaned

------------------------------------------------------------------------
------------------------------------------------------------------------
r13837 | marco | 2009-10-10 20:33:40 +0200 (Sat, 10 Oct 2009) | 2 lines

* fpdoc parts of binary support + disable options.

------------------------------------------------------------------------
------------------------------------------------------------------------
r13839 | marco | 2009-10-10 21:23:30 +0200 (Sat, 10 Oct 2009) | 2 lines

* Fixes compilation problem

------------------------------------------------------------------------
------------------------------------------------------------------------
r13840 | marco | 2009-10-10 23:26:36 +0200 (Sat, 10 Oct 2009) | 2 lines

* commented a forgotten debug writeln

------------------------------------------------------------------------
------------------------------------------------------------------------
r13844 | marco | 2009-10-11 15:03:25 +0200 (Sun, 11 Oct 2009) | 2 lines

* fix for case that none of the two indexes are present.

------------------------------------------------------------------------
------------------------------------------------------------------------
r13845 | marco | 2009-10-11 15:53:03 +0200 (Sun, 11 Oct 2009) | 1 line

* IDE now uses generalized index procedure.
------------------------------------------------------------------------

git-svn-id: branches/fixes_2_4@14623 -

marco 15 years ago
parent
commit
6dddae6115

+ 1 - 0
.gitattributes

@@ -975,6 +975,7 @@ packages/chm/src/chmwriter.pas svneol=native#text/plain
 packages/chm/src/fasthtmlparser.pas svneol=native#text/plain
 packages/chm/src/fasthtmlparser.pas svneol=native#text/plain
 packages/chm/src/htmlindexer.pas svneol=native#text/plain
 packages/chm/src/htmlindexer.pas svneol=native#text/plain
 packages/chm/src/htmlutil.pas svneol=native#text/plain
 packages/chm/src/htmlutil.pas svneol=native#text/plain
+packages/chm/src/lzxcompressthread.pas svneol=native#text/plain
 packages/chm/src/paslznonslide.pas svneol=native#text/plain
 packages/chm/src/paslznonslide.pas svneol=native#text/plain
 packages/chm/src/paslzx.pas svneol=native#text/plain
 packages/chm/src/paslzx.pas svneol=native#text/plain
 packages/chm/src/paslzxcomp.pas svneol=native#text/plain
 packages/chm/src/paslzxcomp.pas svneol=native#text/plain

+ 11 - 2
ide/wchmhwrap.pas

@@ -129,7 +129,9 @@ begin
      debugmessageS({$i %file%},'TCHMWrapper: indexfilename:'+fchmr.indexfile,{$i %line%},'1',0,0);
      debugmessageS({$i %file%},'TCHMWrapper: indexfilename:'+fchmr.indexfile,{$i %line%},'1',0,0);
  {$endif}
  {$endif}
 
 
-  m:=fchmr.getobject(fchmr.indexfile);
+
+  findex:=fchmr.GetIndexSitemap(false);
+(*  m:=fchmr.getobject(fchmr.indexfile);
   try
   try
    if assigned(m) then
    if assigned(m) then
      begin
      begin
@@ -141,6 +143,7 @@ begin
   finally
   finally
     freeandnil(m);
     freeandnil(m);
     end;
     end;
+    *)
    {$ifdef wdebug}
    {$ifdef wdebug}
      debugmessageS({$i %file%},'TCHMWrapper: loadindex after final ',{$i %line%},'1',0,0);
      debugmessageS({$i %file%},'TCHMWrapper: loadindex after final ',{$i %line%},'1',0,0);
   {$endif}
   {$endif}
@@ -148,6 +151,12 @@ begin
   tli:=TopicLinks^.AddItem(fchmr.defaultpage);
   tli:=TopicLinks^.AddItem(fchmr.defaultpage);
   TLI:=EncodeHTMLCtx(ID,TLI+1);
   TLI:=EncodeHTMLCtx(ID,TLI+1);
   IndexEntries^.Insert(NewIndexEntry(  FormatAlias('Table of contents'),ID,TLI));
   IndexEntries^.Insert(NewIndexEntry(  FormatAlias('Table of contents'),ID,TLI));
+  if findex= Nil Then
+    begin
+      floaded:=true;
+      exit(true);
+    end;
+  if assigned(findex.items) and (findex.items.count>0) Then
   for i:=0 to findex.items.count-1 do
   for i:=0 to findex.items.count-1 do
     begin
     begin
       item:=findex.items.item[i];
       item:=findex.items.item[i];
@@ -289,7 +298,7 @@ begin
                Afileid:=chmw.fileid;
                Afileid:=chmw.fileid;
                alinkid:=chmw.fTopicLinks.additem(restlink);
                alinkid:=chmw.fTopicLinks.additem(restlink);
                result:=true;
                result:=true;
-            end;    
+            end;
          end;
          end;
     end
     end
 end;
 end;

+ 59 - 59
packages/chm/Makefile

@@ -1,5 +1,5 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/08/02]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/10/03]
 #
 #
 default: all
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
@@ -441,178 +441,178 @@ ifeq ($(FULL_TARGET),armeb-embedded)
 override TARGET_PROGRAMS+=chmcmd chmls
 override TARGET_PROGRAMS+=chmcmd chmls
 endif
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-haiku)
 ifeq ($(FULL_TARGET),i386-haiku)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netware)
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
 ifeq ($(FULL_TARGET),i386-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
 ifeq ($(FULL_TARGET),m68k-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
 ifeq ($(FULL_TARGET),sparc-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 ifeq ($(FULL_TARGET),x86_64-darwin)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 ifeq ($(FULL_TARGET),x86_64-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 ifeq ($(FULL_TARGET),arm-palmos)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),arm-darwin)
 ifeq ($(FULL_TARGET),arm-darwin)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),arm-wince)
 ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),arm-gba)
 ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),arm-nds)
 ifeq ($(FULL_TARGET),arm-nds)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
 ifeq ($(FULL_TARGET),arm-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
 ifeq ($(FULL_TARGET),arm-symbian)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
 ifeq ($(FULL_TARGET),powerpc64-darwin)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 ifeq ($(FULL_TARGET),powerpc64-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),avr-embedded)
 ifeq ($(FULL_TARGET),avr-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),armeb-linux)
 ifeq ($(FULL_TARGET),armeb-linux)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 ifeq ($(FULL_TARGET),armeb-embedded)
-override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain
+override TARGET_UNITS+=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer chmfiftimain lzxcompressthread
 endif
 endif
 override INSTALL_FPCPACKAGE=y
 override INSTALL_FPCPACKAGE=y
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)

+ 1 - 1
packages/chm/Makefile.fpc

@@ -9,7 +9,7 @@ version=2.2.2
 [target]
 [target]
 units=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes \
 units=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes \
       chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer \
       chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer \
-      chmfiftimain
+      chmfiftimain lzxcompressthread
 programs=chmcmd chmls
 programs=chmcmd chmls
 examples=
 examples=
 
 

+ 6 - 1
packages/chm/fpmake.pp

@@ -56,7 +56,7 @@ begin
         end;
         end;
     T:=P.Targets.AddUnit('chmtypes.pas');
     T:=P.Targets.AddUnit('chmtypes.pas');
       with T.Dependencies do
       with T.Dependencies do
-        begin
+       begin
           AddUnit('chmbase');
           AddUnit('chmbase');
         end;
         end;
     T:=P.Targets.AddUnit('htmlindexer.pas');
     T:=P.Targets.AddUnit('htmlindexer.pas');
@@ -74,6 +74,11 @@ begin
           AddUnit('paslzxcomp');
           AddUnit('paslzxcomp');
           AddUnit('chmfiftimain');
           AddUnit('chmfiftimain');
         end;
         end;
+    T:=P.Targets.AddUnit('lzxcompressthread');
+      with T.Dependencies do
+        begin
+          AddUnit('paslzxcomp');
+        end;
     T:=P.Targets.AddUnit('fasthtmlparser.pas');
     T:=P.Targets.AddUnit('fasthtmlparser.pas');
     T:=P.Targets.AddUnit('htmlutil.pas');
     T:=P.Targets.AddUnit('htmlutil.pas');
     T:=P.Targets.AddUnit('paslznonslide.pas');
     T:=P.Targets.AddUnit('paslznonslide.pas');

+ 21 - 4
packages/chm/src/chmfiftimain.pas

@@ -67,6 +67,7 @@ type
     FWriteStream: TStream;
     FWriteStream: TStream;
     FBlockStream: TMemoryStream;
     FBlockStream: TMemoryStream;
     ParentNode: TFIftiNode;
     ParentNode: TFIftiNode;
+    OwnsParentNode : boolean;
     function  AdjustedWord(AWord: String; out AOffset: Byte; AOldWord: String): String;
     function  AdjustedWord(AWord: String; out AOffset: Byte; AOldWord: String): String;
     procedure ChildIsFull(AWord: String; ANodeOffset: DWord); virtual; abstract;
     procedure ChildIsFull(AWord: String; ANodeOffset: DWord); virtual; abstract;
     function  GuessIfCanHold(AWord: String): Boolean; virtual; abstract;
     function  GuessIfCanHold(AWord: String): Boolean; virtual; abstract;
@@ -91,6 +92,7 @@ type
   public
   public
     procedure WriteToStream;
     procedure WriteToStream;
     constructor Create(AStream: TStream; AWordList: TIndexedWordList);
     constructor Create(AStream: TStream; AWordList: TIndexedWordList);
+    destructor Destroy; override;
   end;
   end;
 
 
   { TChmSearchReader }
   { TChmSearchReader }
@@ -259,6 +261,7 @@ begin
     FActiveLeafNode.Flush(False); // causes the unwritten parts of the tree to be written
     FActiveLeafNode.Flush(False); // causes the unwritten parts of the tree to be written
 end;
 end;
 
 
+
 procedure TChmSearchWriter.WriteHeader ( IsPlaceHolder: Boolean ) ;
 procedure TChmSearchWriter.WriteHeader ( IsPlaceHolder: Boolean ) ;
 var
 var
   TmpNode: TFIftiNode;
   TmpNode: TFIftiNode;
@@ -344,6 +347,7 @@ begin
 end;
 end;
 
 
 procedure TChmSearchWriter.WriteAWord ( AWord: TIndexedWord ) ;
 procedure TChmSearchWriter.WriteAWord ( AWord: TIndexedWord ) ;
+
 begin
 begin
   if FActiveLeafNode = nil then
   if FActiveLeafNode = nil then
   begin
   begin
@@ -363,7 +367,6 @@ begin
   TLeafNode(FActiveLeafNode).AddWord(AWord);
   TLeafNode(FActiveLeafNode).AddWord(AWord);
 end;
 end;
 
 
-
 procedure TChmSearchWriter.WriteToStream;
 procedure TChmSearchWriter.WriteToStream;
 begin
 begin
   WriteHeader(True);
   WriteHeader(True);
@@ -376,9 +379,16 @@ constructor TChmSearchWriter.Create ( AStream: TStream;
 begin
 begin
   FStream := AStream;
   FStream := AStream;
   FWordList := AWordList;
   FWordList := AWordList;
+  FActiveLeafNode:=NIL; 
+end;
+
+destructor TChmSearchWriter.Destroy;
 
 
+begin
+ freeandnil(FActiveLeafNode);
 end;
 end;
 
 
+
 { TLeafNode }
 { TLeafNode }
 
 
 function TFIftiNode.RemainingSpace: DWord;
 function TFIftiNode.RemainingSpace: DWord;
@@ -391,11 +401,13 @@ begin
   inherited Create;
   inherited Create;
   FWriteStream := AStream;
   FWriteStream := AStream;
   FBlockStream := TMemoryStream.Create;
   FBlockStream := TMemoryStream.Create;
+  OwnsParentNode :=false;
 end;
 end;
 
 
 destructor TFIftiNode.Destroy;
 destructor TFIftiNode.Destroy;
 begin
 begin
   FBlockStream.Free;
   FBlockStream.Free;
+  if OwnsParentNode then ParentNode.Free;
   inherited Destroy;
   inherited Destroy;
 end;
 end;
 
 
@@ -486,8 +498,10 @@ begin
   if NewBlockNeeded or ((NewBlockNeeded = False) and (ParentNode <> nil)) then
   if NewBlockNeeded or ((NewBlockNeeded = False) and (ParentNode <> nil)) then
   begin
   begin
     if ParentNode = nil then
     if ParentNode = nil then
-      ParentNode := TIndexNode.Create(FWriteStream);
-
+      begin
+        ParentNode := TIndexNode.Create(FWriteStream);
+        OwnsParentNode:=True;
+      end;
     ParentNode.ChildIsFull(FLastWord, FLastNodeStart);
     ParentNode.ChildIsFull(FLastWord, FLastNodeStart);
     if (NewBlockNeeded = False) then
     if (NewBlockNeeded = False) then
       ParentNode.Flush(False);
       ParentNode.Flush(False);
@@ -675,7 +689,10 @@ begin
   if NewBlockNeeded then
   if NewBlockNeeded then
   begin
   begin
     if ParentNode = nil then
     if ParentNode = nil then
-      ParentNode := TIndexNode.Create(FWriteStream);
+      begin
+        ParentNode := TIndexNode.Create(FWriteStream);
+        OwnsParentNode:=True;
+      end;
   end;
   end;
 
 
   if ParentNode <> nil then
   if ParentNode <> nil then

+ 30 - 11
packages/chm/src/chmfilewriter.pas

@@ -26,10 +26,10 @@ interface
 
 
 uses
 uses
   Classes, SysUtils, chmwriter;
   Classes, SysUtils, chmwriter;
-  
+
 type
 type
   TChmProject = class;
   TChmProject = class;
-  
+
   TChmProgressCB = procedure (Project: TChmProject; CurrentFile: String) of object;
   TChmProgressCB = procedure (Project: TChmProject; CurrentFile: String) of object;
 
 
   { TChmProject }
   { TChmProject }
@@ -42,6 +42,7 @@ type
     FFiles: TStrings;
     FFiles: TStrings;
     FIndexFileName: String;
     FIndexFileName: String;
     FMakeBinaryTOC: Boolean;
     FMakeBinaryTOC: Boolean;
+    FMakeBinaryIndex: Boolean;
     FMakeSearchable: Boolean;
     FMakeSearchable: Boolean;
     FFileName: String;
     FFileName: String;
     FOnProgress: TChmProgressCB;
     FOnProgress: TChmProgressCB;
@@ -66,12 +67,13 @@ type
     property AutoFollowLinks: Boolean read FAutoFollowLinks write FAutoFollowLinks;
     property AutoFollowLinks: Boolean read FAutoFollowLinks write FAutoFollowLinks;
     property TableOfContentsFileName: String read FTableOfContentsFileName write FTableOfContentsFileName;
     property TableOfContentsFileName: String read FTableOfContentsFileName write FTableOfContentsFileName;
     property MakeBinaryTOC: Boolean read FMakeBinaryTOC write FMakeBinaryTOC;
     property MakeBinaryTOC: Boolean read FMakeBinaryTOC write FMakeBinaryTOC;
+    property MakeBinaryIndex: Boolean read FMakeBinaryIndex write FMakeBinaryIndex;
     property Title: String read FTitle write FTitle;
     property Title: String read FTitle write FTitle;
     property IndexFileName: String read FIndexFileName write FIndexFileName;
     property IndexFileName: String read FIndexFileName write FIndexFileName;
     property MakeSearchable: Boolean read FMakeSearchable write FMakeSearchable;
     property MakeSearchable: Boolean read FMakeSearchable write FMakeSearchable;
     property DefaultPage: String read FDefaultPage write FDefaultPage;
     property DefaultPage: String read FDefaultPage write FDefaultPage;
     property DefaultFont: String read FDefaultFont write FDefaultFont;
     property DefaultFont: String read FDefaultFont write FDefaultFont;
-    
+
     property OnProgress: TChmProgressCB read FOnProgress write FOnProgress;
     property OnProgress: TChmProgressCB read FOnProgress write FOnProgress;
   end;
   end;
 
 
@@ -90,7 +92,7 @@ begin
   // clean up the filename
   // clean up the filename
   FileName := StringReplace(ExtractFileName(DataName), '\', '/', [rfReplaceAll]);
   FileName := StringReplace(ExtractFileName(DataName), '\', '/', [rfReplaceAll]);
   FileName := StringReplace(FileName, '//', '/', [rfReplaceAll]);
   FileName := StringReplace(FileName, '//', '/', [rfReplaceAll]);
-  
+
   PathInChm := '/'+ExtractFilePath(DataName);
   PathInChm := '/'+ExtractFilePath(DataName);
   if Assigned(FOnProgress) then FOnProgress(Self, DataName);
   if Assigned(FOnProgress) then FOnProgress(Self, DataName);
 end;
 end;
@@ -100,13 +102,28 @@ var
   IndexStream: TFileStream;
   IndexStream: TFileStream;
   TOCStream: TFileStream;
   TOCStream: TFileStream;
   Writer: TChmWriter;
   Writer: TChmWriter;
-  TOCSitemap: TChmSiteMap;
+  TOCSitemap  : TChmSiteMap;
+  IndexSiteMap: TChmSiteMap;
 begin
 begin
   // Assign the TOC and index files
   // Assign the TOC and index files
   Writer := TChmWriter(Sender);
   Writer := TChmWriter(Sender);
+  {$ifdef chmindex}
+    Writeln('binindex filename ',IndexFileName);
+  {$endif}
   if (IndexFileName <> '') and FileExists(IndexFileName) then begin
   if (IndexFileName <> '') and FileExists(IndexFileName) then begin
     IndexStream := TFileStream.Create(IndexFileName, fmOpenRead);
     IndexStream := TFileStream.Create(IndexFileName, fmOpenRead);
     Writer.AppendIndex(IndexStream);
     Writer.AppendIndex(IndexStream);
+    if MakeBinaryIndex then
+    begin
+      {$ifdef chmindex}
+        Writeln('into binindex ');
+      {$endif}
+      IndexStream.Position := 0;
+      IndexSitemap := TChmSiteMap.Create(stIndex);
+      indexSitemap.LoadFromStream(IndexStream);
+      Writer.AppendBinaryIndexFromSiteMap(IndexSitemap,False);
+      IndexSitemap.Free;	
+    end;
     IndexStream.Free;
     IndexStream.Free;
   end;
   end;
   if (TableOfContentsFileName <> '') and FileExists(TableOfContentsFileName) then begin
   if (TableOfContentsFileName <> '') and FileExists(TableOfContentsFileName) then begin
@@ -145,7 +162,7 @@ begin
   Cfg := TXMLConfig.Create(nil);
   Cfg := TXMLConfig.Create(nil);
   Cfg.Filename := AFileName;
   Cfg.Filename := AFileName;
   FileName := AFileName;
   FileName := AFileName;
-  
+
   Files.Clear;
   Files.Clear;
   FileCount := Cfg.GetValue('Files/Count/Value', 0);
   FileCount := Cfg.GetValue('Files/Count/Value', 0);
   for I := 0 to FileCount-1 do begin
   for I := 0 to FileCount-1 do begin
@@ -153,8 +170,9 @@ begin
   end;
   end;
   IndexFileName := Cfg.GetValue('Files/IndexFile/Value','');
   IndexFileName := Cfg.GetValue('Files/IndexFile/Value','');
   TableOfContentsFileName := Cfg.GetValue('Files/TOCFile/Value','');
   TableOfContentsFileName := Cfg.GetValue('Files/TOCFile/Value','');
+  // For chm file merging, bintoc must be false and binindex true. Change defaults in time?
   MakeBinaryTOC := Cfg.GetValue('Files/MakeBinaryTOC/Value', True);
   MakeBinaryTOC := Cfg.GetValue('Files/MakeBinaryTOC/Value', True);
-  
+  MakeBinaryIndex:= Cfg.GetValue('Files/MakeBinaryIndex/Value', False);
   AutoFollowLinks := Cfg.GetValue('Settings/AutoFollowLinks/Value', False);
   AutoFollowLinks := Cfg.GetValue('Settings/AutoFollowLinks/Value', False);
   MakeSearchable := Cfg.GetValue('Settings/MakeSearchable/Value', False);
   MakeSearchable := Cfg.GetValue('Settings/MakeSearchable/Value', False);
   DefaultPage := Cfg.GetValue('Settings/DefaultPage/Value', '');
   DefaultPage := Cfg.GetValue('Settings/DefaultPage/Value', '');
@@ -181,7 +199,7 @@ begin
   Cfg.SetValue('Files/IndexFile/Value', IndexFileName);
   Cfg.SetValue('Files/IndexFile/Value', IndexFileName);
   Cfg.SetValue('Files/TOCFile/Value', TableOfContentsFileName);
   Cfg.SetValue('Files/TOCFile/Value', TableOfContentsFileName);
   Cfg.SetValue('Files/MakeBinaryTOC/Value',MakeBinaryTOC);
   Cfg.SetValue('Files/MakeBinaryTOC/Value',MakeBinaryTOC);
-
+  Cfg.SetValue('Files/MakeBinaryIndex/Value',MakeBinaryIndex);
   Cfg.SetValue('Settings/AutoFollowLinks/Value', AutoFollowLinks);
   Cfg.SetValue('Settings/AutoFollowLinks/Value', AutoFollowLinks);
   Cfg.SetValue('Settings/MakeSearchable/Value', MakeSearchable);
   Cfg.SetValue('Settings/MakeSearchable/Value', MakeSearchable);
   Cfg.SetValue('Settings/DefaultPage/Value', DefaultPage);
   Cfg.SetValue('Settings/DefaultPage/Value', DefaultPage);
@@ -212,7 +230,7 @@ begin
   // our callback to get data
   // our callback to get data
   Writer.OnGetFileData := @GetData;
   Writer.OnGetFileData := @GetData;
   Writer.OnLastFile    := @LastFileAdded;
   Writer.OnLastFile    := @LastFileAdded;
-  
+
   // give it the list of files
   // give it the list of files
   Writer.FilesToCompress.AddStrings(Files);
   Writer.FilesToCompress.AddStrings(Files);
 
 
@@ -222,10 +240,11 @@ begin
   Writer.DefaultFont := DefaultFont;
   Writer.DefaultFont := DefaultFont;
   Writer.FullTextSearch := MakeSearchable;
   Writer.FullTextSearch := MakeSearchable;
   Writer.HasBinaryTOC := MakeBinaryTOC;
   Writer.HasBinaryTOC := MakeBinaryTOC;
-  
+  Writer.HasBinaryIndex := MakeBinaryIndex;
+
   // and write!
   // and write!
   Writer.Execute;
   Writer.Execute;
-  
+
   if Assigned(TOCStream) then TOCStream.Free;
   if Assigned(TOCStream) then TOCStream.Free;
   if Assigned(IndexStream) then IndexStream.Free;
   if Assigned(IndexStream) then IndexStream.Free;
 end;
 end;

+ 239 - 3
packages/chm/src/chmreader.pas

@@ -116,7 +116,8 @@ type
   public
   public
     function GetContextUrl(Context: THelpContext): String;
     function GetContextUrl(Context: THelpContext): String;
     function LookupTopicByID(ATopicID: Integer; out ATitle: String): String; // returns a url
     function LookupTopicByID(ATopicID: Integer; out ATitle: String): String; // returns a url
-    function GetTOCSitemap: TChmSiteMap;
+    function GetTOCSitemap(ForceXML:boolean=false): TChmSiteMap;
+    function GetIndexSitemap(ForceXML:boolean=false): TChmSiteMap;
     function HasContextList: Boolean;
     function HasContextList: Boolean;
     property DefaultPage: String read fDefaultPage;
     property DefaultPage: String read fDefaultPage;
     property IndexFile: String read fIndexFile;
     property IndexFile: String read fIndexFile;
@@ -875,7 +876,241 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TChmReader.GetTOCSitemap: TChmSiteMap;
+const DefBlockSize = 2048;
+
+function LoadBtreeHeader(m:TMemoryStream;var btreehdr:TBtreeHeader):boolean;
+
+begin
+  if m.size<sizeof(TBtreeHeader) Then
+    Exit(False);
+  result:=true;
+  m.read(btreeHdr,sizeof(TBtreeHeader));
+  {$IFDEF ENDIAN_BIG}
+     btreehdr.flags         :=LEToN(btreehdr.flags);
+     btreehdr.blocksize     :=LEToN(btreehdr.blocksize);
+     btreehdr.lastlstblock  :=LEToN(btreehdr.lastlstblock);
+     btreehdr.indexrootblock:=LEToN(btreehdr.indexrootblock);
+     btreehdr.nrblock       :=LEToN(btreehdr.nrblock);
+     btreehdr.treedepth     :=LEToN(btreehdr.treedepth);
+     btreehdr.nrkeywords    :=LEToN(btreehdr.nrkeywords);
+     btreehdr.codepage      :=LEToN(btreehdr.codepage);
+     btreehdr.lcid          :=LEToN(btreehdr.lcid);
+     btreehdr.ischm         :=LEToN(btreehdr.ischm);
+  {$endif}
+end;
+
+function readwcharstring(var head:pbyte;tail:pbyte;var readv : ansistring):boolean;
+
+var pw      : PWord;
+    oldhead : PByte;
+    ws      : WideString;
+    n       : Integer;
+begin
+  oldhead:=head;
+  pw:=pword(head);
+  while (pw<pword(tail)) and (pw^<>word(0)) do
+    inc(pw);
+  inc(pw); // skip #0#0.
+  head:=pbyte(pw);
+  result:=head<tail;
+
+  n:=head-oldhead;
+  setlength(ws,n div sizeof(widechar));
+  move(oldhead^,ws[1],n);
+  for n:=1 to length(ws) do
+    word(ws[n]):=LEToN(word(ws[n]));
+  readv:=ws; // force conversion for now, and hope it doesn't require cwstring
+end;
+
+function TChmReader.GetIndexSitemap(ForceXML:boolean=false): TChmSiteMap;
+var Index   : TMemoryStream;
+    sitemap : TChmSiteMap;
+    Item    : TChmSiteMapItem;
+    
+function  AbortAndTryTextual:tchmsitemap;
+
+begin
+     if Assigned(Index) Then Index.Free;
+     // Second Try text Index
+     Index := GetObject(IndexFile);
+     if Index <> nil then
+     begin
+       Result := TChmSiteMap.Create(stIndex);
+       Result.LoadFromStream(Index);
+       Index.Free;
+     end
+    else
+      result:=nil;
+end;
+
+procedure createentry(Name:ansistring;CharIndex:integer;Topic,Title:ansistring);
+var litem : TChmSiteMapItem;
+    shortname : ansistring;
+    longpart  : ansistring;
+begin
+ if charindex=0 then
+   begin
+     item:=sitemap.items.NewItem;
+     item.keyword:=Name;
+     item.local:=topic;
+     item.text:=title;
+   end
+ else
+   begin
+     shortname:=copy(name,1,charindex-2);
+     longpart:=copy(name,charindex,length(name)-charindex+1);
+     if assigned(item) and (shortname=item.text) then
+       begin
+         litem:=item.children.newitem;
+         litem.local:=topic;
+         litem.keyword :=longpart; // recursively split this? No examples.
+         litem.text:=title;
+       end
+      else
+       begin
+         item:=sitemap.items.NewItem;
+         item.keyword:=shortname;
+         item.local:=topic;
+         item.text:=title;
+         litem:=item.children.newitem;
+         litem.keyword:=longpart;
+         litem.local:=topic;
+         litem.text :=Title; // recursively split this? No examples.
+       end;
+   end;  
+end;
+
+procedure parselistingblock(p:pbyte);
+var hdr:PBTreeBlockHeader;
+    head,tail : pbyte;
+    isseealso,
+    nrpairs : Integer;
+    i : integer;
+    PE : PBtreeBlockEntry;
+    title : string;
+    CharIndex,
+    ind:integer;
+    seealsostr,
+    topic,
+    Name : AnsiString;
+    item : TChmSiteMapItem;
+begin
+  hdr:=PBTreeBlockHeader(p);
+  hdr^.Length          :=LEToN(hdr^.Length);
+  hdr^.NumberOfEntries :=LEToN(hdr^.NumberOfEntries);
+  hdr^.IndexOfPrevBlock:=LEToN(hdr^.IndexOfPrevBlock);
+  hdr^.IndexOfNextBlock:=LEToN(hdr^.IndexOfNextBlock);
+
+  tail:=p+(2048-hdr^.length);
+  head:=p+sizeof(TBtreeBlockHeader);
+  
+  {$ifdef binindex}
+  writeln('previndex  : ',hdr^.IndexOfPrevBlock);
+  writeln('nextindex  : ',hdr^.IndexOfNextBlock);
+  {$endif}
+  while head<tail do
+    begin
+      if not ReadWCharString(Head,Tail,Name) Then
+        Break;
+      {$ifdef binindex}
+         Writeln('name : ',name);
+      {$endif}
+       if (head+sizeof(TBtreeBlockEntry))>=tail then
+         break;
+      PE :=PBtreeBlockEntry(head);
+      NrPairs  :=LEToN(PE^.nrpairs);
+      IsSeealso:=LEToN(PE^.isseealso);
+      CharIndex:=LEToN(PE^.CharIndex);
+      {$ifdef binindex}
+        Writeln('seealso:     ',IsSeeAlso);
+        Writeln('entrydepth:  ',LEToN(PE^.entrydepth));
+        Writeln('charindex :  ',charindex );
+        Writeln('Nrpairs   :  ',NrPairs);
+        writeln('seealso data : ');
+      {$endif}
+
+      inc(head,sizeof(TBtreeBlockEntry));
+      if isseealso>0 then
+        begin
+          if not ReadWCharString(Head,Tail,SeeAlsoStr) Then
+            Break;
+          // have to figure out first what to do with it.
+        end
+      else
+        begin
+         if NrPairs>0 Then
+            for i:=0 to nrpairs-1 do
+              begin
+                if head<tail Then
+                  begin
+                    ind:=LEToN(plongint(head)^);
+                    topic:=lookuptopicbyid(ind,title);
+                    {$ifdef binindex}
+                      writeln(i:3,' topic: ',topic);
+                      writeln('    title: ',title);
+                    {$endif}
+                    inc(head,4);
+                  end;
+              end;
+          end;
+      if nrpairs<>0 Then
+        createentry(Name,CharIndex,Topic,Title);
+      inc(head,4); // always 1
+      {$ifdef binindex}
+        if head<tail then
+        writeln('Zero based index (13 higher than last) :',plongint(head)^);
+      {$endif}
+      inc(head,4); // zero based index (13 higher than last
+    end;
+end;
+
+var TryTextual : boolean;
+    BHdr       : TBTreeHeader;
+    block      : Array[0..2047] of Byte;
+    i          : Integer;
+begin
+   Result := nil;  SiteMap:=Nil;
+   // First Try Binary
+   Index := GetObject('/$WWKeywordLinks/BTree');
+   if (Index = nil) or ForceXML then
+   begin
+     Result:=AbortAndTryTextual;
+     Exit;
+   end;
+   if not CheckCommonStreams then
+   begin
+     Result:=AbortAndTryTextual;
+     Exit;
+   end;
+   SiteMap:=TChmSitemap.Create(StIndex);
+   Item   :=Nil;  // cached last created item, in case we need to make 
+                  // a child.
+   TryTextual:=True;
+   BHdr.LastLstBlock:=0;
+   if LoadBtreeHeader(index,BHdr) and (BHdr.LastLstBlock>0) Then
+    begin 
+       if BHdr.BlockSize=defblocksize then
+         begin
+           for i:=0 to BHdr.lastlstblock do
+             begin
+               if (index.size-index.position)>=defblocksize then
+                 begin
+                   Index.read(block,defblocksize);
+                   parselistingblock(@block)
+                end;
+             end;
+            trytextual:=false;
+            result:=sitemap; 
+          end;   
+    end;
+  if trytextual then
+    begin
+      sitemap.free;
+      Result:=AbortAndTryTextual;
+    end;
+end;
+
+function TChmReader.GetTOCSitemap(ForceXML:boolean=false): TChmSiteMap;
     function AddTOCItem(TOC: TStream; AItemOffset: DWord; SiteMapITems: TChmSiteMapItems): DWord;
     function AddTOCItem(TOC: TStream; AItemOffset: DWord; SiteMapITems: TChmSiteMapItems): DWord;
     var
     var
       Props: DWord;
       Props: DWord;
@@ -919,8 +1154,9 @@ begin
    Result := nil;
    Result := nil;
    // First Try Binary
    // First Try Binary
    TOC := GetObject('/#TOCIDX');
    TOC := GetObject('/#TOCIDX');
-   if TOC = nil then
+   if (TOC = nil) or ForceXML then
    begin
    begin
+     if Assigned(TOC) Then Toc.Free;
      // Second Try text toc
      // Second Try text toc
      TOC := GetObject(TOCFile);
      TOC := GetObject(TOCFile);
      if TOC <> nil then
      if TOC <> nil then

+ 61 - 9
packages/chm/src/chmtypes.pas

@@ -25,13 +25,13 @@ unit chmtypes;
 interface
 interface
 
 
 uses
 uses
-  Classes, SysUtils; 
-  
+  Classes, SysUtils;
+
 type
 type
   TSectionName = (snMSCompressed, snUnCompressed);
   TSectionName = (snMSCompressed, snUnCompressed);
-  
+
   TSectionNames = set of TSectionName;
   TSectionNames = set of TSectionName;
-  
+
    { TDirectoryChunk }
    { TDirectoryChunk }
 
 
   TDirectoryChunk = class(TObject)
   TDirectoryChunk = class(TObject)
@@ -52,7 +52,7 @@ type
     property ItemCount: Word read FItemCount;
     property ItemCount: Word read FItemCount;
     constructor Create(AHeaderSize: Integer);
     constructor Create(AHeaderSize: Integer);
   end;
   end;
-  
+
   { TPMGIDirectoryChunk }
   { TPMGIDirectoryChunk }
 
 
   TPMGIDirectoryChunk = class(TDirectoryChunk)
   TPMGIDirectoryChunk = class(TDirectoryChunk)
@@ -134,8 +134,60 @@ type
     Unknown: Word; // 0,2,4,8,10,12,16,32
     Unknown: Word; // 0,2,4,8,10,12,16,32
   end;
   end;
 
 
+  TBtreeHeader = packed record
+                        ident          : array[0..1] of ansichar; // $3B $29
+                        flags          : word;	// bit $2 is always 1, bit $0400 1 if dir? (always on)
+                        blocksize      : word;  // size of blocks (2048)
+                        dataformat     : array[0..15] of ansichar;  // "X44" always the same, see specs.
+                        unknown0       : dword; // always 0
+			lastlstblock   : dword; // index of last listing block in the file;
+                        indexrootblock : dword; // Index of the root block in the file.
+                        unknown1       : dword; // always -1
+                        nrblock	       : dword; // Number of blocks
+                        treedepth      : word;  // The depth of the tree of blocks (1 if no index blocks, 2 one level of index blocks, ...)
+                        nrkeywords     : dword; // number of keywords in the file.
+                        codepage       : dword; // Windows code page identifier (usually 1252 - Windows 3.1 US (ANSI))
+			lcid	       : dword; // LCID from the HHP file.
+                        ischm	       : dword; // 0 if this a BTREE and is part of a CHW file, 1 if it is a BTree and is part of a CHI or CHM file
+                        unknown2       : dword; // Unknown. Almost always 10031. Also 66631 (accessib.chm, ieeula.chm, iesupp.chm, iexplore.chm, msoe.chm, mstask.chm, ratings.chm, wab.chm).
+                        unknown3       : dword; // unknown 0
+		        unknown4       : dword; // unknown 0
+			unknown5       : dword; // unknown 0
+                      end;
+  PBTreeBlockHeader = ^TBtreeBlockHeader;
+  TBtreeBlockHeader = packed record
+                        Length             : word;  // Length of free space at the end of the block.
+                        NumberOfEntries    : word;  // Number of entries in the block.
+                        IndexOfPrevBlock   : dword; // Index of the previous block. -1 if this is the first listing block.
+                        IndexOfNextBlock   : dword; // Index of the next block. -1 if this is the last listing block.
+                      end;
+
+  PBtreeBlockEntry = ^TBtreeBlockEntry;
+  TBtreeBlockEntry = packed record
+                        isseealso  : word; // 2 if this keyword is a See Also keyword, 0 if it is not.
+                        entrydepth : word; // Depth of this entry into the tree.
+                        charindex  : dword;// Character index of the last keyword in the ", " separated list.
+                        unknown0   : dword;// 0 (unknown)
+                        NrPairs    : dword;// Number of Name, Local pairs
+                      end;
+
+  PBtreeIndexBlockHeader = ^TBtreeIndexBlockHeader;
+  TBtreeIndexBlockHeader = packed record
+                        length             : word;  // Length of free space at the end of the block.
+                        NumberOfEntries    : word;  // Number of entries in the block.
+                        IndexOfChildBlock  : dword; // Index of Child Block
+                      end;
+
+  PBtreeIndexBlockEntry = ^TBtreeIndexBlockEntry;
+  TBtreeIndexBlockEntry = packed record
+                        isseealso  : word; // 2 if this keyword is a See Also keyword, 0 if it is not.
+                        entrydepth : word; // Depth of this entry into the tree.
+                        charindex  : dword;// Character index of the last keyword in the ", " separated list.
+                        unknown0   : dword;// 0 (unknown)
+                        NrPairs    : dword;// Number of Name, Local pairs
+                      end;
 
 
-  function PageBookInfoRecordSize(ARecord: PTOCEntryPageBookInfo): Integer;
+function PageBookInfoRecordSize(ARecord: PTOCEntryPageBookInfo): Integer;
 
 
 implementation
 implementation
 uses chmbase;
 uses chmbase;
@@ -174,7 +226,7 @@ begin
   Move(Data^, Buffer[CurrentPos], Size);
   Move(Data^, Buffer[CurrentPos], Size);
   Inc(CurrentPos, Size);
   Inc(CurrentPos, Size);
   Inc(FItemCount);
   Inc(FItemCount);
-  
+
   // now put a quickref entry if needed
   // now put a quickref entry if needed
   if ItemCount mod 5 = 0 then begin
   if ItemCount mod 5 = 0 then begin
     Inc(FQuickRefEntries);
     Inc(FQuickRefEntries);
@@ -312,7 +364,7 @@ begin
   WriteChunkToStream(Stream);
   WriteChunkToStream(Stream);
   NewPos := Stream.Position;
   NewPos := Stream.Position;
   Inc(FChunkLevelCount);
   Inc(FChunkLevelCount);
-  
+
   if Final and (ChunkLevelCount < 2) then begin
   if Final and (ChunkLevelCount < 2) then begin
     FParentChunk.Free;
     FParentChunk.Free;
     FParentChunk := nil;
     FParentChunk := nil;
@@ -332,7 +384,7 @@ begin
   if not FParentChunk.CanHold(WriteSize) then begin
   if not FParentChunk.CanHold(WriteSize) then begin
     FinishBlock;
     FinishBlock;
   end;
   end;
-  
+
   FParentChunk.WriteEntry(WriteSize, @NewBuffer[0]);
   FParentChunk.WriteEntry(WriteSize, @NewBuffer[0]);
   if Final then FinishBlock;
   if Final then FinishBlock;
   //WriteLn(ChunkLevelCount);
   //WriteLn(ChunkLevelCount);

File diff suppressed because it is too large
+ 629 - 38
packages/chm/src/chmwriter.pas


+ 529 - 0
packages/chm/src/lzxcompressthread.pas

@@ -0,0 +1,529 @@
+{ Copyright (C) <2009> <Andrew Haines> lzxcompressthread.pas
+
+  This library is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Library General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or (at your
+  option) any later version.
+
+  This program is distributed in the hope that it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+  for more details.
+
+  You should have received a copy of the GNU Library General Public License
+  along with this library; if not, write to the Free Software Foundation,
+  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+}
+{
+  See the file COPYING.FPC, included in this distribution,
+  for details about the copyright.
+}
+unit lzxcompressthread;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes, paslzxcomp;
+
+type
+  TLZXCompressor = class;
+  TLZXMasterThread = class;
+  TLZXWorkerThread = class;
+
+  TLZXGetDataMethod = function(Sender: TLZXCompressor; WantedByteCount: Integer; Buffer: Pointer): Integer of object;
+  TLZXIsEndOfFileMethod = function(Sender: TLZXCompressor): Boolean  of object;
+  TLZXChunkDoneMethod = procedure(Sender: TLZXCompressor; CompressedSize: Integer; UncompressedSize: Integer; Buffer: Pointer) of object;
+  TLZXMarkFrameMethod = procedure(Sender: TLZXCompressor; CompressedSize: Integer; UncompressedSize: Integer) of object;
+
+  PLZXFinishedBlock = ^TLZXFinishedBlock;
+  TLZXFinishedBlock = record
+    CompressedSize: Integer;
+    UnCompressedSize: Integer;
+    Frame1CSize,
+    Frame1USize,
+    Frame2CSize,
+    Frame2USize: Integer;
+    Index: Integer;
+    Data: Pointer;
+  end;
+
+  { TLZXCompressor }
+
+  TLZXCompressor = class(TObject)
+  private
+    FOnMarkFrame: TLZXMarkFrameMethod;
+    FThreadCount: Integer;
+    FBlockSize: Integer;
+    FTotalCompressedSize: DWord;
+    FTotalUnCompressedSize: DWord;
+    FOnChunkDone: TLZXChunkDoneMethod;
+    FOnGetData: TLZXGetDataMethod;
+    FOnIsEndOfFile: TLZXIsEndOfFileMethod;
+    FWindowSizeCode: Integer;
+    FinishedBlocks: TFPList;
+    NextBlockNeeded: Integer;
+    FMasterThread: TLZXMasterThread;
+    procedure BlockIsFinished(ABlock: PLZXFinishedBlock);
+    function GetRunning: Boolean;
+  public
+    constructor Create(AThreadCount: Integer);
+    destructor  Destroy; override;
+
+    procedure   Execute(WaitForFinish: Boolean = True);
+
+    property BlockSize: Integer read FBlockSize write FBlockSize;
+    property Running: Boolean read GetRunning;
+    property WindowSizeCode: Integer read FWindowSizeCode write FWindowSizeCode;
+
+    // the following properties must all be assigned
+    property OnGetData: TLZXGetDataMethod read FOnGetData write FOnGetData;
+    property OnChunkDone: TLZXChunkDoneMethod read FOnChunkDone write FOnChunkDone;
+    property OnIsEndOfFile: TLZXIsEndOfFileMethod read FOnIsEndOfFile write FOnIsEndOfFile;
+    property OnMarkFrame: TLZXMarkFrameMethod read FOnMarkFrame write FOnMarkFrame;
+  end;
+
+  { TLZXMasterThread }
+
+  TLZXMasterThread = class(TThread)
+    FCompressor: TLZXCompressor;
+    FBusyThreads: TFPList;
+    FLockData: TRTLCriticalSection;
+    FLockQueueThread: TRTLCriticalSection;
+    FDataRemains: Boolean;
+    FBlockNumber: Integer;
+    FRunning: Boolean;
+    FMemList: TFPList;
+
+    // only used inside a critical section!!
+    // belongs to a Worker thread which will free it
+    FTmpData: Pointer;
+    FTmpDataSize: Integer;
+
+    procedure UpdateDataRemains;
+
+    function  BlockDone(Worker: TLZXWorkerThread; ABlock: PLZXFinishedBlock): Boolean;
+    procedure WorkerFinished(Sender: TObject);
+    function GetFreeMemoryChunk: Pointer;
+
+
+    procedure Lock;
+    Procedure UnLock;
+    procedure LockTmpData;
+    procedure UnLockTmpData;
+    function Working: Boolean;
+    function DataRemains: Boolean;
+    function Running: Boolean;
+    function QueueThread(Thread: TLZXWorkerThread): Boolean;
+
+  public
+    procedure   Execute; override;
+    constructor Create(Compressor: TLZXCompressor);
+    destructor  Destroy; override;
+  end;
+
+  { TLZXWorkerThread }
+
+  TLZXWorkerThread = class(TThread)
+  private
+    Data: PByte;
+    DataSize: Integer;
+    DataCursor: Integer;
+    Frame1C,
+    Frame1U,
+    Frame2C,
+    Frame2U: Integer;
+
+    LZXData: Plzx_data;
+
+    CompressedData: PByte;
+    CompressedDataSize: Integer; // compressed written size. not the size of the array
+
+    BlockNumber: Integer;
+
+    WindowSizeCode: Integer;
+    BlockSize: Integer;
+
+    MasterThread: TLZXMasterThread;
+    ShouldSuspend: Boolean;
+
+    // callbacks for lzxcomp
+    function    GetBytes(ACount: Longint; ABuffer: Pointer): LongInt; cdecl;
+    function    WriteBytes(ACount: LongInt; ABuffer: Pointer): LongInt; cdecl;
+    procedure   MarkFrame(UnCompressedSize: DWord; CompressedSize: DWord); cdecl;
+    function    IsEndOfFile: LongBool; cdecl;
+    // end callbacks
+    procedure   NotifyMasterDone;
+  protected
+    procedure   Execute; override;
+  public
+    procedure   CompressData(ABlockNumber: Integer);
+
+    constructor Create(AMaster: TLZXMasterThread; AWindowSizeCode: Integer; ABlockSize: Integer);
+    destructor  Destroy; override;
+  end;
+
+implementation
+uses
+  Sysutils; // for Sleep()
+
+{ TLZXCompressor }
+
+procedure TLZXCompressor.BlockIsFinished(ABlock: PLZXFinishedBlock);
+  procedure SendChunk(AChunk: PLZXFinishedBlock);
+  begin
+    if Assigned(FOnMarkFrame) then
+    begin
+      Inc(FTotalCompressedSize, AChunk^.Frame1CSize);
+      Inc(FTotalUnCompressedSize, AChunk^.Frame1USize);
+      Inc(NextBlockNeeded);
+
+      FOnMarkFrame(Self, FTotalCompressedSize, FTotalUnCompressedSize);
+
+      if AChunk^.Frame2CSize > 0 then
+      begin
+        Inc(FTotalCompressedSize, AChunk^.Frame2CSize);
+        Inc(FTotalUnCompressedSize, AChunk^.Frame2USize);
+        FOnMarkFrame(Self, FTotalCompressedSize, FTotalUnCompressedSize);
+      end;
+    end;
+
+    FOnChunkDone(Self, AChunk^.CompressedSize, AChunk^.UnCompressedSize, AChunk^.Data);
+    FMasterThread.FMemList.Add(AChunk^.Data);
+    Dispose(AChunk);
+  end;
+var
+  TmpBlock  : PLZXFinishedBlock;
+  FoundMatch: Boolean;
+  i: Integer;
+
+begin
+  if NextBlockNeeded = ABlock^.Index then
+    SendChunk(ABlock)
+  else
+    FinishedBlocks.Add(ABlock);
+
+  repeat
+    FoundMatch := False;
+    for i := FinishedBlocks.Count-1 downto 0 do
+    begin
+      TmpBlock := PLZXFinishedBlock(FinishedBlocks.Items[i]);
+      if TmpBlock^.Index = NextBlockNeeded then
+      begin
+        FoundMatch := True;
+        SendChunk(TmpBlock);
+        FinishedBlocks.Delete(i);
+      end;
+    end;
+  until not FoundMatch;
+end;
+
+function TLZXCompressor.GetRunning: Boolean;
+begin
+  Result := FMasterThread.Running;
+end;
+
+constructor TLZXCompressor.Create(AThreadCount: Integer);
+begin
+  inherited Create;
+  FThreadCount    := AThreadCount;
+  FBlockSize      := 1 shl 16 ; // $10000;
+  FWindowSizeCode := 16;
+  FMasterThread := TLZXMasterThread.Create(Self);
+  FinishedBlocks := TFPList.Create;
+end;
+
+destructor TLZXCompressor.Destroy;
+begin
+  FMasterThread.Free;
+  FinishedBlocks.Free;
+  inherited Destroy;
+end;
+
+procedure TLZXCompressor.Execute(WaitForFinish: Boolean = True);
+begin
+    FTotalCompressedSize := 0;
+    FTotalUnCompressedSize := 0;
+    FMasterThread.FRunning:=True;
+    FMasterThread.Resume;
+    if WaitForFinish then
+      While Running do
+        CheckSynchronize(50);
+end;
+
+{ TLZXMasterThread }
+
+procedure TLZXMasterThread.UpdateDataRemains;
+begin
+  FDataRemains := not FCompressor.FOnIsEndOfFile(FCompressor);
+end;
+
+function TLZXMasterThread.BlockDone(Worker: TLZXWorkerThread; ABlock: PLZXFinishedBlock): Boolean;
+begin
+  Lock;
+  REsult := True;
+  FCompressor.BlockIsFinished(ABlock);
+  if DataRemains then
+    QueueThread(Worker)
+  else
+  begin
+    Result := False;
+    FBusyThreads.Remove(Worker);
+    Worker.Terminate;
+    if FBusyThreads.Count = 0 then
+      Resume;
+  end;
+  Unlock;
+end;
+
+procedure TLZXMasterThread.WorkerFinished(Sender: TObject);
+begin
+  FBusyThreads.Remove(Sender);
+  if TThread(Sender).FatalException <> nil then
+    Raise Exception(TThread(Sender).FatalException);
+  Sender.Free;
+end;
+
+function TLZXMasterThread.GetFreeMemoryChunk: Pointer;
+begin
+  if FMemList.Count >0 then
+  begin
+    Result := FMemList.Items[0];
+    FMemList.Delete(0);
+  end
+  else
+    Result := Getmem(FCompressor.BlockSize);
+end;
+
+procedure TLZXMasterThread.Lock;
+begin
+  EnterCriticalsection(FLockData);
+end;
+
+procedure TLZXMasterThread.UnLock;
+begin
+  LeaveCriticalsection(FLockData);
+end;
+
+procedure TLZXMasterThread.LockTmpData;
+begin
+  EnterCriticalsection(FLockQueueThread);
+end;
+
+procedure TLZXMasterThread.UnLockTmpData;
+begin
+  LeaveCriticalsection(FLockQueueThread);
+end;
+
+function TLZXMasterThread.Working: Boolean;
+begin
+  Result := FBusyThreads.Count > 0;
+end;
+
+function TLZXMasterThread.DataRemains: Boolean;
+begin
+  UpdateDataRemains;
+  Result := FDataRemains;
+end;
+
+function TLZXMasterThread.Running: Boolean;
+begin
+  REsult := FRunning;
+end;
+
+function TLZXMasterThread.QueueThread(Thread: TLZXWorkerThread): Boolean;
+begin
+  LockTmpData;
+
+  Result := DataRemains;
+  if Not Result then
+  begin
+    UnLockTmpData;
+    Exit;
+  end;
+
+  FDataRemains := False;
+
+  Thread.DataSize := FCompressor.OnGetData(FCompressor, FCompressor.FBlockSize, Thread.Data);
+
+  Thread.CompressData(FBlockNumber);
+  Inc(FBlockNumber);
+  Thread.Resume;
+  UnLockTmpData;
+end;
+
+procedure TLZXMasterThread.Execute;
+var
+  i: Integer;
+  Thread: TLZXWorkerThread;
+begin
+  FRunning:= True;
+  for i := 0 to FCompressor.FThreadCount-1 do
+  begin
+    Thread := TLZXWorkerThread.Create(Self, FCompressor.WindowSizeCode, FCompressor.BlockSize);
+    Thread.FreeOnTerminate := True;
+    Thread.OnTerminate:= @WorkerFinished;
+    if QueueThread(Thread) then
+      FBusyThreads.Add(Thread);
+  end;
+  //Suspend;
+  while Working do
+  begin
+      Sleep(50);
+  end;
+  FRunning:= False;
+end;
+
+constructor TLZXMasterThread.Create(Compressor: TLZXCompressor);
+begin
+  Inherited Create(True);
+  FCompressor  := Compressor;
+  FDataRemains := True;
+  FBusyThreads := TFPList.Create;
+  FMemList := TFPList.Create;
+  InitCriticalSection(FLockData);
+  InitCriticalSection(FLockQueueThread);
+end;
+
+destructor TLZXMasterThread.Destroy;
+var
+  i: Integer;
+begin
+  DoneCriticalsection(FLockData);
+  DoneCriticalsection(FLockQueueThread);
+
+  for i := 0 to FBusyThreads.Count-1 do TObject(FBusyThreads.Items[i]).Free;
+  for i := 0 to FMemList.Count-1 do Freemem(FMemList.Items[i]);
+
+  FBusyThreads.Free;
+  FMemList.Free;
+
+  inherited Destroy;
+end;
+
+{ TLZXWorkerThread }
+
+function TLZXWorkerThread.GetBytes(ACount: Longint; ABuffer: Pointer): LongInt; cdecl;
+var
+  MaxBytes: Integer;
+begin
+  MaxBytes := DataSize - DataCursor;
+
+  if ACount > MaxBytes then
+    ACount := MaxBytes;
+
+  Move(Data[DataCursor], ABuffer^, ACount);
+  Inc(DataCursor, ACount);
+
+  Result := ACount;
+end;
+
+function TLZXWorkerThread.WriteBytes(ACount: LongInt; ABuffer: Pointer
+  ): LongInt; cdecl;
+begin
+  Move(ABuffer^, CompressedData[CompressedDataSize], ACount);
+  Inc(CompressedDataSize, ACount);
+  Result := ACount;
+end;
+
+procedure TLZXWorkerThread.MarkFrame(UnCompressedSize: DWord;
+  CompressedSize: DWord); cdecl;
+begin
+  if Frame1C = 0 then
+  begin
+    Frame1C := CompressedSize;
+    Frame1U := UnCompressedSize;
+  end
+  else
+  begin
+    Frame2C := CompressedSize;
+    Frame2U := UnCompressedSize;
+  end;
+end;
+
+function TLZXWorkerThread.IsEndOfFile: LongBool; cdecl;
+begin
+  Result := LongBool(DataSize - DataCursor <= 0);
+end;
+
+procedure TLZXWorkerThread.NotifyMasterDone;
+var
+  Block: PLZXFinishedBlock;
+begin
+  LZXData^.len_compressed_output:=0;
+  LZXData^.len_uncompressed_input:=0;
+
+  New(Block);
+  Block^.Data            :=  MasterThread.GetFreeMemoryChunk;
+  Move(CompressedData^, Block^.Data^, CompressedDataSize);
+  Block^.CompressedSize  := CompressedDataSize;
+  Block^.UnCompressedSize:= DataSize;
+  Block^.Index           := BlockNumber;
+  Block^.Frame1CSize      := Frame1C;
+  Block^.Frame2CSize      := Frame2C-Frame1C;
+  Block^.Frame1USize      := Frame1U;
+  Block^.Frame2USize      := Frame2U-Frame1U;
+
+  Frame1C := 0;
+  Frame2C := 0;
+  Frame1U := 0;
+  Frame2U := 0;
+
+  ShouldSuspend := not MasterThread.BlockDone(Self, Block);
+
+end;
+
+procedure TLZXWorkerThread.CompressData(ABlockNumber: Integer);
+begin
+  BlockNumber := ABlockNumber;
+  DataCursor := 0;
+  CompressedDataSize := 0;
+end;
+
+procedure TLZXWorkerThread.Execute;
+var
+  WSize: LongInt;
+begin
+  WSize := 1 shl WindowSizeCode;
+  while not Terminated do
+  begin
+    lzx_reset(LZXdata);
+    lzx_compress_block(LZXdata, WSize, True);
+
+    MasterThread.Synchronize(@NotifyMasterDone);
+
+    if ShouldSuspend then
+      Suspend;
+  end;
+end;
+
+constructor TLZXWorkerThread.Create(AMaster: TLZXMasterThread;
+  AWindowSizeCode: Integer; ABlockSize: Integer);
+begin
+  Inherited Create(True);
+  MasterThread := AMaster;
+  WindowSizeCode := AWindowSizeCode;
+  BlockSize     := ABlockSize;
+  FreeOnTerminate := True;
+
+  Data  := GetMem(ABlockSize);
+  CompressedData:=GetMem(ABlockSize);
+
+  lzx_init(@LZXdata, longint(WindowSizeCode),
+           TGetBytesFunc(@TLZXWorkerThread.GetBytes), Self,
+           TIsEndOfFileFunc(@TLZXWorkerThread.IsEndOfFile),
+           TWriteBytesFunc(@TLZXWorkerThread.WriteBytes), Self,
+           TMarkFrameFunc(@TLZXWorkerThread.MarkFrame), Self);
+end;
+
+destructor TLZXWorkerThread.Destroy;
+begin
+  lzx_finish(LZXdata, nil);
+  Freemem(Data);
+  FreeMem(CompressedData);
+  inherited Destroy;
+end;
+
+end.
+

+ 10 - 9
packages/chm/src/paslzxcomp.pas

@@ -710,11 +710,11 @@ begin
     end
     end
     else begin
     else begin
       mask_bits := (1 shl shift_bits) - 1;
       mask_bits := (1 shl shift_bits) - 1;
-      lzxd^.bit_buf := lzxd^.bit_buf shl shift_bits;
-      lzxd^.bit_buf := lzxd^.bit_buf or (bits shr rshift_bits) and mask_bits;
+      lzxd^.bit_buf := word(lzxd^.bit_buf shl shift_bits);
+      lzxd^.bit_buf := word(lzxd^.bit_buf or (bits shr rshift_bits) and mask_bits);
     end;
     end;
 {$IFDEF ENDIAN_BIG}
 {$IFDEF ENDIAN_BIG}
-    lzxd^.bit_buf := ((lzxd^.bit_buf and $FF)shl 8) or (lzxd^.bit_buf shr 8);
+    lzxd^.bit_buf := word(((lzxd^.bit_buf and $FF)shl 8) or (lzxd^.bit_buf shr 8));
 {$ENDIF}
 {$ENDIF}
     lzxd^.put_bytes(lzxd^.out_arg, sizeof(lzxd^.bit_buf), @lzxd^.bit_buf);
     lzxd^.put_bytes(lzxd^.out_arg, sizeof(lzxd^.bit_buf), @lzxd^.bit_buf);
     Inc(lzxd^.len_compressed_output, sizeof(lzxd^.bit_buf));
     Inc(lzxd^.len_compressed_output, sizeof(lzxd^.bit_buf));
@@ -726,8 +726,8 @@ begin
   //   otherwise move bits in */
   //   otherwise move bits in */
   shift_bits := nbits;
   shift_bits := nbits;
   mask_bits := (1 shl shift_bits) - 1;
   mask_bits := (1 shl shift_bits) - 1;
-  lzxd^.bit_buf := lzxd^.bit_buf shl shift_bits;
-  lzxd^.bit_buf := lzxd^.bit_buf or bits and mask_bits;
+  lzxd^.bit_buf := word(lzxd^.bit_buf shl shift_bits);
+  lzxd^.bit_buf := word(lzxd^.bit_buf or bits and mask_bits);
   Inc(cur_bits, nbits);
   Inc(cur_bits, nbits);
 
 
   lzxd^.bits_in_buf := cur_bits;
   lzxd^.bits_in_buf := cur_bits;
@@ -892,8 +892,8 @@ begin
 	  Inc(freqs[19]);
 	  Inc(freqs[19]);
 	  //* right, MS lies again.  Code is NOT
 	  //* right, MS lies again.  Code is NOT
 	  //   prev_len + len (mod 17), it's prev_len - len (mod 17)*/
 	  //   prev_len + len (mod 17), it's prev_len - len (mod 17)*/
-	  codep^ := prevlengths[i-cur_run] - last_len;
-	  if (codep^ > 16) then Inc(codep^, 17);
+	  codep^ := byte(prevlengths[i-cur_run] - last_len);
+	  if (codep^ > 16) then codep^ := byte(codep^ + 17); //Inc(codep^, 17);
 	  Inc(freqs[codep^]);
 	  Inc(freqs[codep^]);
           Inc(codep);
           Inc(codep);
 	  runp^ := 0; //* not necessary */
 	  runp^ := 0; //* not necessary */
@@ -901,8 +901,8 @@ begin
 	  Dec(cur_run, excess+4);
 	  Dec(cur_run, excess+4);
         end;
         end;
 	while (cur_run > 0) do begin
 	while (cur_run > 0) do begin
-	  codep^ := prevlengths[i-cur_run] - last_len;
-	  if (codep^ > 16) then Inc(codep^, 17);
+	  codep^ := byte(prevlengths[i-cur_run] - last_len);
+	  if (codep^ > 16) then codep^ := byte(codep^ + 17); //Inc(codep^, byte(17));
 	  runp^ := 0; //* not necessary */
 	  runp^ := 0; //* not necessary */
           Inc(runp);
           Inc(runp);
 	  Dec(cur_run);
 	  Dec(cur_run);
@@ -1151,6 +1151,7 @@ begin
   freemem(lzxd^.prev_main_treelengths);
   freemem(lzxd^.prev_main_treelengths);
   freemem(lzxd^.main_tree);
   freemem(lzxd^.main_tree);
   freemem(lzxd^.main_freq_table);
   freemem(lzxd^.main_freq_table);
+  freemem(lzxd^.block_codes);
   dispose(lzxd);
   dispose(lzxd);
   Exit(0);
   Exit(0);
 end;
 end;

+ 59 - 59
utils/fpdoc/Makefile

@@ -1,5 +1,5 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/08/02]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/10/10]
 #
 #
 default: all
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
@@ -441,178 +441,178 @@ ifeq ($(FULL_TARGET),armeb-embedded)
 override TARGET_PROGRAMS+=fpdoc makeskel unitdiff fpclasschart
 override TARGET_PROGRAMS+=fpdoc makeskel unitdiff fpclasschart
 endif
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 ifeq ($(FULL_TARGET),i386-go32v2)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 ifeq ($(FULL_TARGET),i386-win32)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 ifeq ($(FULL_TARGET),i386-os2)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 ifeq ($(FULL_TARGET),i386-freebsd)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 ifeq ($(FULL_TARGET),i386-beos)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-haiku)
 ifeq ($(FULL_TARGET),i386-haiku)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 ifeq ($(FULL_TARGET),i386-netbsd)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 ifeq ($(FULL_TARGET),i386-solaris)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 ifeq ($(FULL_TARGET),i386-qnx)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netware)
 ifeq ($(FULL_TARGET),i386-netware)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 ifeq ($(FULL_TARGET),i386-openbsd)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 ifeq ($(FULL_TARGET),i386-wdosx)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 ifeq ($(FULL_TARGET),i386-darwin)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 ifeq ($(FULL_TARGET),i386-emx)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
 ifeq ($(FULL_TARGET),i386-watcom)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 ifeq ($(FULL_TARGET),i386-wince)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
 ifeq ($(FULL_TARGET),i386-embedded)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 ifeq ($(FULL_TARGET),m68k-amiga)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
 ifeq ($(FULL_TARGET),m68k-atari)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 ifeq ($(FULL_TARGET),m68k-palmos)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
 ifeq ($(FULL_TARGET),m68k-embedded)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 ifeq ($(FULL_TARGET),powerpc-linux)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 ifeq ($(FULL_TARGET),powerpc-amiga)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 ifeq ($(FULL_TARGET),powerpc-macos)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 ifeq ($(FULL_TARGET),sparc-solaris)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
 ifeq ($(FULL_TARGET),sparc-embedded)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 ifeq ($(FULL_TARGET),x86_64-linux)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 ifeq ($(FULL_TARGET),x86_64-darwin)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 ifeq ($(FULL_TARGET),x86_64-win64)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 ifeq ($(FULL_TARGET),x86_64-embedded)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 ifeq ($(FULL_TARGET),arm-linux)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 ifeq ($(FULL_TARGET),arm-palmos)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),arm-darwin)
 ifeq ($(FULL_TARGET),arm-darwin)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),arm-wince)
 ifeq ($(FULL_TARGET),arm-wince)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),arm-gba)
 ifeq ($(FULL_TARGET),arm-gba)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),arm-nds)
 ifeq ($(FULL_TARGET),arm-nds)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
 ifeq ($(FULL_TARGET),arm-embedded)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
 ifeq ($(FULL_TARGET),arm-symbian)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
 ifeq ($(FULL_TARGET),powerpc64-darwin)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 ifeq ($(FULL_TARGET),powerpc64-embedded)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),avr-embedded)
 ifeq ($(FULL_TARGET),avr-embedded)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),armeb-linux)
 ifeq ($(FULL_TARGET),armeb-linux)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 ifeq ($(FULL_TARGET),armeb-embedded)
-override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+override CLEAN_UNITS+=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf
 endif
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
 override CLEAN_FILES+=dwriter.rst fpdoc.rst dglobals.rst makeskel.rst
 override CLEAN_FILES+=dwriter.rst fpdoc.rst dglobals.rst makeskel.rst

+ 1 - 1
utils/fpdoc/Makefile.fpc

@@ -26,7 +26,7 @@ fpcpackage=y
 fpcdir=../..
 fpcdir=../..
 
 
 [clean]
 [clean]
-units=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man
+units=dglobals dwriter dw_xml sh_pas dw_html dw_latex dw_ipf dw_txt dw_man dwlinear dw_linrtf 
 files=dwriter.rst fpdoc.rst dglobals.rst makeskel.rst
 files=dwriter.rst fpdoc.rst dglobals.rst makeskel.rst
 
 
 [rules]
 [rules]

+ 19 - 3
utils/fpdoc/dw_htmlchm.inc

@@ -15,6 +15,8 @@ type
     FDefaultPage: String;
     FDefaultPage: String;
     FCSSFile: String;
     FCSSFile: String;
     FMakeSearchable,
     FMakeSearchable,
+    FNoBinToc,
+    FNoBinIndex,
     FAutoTOC,
     FAutoTOC,
     FAutoIndex: Boolean;
     FAutoIndex: Boolean;
     FOtherFiles: String;
     FOtherFiles: String;
@@ -47,6 +49,11 @@ begin
   
   
   if FCSSFile <> '' then
   if FCSSFile <> '' then
   begin
   begin
+    if not FileExists(FCSSFile) Then
+      begin
+        Writeln(stderr,'Can''t find CSS file "',FCSSFILE,'"');
+        halt(1);
+      end;
     TempStream := TMemoryStream.Create;
     TempStream := TMemoryStream.Create;
     TempStream.LoadFromFile(FCSSFile);
     TempStream.LoadFromFile(FCSSFile);
     TempStream.Position := 0;
     TempStream.Position := 0;
@@ -233,7 +240,8 @@ begin
     end;
     end;
   end;
   end;
 
 
-  fchm.AppendBinaryTOCFromSiteMap(Toc);  
+  if not fnobintoc then
+    fchm.AppendBinaryTOCFromSiteMap(Toc);  
   TOC.SaveToStream(Stream);
   TOC.SaveToStream(Stream);
   TOC.Free;
   TOC.Free;
 
 
@@ -408,6 +416,8 @@ begin
 
 
     // save
     // save
     Index.SaveToStream(Stream);
     Index.SaveToStream(Stream);
+    if not fnobinindex then
+      fchm.AppendBinaryindexFromSitemap(index,false);
     Index.Free;
     Index.Free;
     Stream.Position :=0 ;
     Stream.Position :=0 ;
     FChm.AppendIndex(Stream);
     FChm.AppendIndex(Stream);
@@ -445,8 +455,8 @@ begin
   FChm.TempRawStream := FTempUncompressed;
   FChm.TempRawStream := FTempUncompressed;
   FChm.OnGetFileData := @RetrieveOtherFiles;
   FChm.OnGetFileData := @RetrieveOtherFiles;
   FChm.OnLastFile := @LastFileAdded;
   FChm.OnLastFile := @LastFileAdded;
-  fchm.hasbinarytoc:=true;
-  
+  fchm.hasbinarytoc:=not fnobintoc;;
+  fchm.hasbinaryindex:=not fnobinindex;
   ProcessOptions;
   ProcessOptions;
 
 
   FileStream := TMemoryStream.Create;
   FileStream := TMemoryStream.Create;
@@ -483,6 +493,8 @@ end;
 function TCHMHTMLWriter.InterPretOption(const Cmd, Arg: String): boolean;
 function TCHMHTMLWriter.InterPretOption(const Cmd, Arg: String): boolean;
 begin
 begin
   Result:=True;
   Result:=True;
+  FNoBinToc:=False;
+  FnoBinIndex:=False;
   if Cmd = '--toc-file' then
   if Cmd = '--toc-file' then
     FTOCName := arg
     FTOCName := arg
   else if Cmd = '--index-file' then
   else if Cmd = '--index-file' then
@@ -497,6 +509,10 @@ begin
     FAutoIndex := True
     FAutoIndex := True
   else if Cmd = '--auto-toc' then
   else if Cmd = '--auto-toc' then
     FAutoTOC := True
     FAutoTOC := True
+  else if Cmd = '--no-bintoc' then
+    FNoBinToc := True
+  else if Cmd = '--no-binindex' then
+    FNoBinIndex := True
   else if Cmd = '--make-searchable' then
   else if Cmd = '--make-searchable' then
     FMakeSearchable := True
     FMakeSearchable := True
   else
   else

Some files were not shown because too many files changed in this diff