Browse Source

* minor improvements to debuginfo, and Florian's increasing of the topic size.

git-svn-id: trunk@13536 -
marco 16 years ago
parent
commit
1a7b8eaefd
3 changed files with 52 additions and 35 deletions
  1. 30 22
      ide/wchmhwrap.pas
  2. 1 1
      ide/whelp.pas
  3. 21 12
      ide/whtmlhlp.pas

+ 30 - 22
ide/wchmhwrap.pas

@@ -15,13 +15,13 @@
  **********************************************************************}
 unit wchmhwrap;
 
-interface 
+interface
 {$Mode Delphi}
 
 Uses  wutils,whelp,whtml,SysUtils,ChmReader,ChmSiteMap,Classes;
 
 Type
-//      TopicLinks: PTopicLinkCollection;IndexEntries : PUnsortedIndexEntryCollection;  
+//      TopicLinks: PTopicLinkCollection;IndexEntries : PUnsortedIndexEntryCollection;
 
      TChmWrapper = Class
                      private
@@ -30,7 +30,7 @@ Type
                        findex: TChmSiteMap;
                        ftopic: TChmSiteMap;
                        floaded  : boolean;
-                     public    
+                     public
                       constructor Create(name:String);
                       function	  LoadIndex(id:integer;TopicLinks: PTopicLinkCollection;IndexEntries : PUnsortedIndexEntryCollection;helpfacility:PHelpFacility):boolean;
                       function    GetTopic(name:string):PMemoryTextFile;
@@ -56,11 +56,19 @@ begin
        basepath:=extractfiledir(basepath);
        delete(relpath,1,3);
      end;
-       
-   {$ifdef combinedebug}
+
+  {$ifdef combinedebug}
     debugmessageS({$i %file%},'combine out "'+relpath+'" and "'+basepath+'"',{$i %line%},'1',0,0);
   {$endif}
-  
+  if (length(basepath)>0) and (length(relpath)>0) then
+    begin
+      if (relpath[1]<>'/') and (basepath[length(basepath)]<>'/') then
+        basepath:=basepath+'/';
+       {$ifdef combinedebug}
+        debugmessageS({$i %file%},'combine out2 "'+relpath+'" and "'+basepath+'"',{$i %line%},'1',0,0);
+       {$endif}
+    end;
+
   result:=basepath+relpath;
 end;
 
@@ -75,8 +83,8 @@ begin
     begin
       freeandnil(fchmr);
       freeandnil(ffs);
-      exit;  
-    end;      
+      exit;
+    end;
   {$ifdef wdebug}
     debugmessageS({$i %file%},'TCHMWrapper: before sitemap creation ',{$i %line%},'1',0,0);
   {$endif}
@@ -97,7 +105,7 @@ begin
 //  if (length(alias)>0) and (alias[1]<>'/') then Alias:='/'+alias;
   FormatAlias:=Alias;
 end;
-              
+
 var
     m : Classes.TMemoryStream;
     i,j : integer;
@@ -108,15 +116,15 @@ begin
  if not assigned (fchmr) then exit;
  if floaded then exit;
  {$ifdef wdebug}
-     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}
-  
+
   m:=fchmr.getobject(fchmr.indexfile);
   try
    if assigned(m) then
      begin
       {$ifdef wdebug}
-       debugmessageS({$i %file%},'TCHMWrapper: stream size loaded :'+inttostr(m.size),{$i %line%},'1',0,0); 
+       debugmessageS({$i %file%},'TCHMWrapper: stream size loaded :'+inttostr(m.size),{$i %line%},'1',0,0);
       {$endif}
       findex.loadfromStream(m);
     end;
@@ -124,21 +132,21 @@ begin
     freeandnil(m);
     end;
    {$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}
-  
-  tli:=TopicLinks^.AddItem(fchmr.defaultpage); 
+
+  tli:=TopicLinks^.AddItem(fchmr.defaultpage);
   TLI:=EncodeHTMLCtx(ID,TLI+1);
   IndexEntries^.Insert(NewIndexEntry(  FormatAlias('Table of contents'),ID,TLI));
   for i:=0 to findex.items.count-1 do
     begin
       item:=findex.items.item[i];
