Recent

Author Topic: Non blocking bugs in chmcmd  (Read 4543 times)

Mwoua

  • New Member
  • *
  • Posts: 16
Non blocking bugs in chmcmd
« on: July 17, 2017, 10:50:47 pm »
Following this thread : You can find attached a sample project (I made it as small as possible) with two bugs :

-internet links are reported as missing file :
Code: Pascal  [Select][+][-]
  1. Warning: Found file https://github.com/philsquared/Catch/blob/master/docs/Readme.md while scanning _l_u_t_sensor_leddar_vu8_modbus_8cpp.html, but couldn't find it on disk


-Existing anchors in html are reported as missing (and maybe it should just be a warning)
Code: Pascal  [Select][+][-]
  1. Error: Anchor _l_u_t_sensor_leddar_vu8_modbus_8cpp_a0058abed3f064d06890a5aa1c1c6fb6d.html#a0058abed3f064d06890a5aa1c1c6fb6d undefined; first use _l_u_t_sensor_leddar_vu8_modbus_8cpp.html

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Non blocking bugs in chmcmd
« Reply #1 on: July 17, 2017, 11:28:10 pm »
I found the bug leading to the missing internet links error: All these links have the https protocol. chmfilewriter contains a list protocols to be ignored, and https is missing here. After adding it here, the warning is gone.

This list is immediately before TChmProject.SanitizeURL (near line 720 of chmfilewriter.pas) and must be extended to be like this:

Code: Pascal  [Select][+][-]
  1. const
  2.    protocols   : array[0..4] of string  = ('HTTP:', 'HTTPS:', 'FTP:', 'MS-ITS:', 'MAILTO:');
  3.    protocollen : array[0..4] of integer = ( 5, 6, 4, 7, 7);
  4.  

Marco, if you see this, could you please apply the modification? Of course I can write a bugreport...

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Non blocking bugs in chmcmd
« Reply #2 on: July 19, 2017, 12:39:44 am »
It took me some time to catch the other bug: All the "undefined anchor" errors occur for anchors which are identified by an ID, not by a name. But the local function ScanTags of TChmProject.ScanList (in chmfilewriter.pas) only checks for the attribute "name" of the "A" tag. This can be fixed as follows:

Code: Pascal  [Select][+][-]
  1. procedure TChmProject.ScanList(toscan,newfiles:TStrings;recursion:boolean);
  2. ...
  3. function scantags(prnt:TDomNode; const localname: string; filelist:TStringlist):TDomNode;
  4. var chld: TDomNode;
  5.     s   : ansistring;
  6.     i   : Integer;
  7.     att : String;     // <-- add
  8. ...
  9.              if s='A'then     // <-- Replace the "if s='A'" part by the following code:
  10.                begin
  11.                   //printattributes(chld,'');
  12.                   checkattributes(chld,'HREF',localname,filelist);
  13.                   att := 'NAME';
  14.                   s := findattribute(chld, att);
  15.                   if s = '' then begin
  16.                     att := 'ID';
  17.                     s := findattribute(chld, att);
  18.                   end;
  19.                   if s <> '' then
  20.                     begin
  21.                       i := fAnchorList.IndexOf(localname+'#'+s);
  22.                       if i < 0 then begin
  23.                         fAnchorList.Add(localname+'#'+s);
  24.                         Error(ChmNote,'New Anchor with '+att+' '+s+' found while scanning '+localname,1);
  25.                       end else if fAnchorList.Objects[i] = nil then
  26.                         Error(chmwarning,'Duplicate anchor definitions with '+att+' '+s+' found while scanning '+localname,1)
  27.                       else begin
  28.                         fAnchorList.Objects[i].Free;
  29.                         fAnchorList.Objects[i] := nil;
  30.                         Error(ChmNote,'Anchor with '+att+' '+s+' defined while scanning '+localname,1);
  31.                       end;
  32.                     end;
  33.                 end;
  34. ...

Running chmcmd for the provided chm project after this modification is fine without any errors or warnings.


marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11453
  • FPC developer.
Re: Non blocking bugs in chmcmd
« Reply #3 on: July 19, 2017, 09:50:00 am »
r36747 please check.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Non blocking bugs in chmcmd
« Reply #4 on: July 19, 2017, 10:44:21 am »
Working fine. Thank you. Will it be backported, too?

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Non blocking bugs in chmcmd
« Reply #5 on: July 19, 2017, 01:19:59 pm »
Frozen?
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Non blocking bugs in chmcmd
« Reply #6 on: July 19, 2017, 01:35:15 pm »
What do you mean?

