diff --git a/packages/chm/src/chmcmd.lpr b/packages/chm/src/chmcmd.lpr index 522e649d0f..9e9e08a7ab 100644 --- a/packages/chm/src/chmcmd.lpr +++ b/packages/chm/src/chmcmd.lpr @@ -23,7 +23,7 @@ program chmcmd; {$mode objfpc}{$H+} uses - {$ifdef LZX_USETHREADS}{$ifdef Unix}cthreads,{$endif}{$endif} Classes, Sysutils, chmfilewriter, GetOpts; + {$ifdef Unix}cthreads,{$endif} Classes, Sysutils, chmfilewriter, GetOpts; Const CHMCMDVersion = '3.0.1'; @@ -45,7 +45,8 @@ begin end; var - theopts : array[1..6] of TOption; + theopts : array[1..7] of TOption; + cores : Integer = 0; procedure InitOptions; @@ -85,6 +86,12 @@ begin flag:=nil; end; with theopts[6] do + begin + name:='cores'; + has_arg:=1; + flag:=nil; + end; + with theopts[7] do begin name:=''; has_arg:=0; @@ -198,6 +205,15 @@ begin Usage; Halt; end; + 5 : begin + if not trystrtoint(optarg,cores) then + begin + Writeln('Illegal value for switch --cores :',optarg); + Usage; + Halt; + end; + + end; end; end; '?' : begin diff --git a/packages/chm/src/chmfilewriter.pas b/packages/chm/src/chmfilewriter.pas index 106b201305..cde6f3bb71 100644 --- a/packages/chm/src/chmfilewriter.pas +++ b/packages/chm/src/chmfilewriter.pas @@ -68,6 +68,7 @@ type FIndex : TCHMSiteMap; FTocStream, FIndexStream : TMemoryStream; + FCores : integer; protected function GetData(const DataName: String; out PathInChm: String; out FileName: String; var Stream: TStream): Boolean; procedure LastFileAdded(Sender: TObject); @@ -112,6 +113,7 @@ type property ScanHtmlContents : Boolean read fScanHtmlContents write fScanHtmlContents; property ReadmeMessage : String read FReadmeMessage write FReadmeMessage; property AllowedExtensions : TStringList read FAllowedExtensions; + property Cores : integer read fcores write fcores; end; TChmContextNode = Class @@ -168,6 +170,7 @@ var begin // Assign the TOC and index files Writer := TChmWriter(Sender); + writer.cores:=fcores; {$ifdef chmindex} Writeln('binindex filename ',IndexFileName); {$endif} diff --git a/packages/chm/src/chmwriter.pas b/packages/chm/src/chmwriter.pas index 33580cad56..fa65505a54 100644 --- a/packages/chm/src/chmwriter.pas +++ b/packages/chm/src/chmwriter.pas @@ -20,10 +20,9 @@ } unit chmwriter; {$MODE OBJFPC}{$H+} -{ $DEFINE LZX_USETHREADS} interface -uses Classes, ChmBase, chmtypes, chmspecialfiles, HtmlIndexer, chmsitemap, contnrs, StreamEx, Avl_Tree{$IFDEF LZX_USETHREADS}, lzxcompressthread{$ENDIF}; +uses Classes, ChmBase, chmtypes, chmspecialfiles, HtmlIndexer, chmsitemap, contnrs, StreamEx, Avl_Tree, lzxcompressthread; Const DefaultHHC = 'Default.hhc'; @@ -79,6 +78,7 @@ Type HeaderSection0: TITSPHeaderPrefix; HeaderSection1: TITSPHeader; // DirectoryListings header FReadmeMessage : String; + FCores : integer; // DirectoryListings // CONTENT Section 0 (section 1 is contained in section 0) // EOF @@ -105,13 +105,11 @@ Type function WriteCompressedData(Count: Longint; Buffer: Pointer): LongInt; procedure MarkFrame(UnCompressedTotal, CompressedTotal: LongWord); // end callbacks - {$IFDEF LZX_USETHREADS} // callbacks for lzx compress threads function LTGetData(Sender: TLZXCompressor; WantedByteCount: Integer; Buffer: Pointer): Integer; function LTIsEndOfFile(Sender: TLZXCompressor): Boolean; procedure LTChunkDone(Sender: TLZXCompressor; CompressedSize: Integer; UncompressedSize: Integer; Buffer: Pointer); procedure LTMarkFrame(Sender: TLZXCompressor; CompressedTotal: Integer; UncompressedTotal: Integer); - {$ENDIF} // end callbacks public constructor Create(AOutStream: TStream; FreeStreamOnDestroy: Boolean); virtual; @@ -127,6 +125,7 @@ Type property OutStream: TStream read FOutStream; property TempRawStream: TStream read FTempStream write SetTempRawStream; property ReadmeMessage : String read fReadmeMessage write fReadmeMessage; + property Cores : integer read fcores write fcores; //property LocaleID: dword read ITSFHeader.LanguageID write ITSFHeader.LanguageID; end; @@ -757,7 +756,6 @@ begin // We have to trim the last entry off when we are done because there is no next block in that case end; -{$IFDEF LZX_USETHREADS} function TITSFWriter.LTGetData(Sender: TLZXCompressor; WantedByteCount: Integer; Buffer: Pointer): Integer; begin @@ -782,8 +780,6 @@ begin MarkFrame(UncompressedTotal, CompressedTotal); //WriteLn('Mark Frame C = ', CompressedTotal, ' U = ', UncompressedTotal); end; -{$ENDIF} - constructor TITSFWriter.Create(AOutStream: TStream; FreeStreamOnDestroy: Boolean); begin @@ -910,37 +906,38 @@ end; procedure TITSFWriter.StartCompressingStream; var - {$IFNDEF LZX_USETHREADS} LZXdata: Plzx_data; WSize: LongInt; - {$ELSE} Compressor: TLZXCompressor; - {$ENDIF} begin - {$IFNDEF LZX_USETHREADS} - lzx_init(@LZXdata, LZX_WINDOW_SIZE, @_GetData, Self, @_AtEndOfData, + if fcores=0 then + begin + lzx_init(@LZXdata, LZX_WINDOW_SIZE, @_GetData, Self, @_AtEndOfData, @_WriteCompressedData, Self, @_MarkFrame, Self); - WSize := 1 shl LZX_WINDOW_SIZE; - while not AtEndOfData do begin - lzx_reset(LZXdata); - lzx_compress_block(LZXdata, WSize, True); - end; + WSize := 1 shl LZX_WINDOW_SIZE; + while not AtEndOfData do begin + lzx_reset(LZXdata); + lzx_compress_block(LZXdata, WSize, True); + end; - //we have to mark the last frame manually - MarkFrame(LZXdata^.len_uncompressed_input, LZXdata^.len_compressed_output); + //we have to mark the last frame manually + MarkFrame(LZXdata^.len_uncompressed_input, LZXdata^.len_compressed_output); - lzx_finish(LZXdata, nil); - {$ELSE} - Compressor := TLZXCompressor.Create(4); - Compressor.OnChunkDone :=@LTChunkDone; - Compressor.OnGetData :=@LTGetData; - Compressor.OnIsEndOfFile:=@LTIsEndOfFile; - Compressor.OnMarkFrame :=@LTMarkFrame; - Compressor.Execute(True); - //Sleep(20000); - Compressor.Free; - {$ENDIF} + lzx_finish(LZXdata, nil); + end + else + begin + if fcores=0 then fcores:=4; + Compressor := TLZXCompressor.Create(fcores); + Compressor.OnChunkDone :=@LTChunkDone; + Compressor.OnGetData :=@LTGetData; + Compressor.OnIsEndOfFile:=@LTIsEndOfFile; + Compressor.OnMarkFrame :=@LTMarkFrame; + Compressor.Execute(True); + //Sleep(20000); + Compressor.Free; + end; end; diff --git a/rtl/inc/system.fpd b/rtl/inc/system.fpd index dfd8504aeb..0303724b6c 100644 --- a/rtl/inc/system.fpd +++ b/rtl/inc/system.fpd @@ -19,7 +19,7 @@ Type Char = #0..#255; Longint = -2147483648..2147483647; Longword= 0..4294967295; - Int64 = =-9223372036854775808.. 9223372036854775807; + Int64 = -9223372036854775808..9223372036854775807; QWord = 0..18446744073709551615; Shortint= -128 .. 127; Smallint= -32768 .. 32767; diff --git a/utils/fpdoc/fpdoc.pp b/utils/fpdoc/fpdoc.pp index d1ffa734c4..0d9257fd3a 100644 --- a/utils/fpdoc/fpdoc.pp +++ b/utils/fpdoc/fpdoc.pp @@ -18,12 +18,8 @@ program FPDoc; uses -{$ifdef LZX_USETHREADS} {$ifdef Unix} - CThreads, - {$endif} -{$endif} -{$ifdef unix} + CThreads, cwstring, {$endif} SysUtils, Classes, Gettext, custapp, diff --git a/utils/fpdoc/makeskel.pp b/utils/fpdoc/makeskel.pp index 3495298920..d63c0c0088 100644 --- a/utils/fpdoc/makeskel.pp +++ b/utils/fpdoc/makeskel.pp @@ -356,8 +356,9 @@ Var N : TDocNode; begin - if not(FileExists(AFileName)) then - raise Exception.CreateFmt('Cannot find source file %s to document.',[AFileName]); +// wrong because afilename is a cmdline with other options. Straight testing filename is therefore wrong. +// if not(FileExists(AFileName)) then +// raise Exception.CreateFmt('Cannot find source file %s to document.',[AFileName]); FNodeList:=TStringList.Create; Try FEmittedList:=TStringList.Create;