Sfoglia il codice sorgente

* Modernized debug code, fixed crash for .chms without index.

git-svn-id: trunk@11944 -
marco 17 anni fa
parent
commit
2a5dfc3bff
3 ha cambiato i file con 39 aggiunte e 31 eliminazioni
  1. 1 1
      ide/fphelp.pas
  2. 12 6
      ide/wchmhwrap.pas
  3. 26 24
      ide/whtmlhlp.pas

+ 1 - 1
ide/fphelp.pas

@@ -455,7 +455,7 @@ begin
   WOS2Help.RegisterHelpType;
   WWinHelp.RegisterHelpType;
   WVPHelp.RegisterHelpType;
-  WHTMLHlp.RegisterHelpType;
+  WHTMLHlp.RegisterHelpType; // Also registers chm and html index (.htx)
 
   PushStatus(msg_LoadingHelpFiles);
   for I:=0 to HelpFiles^.Count-1 do

+ 12 - 6
ide/wchmhwrap.pas

@@ -107,13 +107,19 @@ begin
  result:=false;
  if not assigned (fchmr) then exit;
  if floaded then exit;
-//  m:=Classes.TMemorystream.create;
+ {$ifdef wdebug}
+     debugmessageS({$i %file%},'TCHMWrapper: indexfilename:'+fchmr.indexfile,{$i %line%},'1'); 
+ {$endif}
+  
   m:=fchmr.getobject(fchmr.indexfile);
   try
-  {$ifdef wdebug}
-     debugmessageS({$i %file%},'TCHMWrapper: stream size loaded :'+inttostr(m.size),{$i %line%},'1'); 
-  {$endif}
-    findex.loadfromStream(m);
+   if assigned(m) then
+     begin
+      {$ifdef wdebug}
+       debugmessageS({$i %file%},'TCHMWrapper: stream size loaded :'+inttostr(m.size),{$i %line%},'1'); 
+      {$endif}
+      findex.loadfromStream(m);
+    end;
   finally
     freeandnil(m);
     end;
@@ -148,7 +154,7 @@ begin
   result:=nil;
   if not assigned(fchmr) or (name='') then exit;
   
-  If name[1]<>'/' Then
+  If (name[1]<>'/') and (copy(name,1,7)<>'ms-its:') Then
     name:='/'+name;
   linedata:=Classes.TStringList.create;
   try

+ 26 - 24
ide/whtmlhlp.pas

@@ -24,7 +24,7 @@ const
      ListIndent = 2;
      DefIndent  = 4;
 
-     MaxTopicLinks = 4000; { maximum number of links on a single HTML page }
+     MaxTopicLinks = 24000; { maximum number of links on a single HTML page }
 
 type
     THTMLSection = (hsNone,hsHeading1,hsHeading2,hsHeading3,hsHeading4,hsHeading5,hsHeading6);
@@ -647,16 +647,16 @@ begin
               InAnchor:=true;
               AddChar(hscLink);
 {$IFDEF WDEBUG}
-              DebugMessage('',' Adding Link1 "'+HRef+'"'+' "'+url+'"',1,1);
-{$endif WDEBUG}
+              DebugMessageS({$i %file%},' Adding Link1 "'+HRef+'"'+' "'+url+'"',{$i %line%},'1');
+{$ENDIF WDEBUG}
               
               if pos('#',HRef)=1 then
                 Href:=NameAndExtOf(GetFilename)+Href;
               HRef:=canonicalizeURL(URL,HRef);
               LinkIndexes[LinkPtr]:=TopicLinks^.AddItem(HRef);
 {$IFDEF WDEBUG}
-              DebugMessage('',' Adding Link2 "'+HRef+'"',1,1);
-{$endif WDEBUG}
+              DebugMessageS({$i %file%},' Adding Link2 "'+HRef+'"',{$i %line%},'1');
+{$ENDIF WDEBUG}
               Inc(LinkPtr);
             end;
           end;
@@ -671,8 +671,7 @@ end;
 procedure THTMLTopicRenderer.DocUnknownTag;
 begin
 {$IFDEF WDEBUG}
-  DebugMessage('',' Unknown tag "'+TagName+'" params "'+
-    TagParams+'"',1,1);
+  DebugMessageS({$i %file%},' Unknown tag "'+TagName+'" params "'+TagParams+'"'  ,{$i %line%},'1');
 {$endif WDEBUG}
 end;
 
