2
0
Эх сурвалжийг харах

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

marco 10 жил өмнө
parent
commit
e8338c128b

+ 18 - 2
packages/chm/src/chmcmd.lpr

@@ -23,7 +23,7 @@ program chmcmd;
 {$mode objfpc}{$H+}
 {$mode objfpc}{$H+}
 
 
 uses
 uses
-  {$ifdef LZX_USETHREADS}{$ifdef Unix}cthreads,{$endif}{$endif} Classes, Sysutils, chmfilewriter, GetOpts;
+  {$ifdef Unix}cthreads,{$endif} Classes, Sysutils, chmfilewriter, GetOpts;
 
 
 Const
 Const
   CHMCMDVersion = '3.0.1';
   CHMCMDVersion = '3.0.1';
@@ -45,7 +45,8 @@ begin
 end;
 end;
 
 
 var
 var
-  theopts : array[1..6] of TOption;
+  theopts : array[1..7] of TOption;
+  cores   : Integer = 0;
 
 
 procedure InitOptions;
 procedure InitOptions;
 
 
@@ -85,6 +86,12 @@ begin
     flag:=nil;
     flag:=nil;
   end;
   end;
   with theopts[6] do
   with theopts[6] do
+   begin
+    name:='cores';
+    has_arg:=1;
+    flag:=nil;
+  end;
+  with theopts[7] do
    begin
    begin
     name:='';
     name:='';
     has_arg:=0;
     has_arg:=0;
@@ -198,6 +205,15 @@ begin
                     Usage;
                     Usage;
                     Halt;
                     Halt;
                    end;
                    end;
+               5 : begin
+                     if not trystrtoint(optarg,cores) then
+                       begin
+                         Writeln('Illegal value for switch --cores :',optarg);
+                         Usage;
+                         Halt;
+                       end;
+
+		   end;
                 end;
                 end;
            end;
            end;
       '?' : begin
       '?' : begin

+ 3 - 0
packages/chm/src/chmfilewriter.pas

@@ -68,6 +68,7 @@ type
     FIndex         : TCHMSiteMap;
     FIndex         : TCHMSiteMap;
     FTocStream,
     FTocStream,
     FIndexStream   : TMemoryStream;
     FIndexStream   : TMemoryStream;
+    FCores	   : integer;
   protected
   protected
     function GetData(const DataName: String; out PathInChm: String; out FileName: String; var Stream: TStream): Boolean;
     function GetData(const DataName: String; out PathInChm: String; out FileName: String; var Stream: TStream): Boolean;
     procedure LastFileAdded(Sender: TObject);
     procedure LastFileAdded(Sender: TObject);
@@ -112,6 +113,7 @@ type
     property ScanHtmlContents  : Boolean read fScanHtmlContents write fScanHtmlContents;
     property ScanHtmlContents  : Boolean read fScanHtmlContents write fScanHtmlContents;
     property ReadmeMessage : String read FReadmeMessage write FReadmeMessage;
     property ReadmeMessage : String read FReadmeMessage write FReadmeMessage;
     property AllowedExtensions : TStringList read FAllowedExtensions;
     property AllowedExtensions : TStringList read FAllowedExtensions;
+    property Cores : integer read fcores write fcores; 
   end;
   end;
 
 
   TChmContextNode = Class
   TChmContextNode = Class
@@ -168,6 +170,7 @@ var
 begin
 begin
   // Assign the TOC and index files
   // Assign the TOC and index files
   Writer := TChmWriter(Sender);
   Writer := TChmWriter(Sender);
+  writer.cores:=fcores;
   {$ifdef chmindex}
   {$ifdef chmindex}
     Writeln('binindex filename ',IndexFileName);
     Writeln('binindex filename ',IndexFileName);
   {$endif}
   {$endif}

+ 29 - 32
packages/chm/src/chmwriter.pas

@@ -20,10 +20,9 @@
 }
 }
 unit chmwriter;
 unit chmwriter;
 {$MODE OBJFPC}{$H+}
 {$MODE OBJFPC}{$H+}
-{ $DEFINE LZX_USETHREADS}
 
 
 interface
 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
 Const
    DefaultHHC = 'Default.hhc';
    DefaultHHC = 'Default.hhc';
@@ -79,6 +78,7 @@ Type
     HeaderSection0: TITSPHeaderPrefix;
     HeaderSection0: TITSPHeaderPrefix;
     HeaderSection1: TITSPHeader; // DirectoryListings header
     HeaderSection1: TITSPHeader; // DirectoryListings header
     FReadmeMessage : String;
     FReadmeMessage : String;
+    FCores	: integer;
     // DirectoryListings
     // DirectoryListings
     // CONTENT Section 0 (section 1 is contained in section 0)
     // CONTENT Section 0 (section 1 is contained in section 0)
     // EOF
     // EOF
@@ -105,13 +105,11 @@ Type
     function  WriteCompressedData(Count: Longint; Buffer: Pointer): LongInt;
     function  WriteCompressedData(Count: Longint; Buffer: Pointer): LongInt;
     procedure MarkFrame(UnCompressedTotal, CompressedTotal: LongWord);
     procedure MarkFrame(UnCompressedTotal, CompressedTotal: LongWord);
     // end callbacks
     // end callbacks
