* patch from Jeppe

-  off by one error that causes keywords that only occur once from not
     being included in the full text search
  -  support for scanning files referenced in css file url()
  -  fix bug in sitemap wrt "merge" entry

git-svn-id: trunk@39378 -
This commit is contained in:
marco 2018-07-04 10:48:57 +00:00
parent 62fa67d9d8
commit de160955e6
3 changed files with 38 additions and 6 deletions

View File

@ -933,6 +933,8 @@ begin
Error(ChmWarning,'Found file '+s+' while scanning '+fn+', but couldn''t find it on disk',2); Error(ChmWarning,'Found file '+s+' while scanning '+fn+', but couldn''t find it on disk',2);
end; end;
except except
on e:EDomError do
Error(ChmError,'Html parsing '+fn+', failed with a DOM error: '+e.Message);
on e:exception do on e:exception do
Error(ChmError,'Html parsing '+fn+', failed. Please submit a bug.'); Error(ChmError,'Html parsing '+fn+', failed. Please submit a bug.');
end; end;
@ -943,6 +945,29 @@ begin
Error(chmnote,'Can''t find file '+fn+' to scan it.',5); Error(chmnote,'Can''t find file '+fn+' to scan it.',5);
end; end;
end end
else if FileExists(fn) and (uppercase(ExtractFileExt(fn))='.CSS') then
begin
tmplst:=TStringList.Create;
try
tmplst.LoadFromFile(fn);
for i:=0 to tmplst.Count-1 do
begin
s:=tmplst[i];
if pos('url(''', tmplst[i])>0 then
begin
delete(s,1,pos('url(''', tmplst[i])+4);
s:=trim(copy(s,1,pos('''',s)-1));
if not trypath(s) then
// if not trypath(localpath+s) then
Error(ChmWarning,'Found file '+s+' while scanning '+fn+', but couldn''t find it on disk',2);
end;
end;
finally
tmplst.Free;
end;
end
else else
Error(chmnote,'Not scanning file because of unknown extension '+fn,5); Error(chmnote,'Not scanning file because of unknown extension '+fn,5);
end; end;

View File

@ -169,8 +169,15 @@ begin
end; end;
procedure TChmSiteMap.FoundTag(ACaseInsensitiveTag, AActualTag: string); procedure TChmSiteMap.FoundTag(ACaseInsensitiveTag, AActualTag: string);
procedure NewSiteMapItem;
begin
FCurrentItems.Add(TChmSiteMapItem.Create(FCurrentItems));
end;
function ActiveItem: TChmSiteMapItem; function ActiveItem: TChmSiteMapItem;
begin begin
if FCurrentItems.Count=0 then
NewSiteMapItem;
Result := FCurrentItems.Item[FCurrentItems.Count-1] Result := FCurrentItems.Item[FCurrentItems.Count-1]
end; end;
procedure IncreaseULevel; procedure IncreaseULevel;
@ -189,10 +196,6 @@ procedure TChmSiteMap.FoundTag(ACaseInsensitiveTag, AActualTag: string);
else FCurrentItems := nil; else FCurrentItems := nil;
Dec(FLevel); Dec(FLevel);
end; end;
procedure NewSiteMapItem;
begin
FCurrentItems.Add(TChmSiteMapItem.Create(FCurrentItems));
end;
var var
TagName, TagName,
//TagAttribute, //TagAttribute,

View File

@ -216,6 +216,10 @@ procedure TIndexedWordList.CBFountText(Text: string);
begin begin
if Length(Text) < 1 then if Length(Text) < 1 then
Exit; Exit;
if (not FInTitle) and (not FInBody) then
Exit;
EatWords(Text, FInTitle and not FInBody); EatWords(Text, FInTitle and not FInBody);
end; end;
@ -278,7 +282,7 @@ begin
WordName := Copy(WordStart, 0, (WordPtr-WordStart)); WordName := Copy(WordStart, 0, (WordPtr-WordStart));
try try
WordIndex := addgetword(wordname,istitle); // Self.Words[WordName, IsTitle]; WordIndex := addgetword(wordname,istitle); // Self.Words[WordName, IsTitle];
except on e:exception do writeln(wordname); end; except on e:exception do writeln('Error: ', wordname); end;
WordIndex.DocumentTopic[FTopicIndex].AddWordIndex(FWordCount); WordIndex.DocumentTopic[FTopicIndex].AddWordIndex(FWordCount);
InWord := False; InWord := False;
//if IsNumberWord then WriteLn('Following is NUMBER WORD: "', (WordStart[0]),'"'); ; //if IsNumberWord then WriteLn('Following is NUMBER WORD: "', (WordStart[0]),'"'); ;
@ -497,7 +501,7 @@ end;
function TIndexDocument.getindexentries:integer; function TIndexDocument.getindexentries:integer;
begin begin
result:=flastentry-1; result:=flastentry;
end; end;
end. end.