@@ -1300,6 +1299,9 @@ begin
           if Topic^.LinkCount>0 then { FP causes numeric RTE 215 without this }
           for I:=0 to Min(Topic^.LinkCount-1,High(LinkIndexes)-1) do
             begin
+              {$IFDEF WDEBUG}
+                DebugMessageS({$i %file%},' Indexing links ('+inttostr(i)+')'+topiclinks^.at(linkindexes[i])^,{$i %line%},'1');
+              {$endif WDEBUG}
               Topic^.Links^[I].FileID:=Topic^.FileID;
               Topic^.Links^[I].Context:=EncodeHTMLCtx(Topic^.FileID,LinkIndexes[I]+1);
             end;
@@ -1320,7 +1322,10 @@ end;
 
 Function  TCHMTopicRenderer.CanonicalizeURL(const Base,Relative:String):string; 
 begin
- CanonicalizeUrl:=combinepaths(relative,base);
+ if copy(relative,1,7)<>'ms-its:' then 
+   CanonicalizeUrl:=combinepaths(relative,base)
+  else
+   CanonicalizeUrl:=relative; 
 end;
 
 constructor TCustomHTMLHelpFile.Init(AID: word);
@@ -1376,13 +1381,13 @@ begin
         begin
           Link:=TopicLinks^.At((T^.HelpCtx and $ffff)-1)^;
 {$IFDEF WDEBUG}
-          DebugMessage(Link,' looking before for ',1,1);
-{$endif WDEBUG}
+          DebugMessageS({$i %file%},'(Topicinfo) Link before formatpath "'+link+'"',{$i %line%},'1');
+{$ENDIF WDEBUG}
           
           Link:=FormatPath(Link);
 {$IFDEF WDEBUG}
-          DebugMessage(Link,' looking after for ',1,1);
-{$endif WDEBUG}
+          DebugMessageS({$i %file%},'(Topicinfo) Link after formatpath "'+link+'"',{$i %line%},'1');
+{$ENDIF WDEBUG}
           P:=Pos('#',Link);
           if P>0 then
           begin
@@ -1417,14 +1422,12 @@ begin
         begin
           Link:=TopicLinks^.At((T^.HelpCtx and $ffff)-1)^;
 {$IFDEF WDEBUG}
-          DebugMessage(Link,' looking before for ',1,1);
-{$endif WDEBUG}
-          
+          DebugMessageS({$i %file%},'(ReadTopic) Link before formatpath "'+link+'"',{$i %line%},'1');
+{$ENDIF WDEBUG}
           Link:=FormatPath(Link);
 {$IFDEF WDEBUG}
-          DebugMessage(Link,' looking after for ',1,1);
-{$endif WDEBUG}
-
+          DebugMessageS({$i %file%},'(ReadTopic) Link before formatpath "'+link+'"',{$i %line%},'1');
+{$ENDIF WDEBUG}
           P:=Pos('#',Link);
           if P>0 then
           begin
@@ -1447,8 +1450,8 @@ begin
       if (HTMLFile=nil) then
         begin
 {$IFDEF WDEBUG}
-          DebugMessage(Link,' filename not known :(',1,1);
-{$endif DEBUG}
+          DebugMessageS({$i %file%},'(ReadTopic) Filename not known:  "'+link+'"',{$i %line%},'1');
+{$ENDIF WDEBUG}
         end;
       if (p>1) and (HTMLFile=nil) then
         begin
@@ -1641,7 +1644,7 @@ begin
           Link:=TopicLinks^.At((T^.HelpCtx and $ffff)-1)^;
           Link:=FormatPath(Link);
 {$IFDEF WDEBUG}
-          DebugMessage(Link,' looking for',1,1);
+          DebugMessageS({$i %file%},' Looking for  "'+Link+'"',{$i %line%},'1');
 {$endif WDEBUG}
           P:=Pos('#',Link);
           if P>0 then
@@ -1677,12 +1680,11 @@ begin
         begin
           Link:=TopicLinks^.At((T^.HelpCtx and $ffff)-1)^;
 {$IFDEF WDEBUG}
-          DebugMessage(Link,' looking for',1,1);
+          DebugMessageS({$i %file%},' Looking for  "'+Link+'"',{$i %line%},'1');
 {$endif WDEBUG}
-
           Link:=FormatPath(Link);
 {$IFDEF WDEBUG}
-          DebugMessage(Link,' looking for',1,1);
+          DebugMessageS({$i %file%},' Looking for (after formatpath)  "'+Link+'"',{$i %line%},'1');
 {$endif WDEBUG}
           P:=Pos('#',Link);
           if P>0 then