Browse Source

* improve seealso handling when reading back binindex with chmls
* avoid trailing zero chars when reading back binindex with chmls

git-svn-id: trunk@39707 -

marco 7 years ago
parent
commit
733559b633
1 changed files with 15 additions and 2 deletions
  1. 15 2
      packages/chm/src/chmreader.pas

+ 15 - 2
packages/chm/src/chmreader.pas

@@ -1016,6 +1016,7 @@ begin
   result:=head<tail;
   result:=head<tail;
 
 
   n:=head-oldhead;
   n:=head-oldhead;
+  if (n>0) and (oldhead[n-1]=0) then dec(n); // remove trailing #0
   setlength(ws,n div sizeof(widechar));
   setlength(ws,n div sizeof(widechar));
   move(oldhead^,ws[1],n);
   move(oldhead^,ws[1],n);
   for n:=1 to length(ws) do
   for n:=1 to length(ws) do
@@ -1081,6 +1082,15 @@ begin
    end;
    end;
 end;
 end;
 
 
+procedure createentryseealso(Name:ansistring;CharIndex:integer;seealso:ansistring);
+var litem : TChmSiteMapItem;
+begin
+     item:=sitemap.items.NewItem;
+     item.KeyWord:=name;
+     item.SeeAlso:=seealso;
+end;
+
+
 procedure parselistingblock(p:pbyte);
 procedure parselistingblock(p:pbyte);
 var
 var
     itemstack:TObjectStack;
     itemstack:TObjectStack;
@@ -1193,8 +1203,11 @@ begin
               end;
               end;
           end;
           end;
          end;
          end;
-      if nrpairs<>0 Then
-        createentry(Name,CharIndex,Topic,Title);
+      if isseealso>0 then
+         createentryseealso(name,charindex,seealsostr)
+      else
+        if nrpairs<>0 Then
+          createentry(Name,CharIndex,Topic,Title);
       inc(head,4); // always 1
       inc(head,4); // always 1
       {$ifdef binindex}
       {$ifdef binindex}
         if head<tail then
         if head<tail then