-    {$IFDEF LZX_USETHREADS}
     // callbacks for lzx compress threads
     // callbacks for lzx compress threads
     function  LTGetData(Sender: TLZXCompressor; WantedByteCount: Integer; Buffer: Pointer): Integer;
     function  LTGetData(Sender: TLZXCompressor; WantedByteCount: Integer; Buffer: Pointer): Integer;
     function  LTIsEndOfFile(Sender: TLZXCompressor): Boolean;
     function  LTIsEndOfFile(Sender: TLZXCompressor): Boolean;
     procedure LTChunkDone(Sender: TLZXCompressor; CompressedSize: Integer; UncompressedSize: Integer; Buffer: Pointer);
     procedure LTChunkDone(Sender: TLZXCompressor; CompressedSize: Integer; UncompressedSize: Integer; Buffer: Pointer);
     procedure LTMarkFrame(Sender: TLZXCompressor; CompressedTotal: Integer; UncompressedTotal: Integer);
     procedure LTMarkFrame(Sender: TLZXCompressor; CompressedTotal: Integer; UncompressedTotal: Integer);
-    {$ENDIF}
     // end callbacks
     // end callbacks
   public
   public
     constructor Create(AOutStream: TStream; FreeStreamOnDestroy: Boolean); virtual;
     constructor Create(AOutStream: TStream; FreeStreamOnDestroy: Boolean); virtual;
@@ -127,6 +125,7 @@ Type
     property OutStream: TStream read FOutStream;
     property OutStream: TStream read FOutStream;
     property TempRawStream: TStream read FTempStream write SetTempRawStream;
     property TempRawStream: TStream read FTempStream write SetTempRawStream;
     property ReadmeMessage : String read fReadmeMessage write fReadmeMessage;
     property ReadmeMessage : String read fReadmeMessage write fReadmeMessage;
+    property Cores : integer read fcores write fcores;
     //property LocaleID: dword read ITSFHeader.LanguageID write ITSFHeader.LanguageID;
     //property LocaleID: dword read ITSFHeader.LanguageID write ITSFHeader.LanguageID;
   end;
   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
   // We have to trim the last entry off when we are done because there is no next block in that case
 end;
 end;
 
 
-{$IFDEF LZX_USETHREADS}
 function TITSFWriter.LTGetData(Sender: TLZXCompressor; WantedByteCount: Integer;
 function TITSFWriter.LTGetData(Sender: TLZXCompressor; WantedByteCount: Integer;
   Buffer: Pointer): Integer;
   Buffer: Pointer): Integer;
 begin
 begin
@@ -782,8 +780,6 @@ begin
   MarkFrame(UncompressedTotal, CompressedTotal);
   MarkFrame(UncompressedTotal, CompressedTotal);
   //WriteLn('Mark Frame C = ', CompressedTotal, ' U = ', UncompressedTotal);
   //WriteLn('Mark Frame C = ', CompressedTotal, ' U = ', UncompressedTotal);
 end;
 end;
-{$ENDIF}
-
 
 
 constructor TITSFWriter.Create(AOutStream: TStream; FreeStreamOnDestroy: Boolean);
 constructor TITSFWriter.Create(AOutStream: TStream; FreeStreamOnDestroy: Boolean);
 begin
 begin
@@ -910,37 +906,38 @@ end;
 
 
 procedure TITSFWriter.StartCompressingStream;
 procedure TITSFWriter.StartCompressingStream;
 var
 var
-  {$IFNDEF LZX_USETHREADS}
   LZXdata: Plzx_data;
   LZXdata: Plzx_data;
   WSize: LongInt;
   WSize: LongInt;
-  {$ELSE}
   Compressor: TLZXCompressor;
   Compressor: TLZXCompressor;
-  {$ENDIF}
 begin
 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);
               @_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;
-
-  //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}
+     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);
+
+     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;
 end;
 
 
 
 

+ 1 - 1
rtl/inc/system.fpd

@@ -19,7 +19,7 @@ Type
    Char    = #0..#255;
    Char    = #0..#255;
    Longint = -2147483648..2147483647;
    Longint = -2147483648..2147483647;
    Longword= 0..4294967295;
    Longword= 0..4294967295;
-   Int64   = =-9223372036854775808.. 9223372036854775807;
+   Int64   = -9223372036854775808..9223372036854775807;
    QWord   = 0..18446744073709551615;
    QWord   = 0..18446744073709551615;
    Shortint= -128 .. 127;
    Shortint= -128 .. 127;
    Smallint= -32768 .. 32767;
    Smallint= -32768 .. 32767;

+ 1 - 5
utils/fpdoc/fpdoc.pp

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

+ 3 - 2
utils/fpdoc/makeskel.pp

@@ -356,8 +356,9 @@ Var
   N : TDocNode;
   N : TDocNode;
      
      
 begin
 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;
   FNodeList:=TStringList.Create;
   Try
   Try
     FEmittedList:=TStringList.Create;
     FEmittedList:=TStringList.Create;