--- Merging r29545 into '.':

U    packages/chm/src/chmwriter.pas
U    packages/chm/src/chmfilewriter.pas
U    packages/chm/src/chmcmd.lpr
--- Merging r29546 into '.':
U    rtl/inc/system.fpd
--- Merging r29547 into '.':
U    utils/fpdoc/fpdoc.pp
--- Merging r29548 into '.':
U    utils/fpdoc/makeskel.pp
--- Merging r29550 into '.':
G    packages/chm/src/chmcmd.lpr

# revisions: 29545,29546,29547,29548,29550

git-svn-id: branches/fixes_3_0@29720 -
This commit is contained in:
marco 2015-02-16 12:20:32 +00:00
parent 9c19728fc0
commit e8338c128b
6 changed files with 53 additions and 40 deletions

View File

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

View File

@ -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}

View File

@ -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;

View File

@ -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;

View File

@ -18,12 +18,8 @@
program FPDoc;
uses
{$ifdef LZX_USETHREADS}
{$ifdef Unix}
CThreads,
{$endif}
{$endif}
{$ifdef unix}
CThreads,
cwstring,
{$endif}
SysUtils, Classes, Gettext, custapp,

View File

@ -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;