Browse Source

* more little fixes from initial testing. Mostly errormessages and .hhp defaults.
chmls -n switch

git-svn-id: trunk@15578 -

marco 15 years ago
parent
commit
526c9e2eaf
3 changed files with 37 additions and 10 deletions
  1. 23 6
      packages/chm/src/chmcmd.lpr
  2. 4 0
      packages/chm/src/chmfilewriter.pas
  3. 10 4
      packages/chm/src/chmls.lpr

+ 23 - 6
packages/chm/src/chmcmd.lpr

@@ -121,23 +121,40 @@ begin
     begin
     begin
       xmlname:=changefileext(name,'.hhp.xml');
       xmlname:=changefileext(name,'.hhp.xml');
       Project.OnError:=@OnError;
       Project.OnError:=@OnError;
-      Project.LoadFromHHP(name,false) ;          // we need a param for this second param later
-      project.ScanHtmlContents:=htmlscan<>scanforcedno;  // .hhp default SCAN
-      if GenerateXMLForHHP then
-       begin
-         Writeln('Generating XML ',xmlname,'.');
-         Project.SaveToFile(xmlname);
+      try
+        Project.LoadFromHHP(name,false) ;          // we need a param for this second param later
+       except
+         on e:exception do
+           begin
+             Writeln('This HHP CHM project seems corrupt, please check it ',name);
+             halt(1);
+           end;
        end;
        end;
+      project.ScanHtmlContents:=htmlscan<>scanforcedno;  // .hhp default SCAN
     end
     end
   else
   else
     begin
     begin
+     try
       project.ScanHtmlContents:=htmlscan=scanforce;  // .hhp default SCAN
       project.ScanHtmlContents:=htmlscan=scanforce;  // .hhp default SCAN
       Project.LoadFromFile(name);
       Project.LoadFromFile(name);
+     except
+       on e:exception do
+         begin
+           Writeln('This XML CHM project seems corrupt, please check it ',name);
+           halt(1);
+         end;
+       end;
     end;
     end;
   OutStream := TFileStream.Create(Project.OutputFileName, fmCreate, fmOpenWrite);
   OutStream := TFileStream.Create(Project.OutputFileName, fmCreate, fmOpenWrite);
   Project.WriteChm(OutStream);
   Project.WriteChm(OutStream);
+  if ishhp and GenerateXMLForHHP then
+    begin
+      Writeln('Generating XML ',xmlname,'.');
+      Project.SaveToFile(xmlname);
+    end;
   OutStream.Free;
   OutStream.Free;
   Project.Free;
   Project.Free;
+
 end;
 end;
 
 
 var
 var

+ 4 - 0
packages/chm/src/chmfilewriter.pas

@@ -272,6 +272,7 @@ begin
       OPTERROR_LOG_FILE            : ;
       OPTERROR_LOG_FILE            : ;
       OPTFLAT                      : ;
       OPTFLAT                      : ;
       OPTFULL_TEXT_SEARCH_STOP_LIST: ;
       OPTFULL_TEXT_SEARCH_STOP_LIST: ;
+      OPTFULL_TEXT_SEARCH          : MakeSearchable:=optvalupper='YES';
       OPTIGNORE                    : ;
       OPTIGNORE                    : ;
       OPTINDEX_FILE                : Indexfilename:=optval;
       OPTINDEX_FILE                : Indexfilename:=optval;
       OPTLANGUAGE                  : ;
       OPTLANGUAGE                  : ;
@@ -390,6 +391,9 @@ var i,j : integer;
     node: TCHMContextNode;
     node: TCHMContextNode;
     keyupper : string;
     keyupper : string;
 begin
 begin
+ { Defaults other than global }
+   MakeBinaryIndex:=True;
+
  {$ifdef hhp_debug}
  {$ifdef hhp_debug}
    writeln('alias entry:',key,'=',value);
    writeln('alias entry:',key,'=',value);
  {$endif}
  {$endif}