Mwoua

  • New Member
  • *
  • Posts: 16
Re: Non blocking bugs in chmcmd
« Reply #7 on: July 25, 2017, 04:45:51 pm »
Has it been merged to trunk ?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11453
  • FPC developer.
Re: Non blocking bugs in chmcmd
« Reply #8 on: July 25, 2017, 04:49:17 pm »
Yes

Mwoua

  • New Member
  • *
  • Posts: 16
Re: Non blocking bugs in chmcmd
« Reply #9 on: July 25, 2017, 09:44:31 pm »
I've tried running the new version on my project, I have fewer errors (by much), but all remaining error are reported as

Anchor xxx undefined; first use Site Map for enumName

What does "Site Map" means ? ( it should be a file name)
« Last Edit: July 25, 2017, 09:53:34 pm by Mwoua »

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Non blocking bugs in chmcmd
« Reply #10 on: July 25, 2017, 10:42:11 pm »
Same story again: please assemble a little chm project which shows the issue and upload it here.

Mwoua

  • New Member
  • *
  • Posts: 16
Re: Non blocking bugs in chmcmd
« Reply #11 on: July 25, 2017, 10:50:13 pm »
I'm trying to make a small project to show the bug, but since I dont know the exact file that cause the issue, it's a bit harder.

And the words "Site Map" are nowhere in my code/project, so I guessed it's something specific to chmcmd.

EDIT : managed to made a small example (see attached file)
« Last Edit: July 25, 2017, 10:58:55 pm by Mwoua »

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Non blocking bugs in chmcmd
« Reply #12 on: July 26, 2017, 01:37:23 pm »
I'm a bit lost...

I think the phrase "Site map" refers to Index and Contents pages of the chm file here.

I temporarily removed the items "Contents file" and "Index file" from the Options section of the hhp file which resulted in successful compilation and confirmed this idea. After successive restoring these item I found out that the contents file is the guilty one.

Then I removed all <LI> nodes from the index.hhc file (--> successful compilation) and restored them successively until the compilation error returned.

The first item which triggered the compilation error was:
Quote
      <LI><OBJECT type="text/sitemap"><param name="Name" value="dwBytesToWrite"><param name="Local" value="_ld_spi_f_t_d_i_8cpp.html#af8bac4f0406d0ddd199751ecbce27708"><param name="ImageNumber" value="11"></OBJECT>

This means that the item "dwBytesToWrite" of the Contents page links to the anchor "#af8bac4f0406d0ddd199751ecbce27708" in file "_ld_spi_f_t_d_i_8cpp.html". But this anchor is not defined in this file - therefore the error message is correct. Instead, the anchor is declared in file "namespace_f_t_d_i_af8bac4f0406d0ddd199751ecbce27708.html". I don't know to make a logical connection between these two files - although there must be one because MS HTML Help workshop compile the project without any issues.

But maybe they are doing something similar what I am proposing now as a workaround: Compile the project with the option --no-html-scan. With it the project can be compiled successfully.

The problem is that you must specify all files in the "Files" section of the hhp project, like we had discussed in the other thread.

Maybe procedure TChmProject.ShowUndefinedAnchors which is bypassed if no-html-scan is set should be modified to show a warning instead of an error in case of a missing file?

Code: Pascal  [Select][+][-]
  1. procedure TChmProject.ShowUndefinedAnchors;
  2. var
  3.   i:Integer;
  4. begin
  5.   for i := 0 to fAnchorList.Count-1 do
  6.     if fAnchorList.Objects[i] <> nil then
  7.       Error(chmwarning,'Anchor '+fAnchorList[i]+' undefined; first use '+TFirstReference(fAnchorList.Objects[i]).Location);
  8.       // was: chmerror
  9. end;


marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11453
  • FPC developer.
Re: Non blocking bugs in chmcmd
« Reply #13 on: July 26, 2017, 02:05:58 pm »
Site map in CHM speak is TOC or Index. (they have a common XML format).

So my guess is that something isn't right with the url of enumname in TOC or Index (.hhk/hhi)

 

TinyPortal © 2005-2018