-      tli:=TopicLinks^.AddItem('/'+item.local); 
+      tli:=TopicLinks^.AddItem('/'+item.local);
       TLI:=EncodeHTMLCtx(ID,TLI+1);
       IndexEntries^.Insert(NewIndexEntry(  FormatAlias(item.text),ID,TLI));
     end;
    {$ifdef wdebug}
-     debugmessageS({$i %file%},'TCHMWrapper: endloadindex ',{$i %line%},'1',0,0); 
+     debugmessageS({$i %file%},'TCHMWrapper: endloadindex ',{$i %line%},'1',0,0);
   {$endif}
   floaded:=true;
   result:=true;
@@ -161,7 +169,7 @@ begin
       if (s[i]=' ') and not inquote then lastpoint:=i;
       if (s[i]='"') then inquote:=not inquote;
       inc(i);
-    end;  
+    end;
   scanvalue:=lastpoint;
 end;
 
@@ -191,19 +199,19 @@ var
 begin
   result:=nil;
   if not assigned(fchmr) or (name='') then exit;
-  
+
   If (name[1]<>'/') and (copy(name,1,7)<>'ms-its:') Then
     name:='/'+name;
   linedata:=Classes.TStringList.create;
   try
     {$ifdef wdebug}
-     debugmessageS({$i %file%},'TCHMWrapper: Getting file '+name,{$i %line%},'1',0,0); 
+     debugmessageS({$i %file%},'TCHMWrapper: Getting file '+name,{$i %line%},'1',0,0);
     {$endif}
 //    if uppercase(name)='TABLE OF CONTENTS' Then
   //    m:=fchmr.getobject(fchmr.tocfile)
 //    else
       m:=fchmr.getobject(name);
-    
+
     if not assigned(m) then exit;
     linedata.loadfromstream(m);
     result:=new(PMemoryTextFile,Init);
@@ -231,4 +239,4 @@ end;
 // m:=r.getobject(r.indexfile);
 //  siteindex.loadfromStream(m);
 
-end.
+end.

+ 1 - 1
ide/whelp.pas

@@ -156,7 +156,7 @@ type
 const TopicCacheSize    : sw_integer = 10;
       HelpStreamBufSize : sw_integer = 4096;
       HelpFacility      : PHelpFacility = nil;
-      MaxHelpTopicSize  : sw_word = 3*65520;
+      MaxHelpTopicSize  : sw_word = 1024*1024;
 
 function  NewTopic(FileID: byte; HelpCtx: THelpCtx; Pos: longint; Param: string;
           ExtData: pointer; ExtDataSize: longint): PTopic;

+ 21 - 12
ide/whtmlhlp.pas

@@ -149,7 +149,7 @@ type
     TCHMTopicRenderer = object(THTMLTopicRenderer)
       function CanonicalizeURL(const Base,Relative:String):string; virtual;
       end;
-      
+
     PCustomHTMLHelpFile = ^TCustomHTMLHelpFile;
     TCustomHTMLHelpFile = object(THelpFile)
       constructor Init(AID: word);
@@ -165,7 +165,7 @@ type
       CurFileName: string;
       TopicLinks: PTopicLinkCollection;
     end;
-   
+
     PHTMLHelpFile = ^THTMLHelpFile;
     THTMLHelpFile = object(TCustomHTMLHelpFile)
       constructor Init(AFileName: string; AID: word; ATOCEntry: string);
@@ -178,7 +178,7 @@ type
     PCHMHelpFile = ^TCHMHelpFile;
     TCHMHelpFile = object(TCustomHTMLHelpFile)
       constructor Init(AFileName: string; AID: word);
-      destructor  Done; virtual; 
+      destructor  Done; virtual;
     public
       function    LoadIndex: boolean; virtual;
       function    ReadTopic(T: PTopic): boolean; virtual;