+ 10 - 4
packages/chm/src/chmls.lpr

@@ -35,8 +35,9 @@ type
   { TJunkObject }
   { TJunkObject }
 
 
   TJunkObject = class
   TJunkObject = class
-    Section : Integer;
-    count   : integer;
+    Section  : Integer;
+    count    : integer;
+    donotpage: boolean;
     procedure OnFileEntry(Name: String; Offset, UncompressedSize, ASection: Integer);
     procedure OnFileEntry(Name: String; Offset, UncompressedSize, ASection: Integer);
   end;
   end;
 
 
@@ -56,6 +57,7 @@ begin
   writeln(stderr);
   writeln(stderr);
   writeln(stderr,'Switches : ');
   writeln(stderr,'Switches : ');
   writeln(stderr,' -h, --help  : this screen');
   writeln(stderr,' -h, --help  : this screen');
+  writeln(stderr,' -n          : do not page list output');
   writeln(stderr);
   writeln(stderr);
   writeln(stderr,'Where command is one of the following or if omitted, equal to LIST.');
   writeln(stderr,'Where command is one of the following or if omitted, equal to LIST.');
   writeln(stderr,' list     <filename> [section number] ');
   writeln(stderr,' list     <filename> [section number] ');
@@ -103,7 +105,7 @@ procedure TJunkObject.OnFileEntry(Name: String; Offset, UncompressedSize,
 begin
 begin
   Inc(Count);
   Inc(Count);
   if (Section > -1) and (ASection <> Section) then Exit;
   if (Section > -1) and (ASection <> Section) then Exit;
-  if (Count = 1) or (Count mod 40 = 0) then
+  if (Count = 1) or ((Count mod 40 = 0) and not donotpage) then
     WriteLn(StdErr, '<Section> <Offset> <UnCompSize>  <Name>');
     WriteLn(StdErr, '<Section> <Offset> <UnCompSize>  <Name>');
   Write(' ');
   Write(' ');
   Write(ASection);
   Write(ASection);
@@ -115,6 +117,8 @@ begin
   WriteLn(Name);
   WriteLn(Name);
 end;
 end;
 
 
+var donotpage:boolean=false;
+
 procedure ListChm(Const Name:string;Section:Integer);
 procedure ListChm(Const Name:string;Section:Integer);
 var
 var
   ITS: TITSFReader;
   ITS: TITSFReader;
@@ -132,6 +136,7 @@ begin
   JunkObject := TJunkObject.Create;
   JunkObject := TJunkObject.Create;
   JunkObject.Section:=Section;
   JunkObject.Section:=Section;
   JunkObject.Count:=0;
   JunkObject.Count:=0;
+  JunkObject.DoNotPage:=DoNotPage;
 
 
   ITS:= TITSFReader.Create(Stream, True);
   ITS:= TITSFReader.Create(Stream, True);
   ITS.GetCompleteFileList(@JunkObject.OnFileEntry);
   ITS.GetCompleteFileList(@JunkObject.OnFileEntry);
@@ -217,7 +222,7 @@ begin
   Writeln(stderr,'chmls, a CHM utility. (c) 2010 Free Pascal core.');
   Writeln(stderr,'chmls, a CHM utility. (c) 2010 Free Pascal core.');
   Writeln(Stderr);
   Writeln(Stderr);
   repeat
   repeat
-    c:=getlongopts('h',@theopts[1],optionindex);
+    c:=getlongopts('hn',@theopts[1],optionindex);
     case c of
     case c of
       #0 : begin
       #0 : begin
              case optionindex-1 of
              case optionindex-1 of
@@ -227,6 +232,7 @@ begin
                    end;
                    end;
                 end;
                 end;
            end;
            end;
+      'n'     : donotpage:=true;
       '?','h' :
       '?','h' :
             begin
             begin
               writeln('unknown option',optopt);
               writeln('unknown option',optopt);