@@ -651,7 +651,7 @@ begin
 {$IFDEF WDEBUG}
               DebugMessageS({$i %file%},' Adding Link1 "'+HRef+'"'+' "'+url+'"',{$i %line%},'1',0,0);
 {$ENDIF WDEBUG}
-              
+
               if pos('#',HRef)=1 then
                 Href:=NameAndExtOf(GetFilename)+Href;
               HRef:=canonicalizeURL(URL,HRef);
@@ -717,7 +717,7 @@ begin
     end;
 end;
 
-Function  THTMLTopicRenderer.CanonicalizeURL(const Base,Relative:String):string; 
+Function  THTMLTopicRenderer.CanonicalizeURL(const Base,Relative:String):string;
 // uses info from filesystem (curdir) -> overriden for CHM.
 begin
  CanonicalizeURL:=CompleteURL(Base,relative);
@@ -1307,6 +1307,12 @@ begin
               Topic^.Links^[I].FileID:=Topic^.FileID;
               Topic^.Links^[I].Context:=EncodeHTMLCtx(Topic^.FileID,LinkIndexes[I]+1);
             end;
+         {$IFDEF WDEBUG}
+          if Topic^.Linkcount>High(linkindexes) then
+           DebugMessageS({$i %file%},' Maximum links exceeded ('+inttostr(Topic^.LinkCount)+') '+URL,{$i %line%},'1',0,0);
+         {$endif WDEBUG}
+
+
           { --- topic text --- }
           GetMem(TP,TextPtr);
           Move(Topic^.Text^,TP^,TextPtr);
@@ -1322,12 +1328,12 @@ begin
   BuildTopic:=OK;
 end;
 
-Function  TCHMTopicRenderer.CanonicalizeURL(const Base,Relative:String):string; 
+Function  TCHMTopicRenderer.CanonicalizeURL(const Base,Relative:String):string;
 begin
- if copy(relative,1,7)<>'ms-its:' then 
+ if copy(relative,1,7)<>'ms-its:' then
    CanonicalizeUrl:=combinepaths(relative,base)
   else
-   CanonicalizeUrl:=relative; 
+   CanonicalizeUrl:=relative;
 end;
 
 constructor TCustomHTMLHelpFile.Init(AID: word);
@@ -1390,7 +1396,7 @@ begin
 {$IFDEF WDEBUG}
           DebugMessageS({$i %file%},'(Topicinfo) Link before formatpath "'+link+'"',{$i %line%},'1',0,0);
 {$ENDIF WDEBUG}
-          
+
           Link:=FormatLink(Link);
 {$IFDEF WDEBUG}
           DebugMessageS({$i %file%},'(Topicinfo) Link after formatpath "'+link+'"',{$i %line%},'1',0,0);
@@ -1584,11 +1590,11 @@ end;
 
 constructor TChmHelpFile.Init(AFileName: string; AID: word);
 begin
-  if inherited Init(AID)=false then 
+  if inherited Init(AID)=false then
     Fail;
   Dispose(renderer,done);
   renderer:=New(PCHMTopicRenderer, Init);
-  DefaultFileName:=AFileName; 
+  DefaultFileName:=AFileName;
   if (DefaultFileName='') or not ExistsFile(DefaultFilename) then
   begin
     Done;
@@ -1598,7 +1604,7 @@ begin
     chmw:=TCHMWrapper.Create(DefaultFileName);
 end;
 
-function    TChmHelpFile.LoadIndex: boolean; 
+function    TChmHelpFile.LoadIndex: boolean;
 begin
   loadindex:=false;
   if assigned(chmw) then
@@ -1705,6 +1711,9 @@ begin
           begin
             Bookmark:=copy(Link,P+1,length(Link));
             Link:=copy(Link,1,P-1);
+            {$IFDEF WDEBUG}
+              debugMessageS({$i %file%},' Removed label: "'+Link+'"',{$i %line%},'1',0,0);
+            {$endif WDEBUG}
           end;
 {          if CurFileName='' then Name:=Link else
           Name:=CompletePath(CurFileName,Link);}