Changeset 43 for trunk/NewView


Ignore:
Timestamp:
Jan 2, 2007, 8:29:54 PM (19 years ago)
Author:
RBRi
Message:

% use new debug unit

Location:
trunk/NewView
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/NewView/GlobalSearchForm.pas

    r32 r43  
    142142uses
    143143  SysUtils,
     144  DebugUnit,
    144145  ACLFileUtility,
    145   ACLProfile,
    146146  ACLDialogs,
    147147  ControlsUtility,
     
    499499  MatchingTopics := TList.Create;
    500500
    501   ProfileEvent( 'Getting files' );
     501  LogEvent(LogParse, 'Getting files');
    502502
    503503  // make sure we ignore duplicate files...
     
    535535  end;
    536536
    537   ProfileEvent( ' Searching ' + IntToStr( Files.Count ) + ' files' );
     537  LogEvent(LogParse, ' Searching ' + IntToStr( Files.Count ) + ' files');
    538538  for FileIndex := 0 to Files.Count - 1 do
    539539  begin
     
    541541      break;
    542542    Filename := Files[ FileIndex ];
    543     ProfileEvent( Filename );
     543    LogEvent(LogParse, Filename);
    544544    ThreadManager.UpdateProgress( 10 + FileIndex * 95 div Files.Count,
    545545                                  100,
     
    553553
    554554    try
    555       ProfileEvent( ' Create THelpFile' );
     555      LogEvent(LogParse, ' Create THelpFile');
    556556      HelpFile := THelpFile.Create( FileName );
    557557
    558       ProfileEvent( ' Helpfile created' );
     558      LogEvent(LogParse, ' Helpfile created');
    559559      MatchingTopics.Clear;
    560560
    561       ProfileEvent( ' Search file' );
     561      LogEvent(LogParse, ' Search file');
    562562      SearchHelpFile( HelpFile,
    563563                      Query,
     
    568568      if MatchingTopics.Count > 0 then
    569569      begin
    570         ProfileEvent( '  Sort results' );
     570        LogEvent(LogParse, '  Sort results');
    571571        // Create a searchresult object to send back to main thread.
    572572        SearchResult := TSearchResult.Create;
     
    577577
    578578        SearchResult.MatchingTopics.Sort( TopicRelevanceCompare );
    579         ProfileEvent( '  Display results' );
     579        LogEvent(LogParse, '  Display results');
    580580
    581581        ThreadManager.SendData( '', SearchResult );
    582582      end;
    583583
    584       ProfileEvent( 'Unload helpfile' );
     584      LogEvent(LogParse, 'Unload helpfile');
    585585      HelpFile.Destroy;
    586586
     
    598598
    599599  end;
    600   ProfileEvent( 'search completed' );
     600  LogEvent(LogParse, 'search completed');
    601601  ThreadManager.UpdateProgress( 100, 100, DoneMsg );
    602602  Files.Destroy;
     
    608608
    609609  Result := nil;
    610   ProfileEvent( 'done' );
     610  LogEvent(LogParse, 'done');
    611611End;
    612612
  • trunk/NewView/HelpFile.pas

    r32 r43  
    156156uses
    157157  BseErr,
     158  DebugUnit,
    158159  ACLStringUtility,
    159160  ACLFileIOUtility,
    160   ACLProfile,
    161161  ACLLanguageUnit;
    162162
     
    220220constructor THelpFile.Create( const FileName: string );
    221221begin
    222   ProfileEvent( 'Helpfile Load: ' + FileName );
     222  LogEvent(LogParse, 'Helpfile Load: ' + FileName);
    223223
    224224  _FileName := FileName;
     
    338338procedure THelpFile.ReadHeader;
    339339begin
    340   ProfileEvent( 'Read header' );
     340  LogEvent(LogParse, 'Read header');
    341341
    342342  ReadFileBlock( _pHeader,
     
    371371  pEnd: pTTOCEntryStart;
    372372begin
    373   ProfileEvent( 'Read contents' );
     373  LogEvent(LogParse, 'Read contents');
    374374
    375375  if _pHeader^.ntoc = 0 then
     
    420420  pEnd: pbyte;
    421421begin
    422   ProfileEvent( 'Read dictionary' );
     422  LogEvent(LogParse, 'Read dictionary');
    423423
    424424  if _pHeader^.ndict = 0 then
     
    475475  pIndexData: pointer;
    476476begin
    477   ProfileEvent( 'Read index' );
     477  LogEvent(LogParse, 'Read index');
    478478
    479479  _Index := TStringList.Create;
     
    529529  SearchTableRecordLengthIs16Bit: boolean;
    530530begin
    531   ProfileEvent( 'Read search table' );
     531  LogEvent(LogParse, 'Read search table');
    532532
    533533  if _pHeader^.SearchLen = 0 then
    534534  begin
    535     ProfileEvent( 'Read search table' );
     535    LogEvent(LogParse, 'Read search table (len = 0');
    536536    exit;
    537537  end;
  • trunk/NewView/HelpTopic.pas

    r38 r43  
    253253uses
    254254  SysUtils,
    255   ACLUtility, ACLStringUtility, ACLProfile, ACLFileIOUtility,
     255  ACLUtility, ACLStringUtility, ACLFileIOUtility,
    256256  AStringUtilityUnit,
    257257  ACLLanguageUnit,
  • trunk/NewView/SearchUnit.pas

    r33 r43  
    4848uses
    4949  SysUtils,
     50  DebugUnit,
    5051  ACLStringUtility,
    51   ACLProfile,
    5252  HelpTopic;
    5353
     
    360360    Term := Query.Term[ TermIndex ];
    361361
    362     ProfileEvent( 'Searching for term "'
     362    LogEvent(LogSearch, 'Searching for term "'
    363363                  + Term.Text
    364364                  + '", '
     
    379379      TermPart := Term.Parts[ TermPartIndex ];
    380380
    381       ProfileEvent( '  Searching for [' + TermPart + ']' );
     381      LogEvent(LogSearch, '  Searching for [' + TermPart + ']' );
    382382
    383383      AllocUInt32Array( DictionaryRelevances,
     
    416416      // this search term part, search topic texts
    417417
    418       ProfileEvent( '  Dictionary search done' );
     418      LogEvent(LogSearch, '  Dictionary search done' );
    419419      ClearUInt32Array( TopicsMatchingTermPart,
    420420                        TopicCount );
     
    441441      end;
    442442
    443       ProfileEvent( 'TOpic searches done' );
     443      LogEvent(LogSearch, 'Topic searches done' );
    444444
    445445      if TermPartIndex = 0 then
     
    460460    // for all parts of the term. Now combine all together
    461461
    462     ProfileEvent( 'Checking for sequences' );
     462    LogEvent(LogSearch, 'Checking for sequences' );
    463463    for TopicIndex := 0 to TopicCount - 1 do
    464464    begin
     
    494494    // Search titles and index
    495495
    496     ProfileEvent( '  Searching titles' );
     496    LogEvent(LogSearch, '  Searching titles' );
    497497    SearchTopicTitles( HelpFile, Term.Text, TopicsMatchingTerm );
    498498
    499     ProfileEvent( '  Searching index' );
     499    LogEvent(LogSearch, '  Searching index' );
    500500    SearchIndex( HelpFile, Term.Text, TopicsMatchingTerm );
    501501
    502     ProfileEvent( '  Combining' );
     502    LogEvent(LogSearch, '  Combining' );
    503503    case Term.CombineMethod of
    504504      cmOptional:
     
    530530  end;
    531531
    532   ProfileEvent( 'Search completed, converting to list' );
     532  LogEvent(LogSearch, 'Search completed, converting to list' );
    533533
    534534  // Now convert to list form.
     
    547547  end;
    548548
    549   ProfileEvent( 'Freeing arrays' );
     549  LogEvent(LogSearch, 'Freeing arrays' );
    550550  FreeUInt32Array( TopicRelevances, TopicCount );
    551551  FreeUInt32Array( TopicsExcluded, TopicCount );
     
    554554  FreeUInt32Array( TopicsMatchingDictWord, TopicCount );
    555555
    556   ProfileEvent( 'Done' );
     556  LogEvent(LogSearch, 'Done' );
    557557end;
    558558
  • trunk/NewView/SettingsUnit.pas

    r33 r43  
    137137Uses
    138138  SysUtils,
     139  DebugUnit,
    139140  Dos,
    140141  ACLFileUtility,
    141142  ACLUtility,
    142143  ACLStringUtility,
    143   ACLProfile,
    144144  ControlsUtility;
    145145
     
    192192begin
    193193  try
    194     ProfileEvent( 'Calling IniFile.Destroy' );
     194    LogEvent(LogSettings, 'Calling IniFile.Destroy');
    195195    IniFile.Destroy;
    196196  except
     
    198198    begin
    199199      // don't care if we can't save settings.
    200       ProfileEvent( '  Exception: ' + E.Message );
     200      LogEvent(LogSettings, '  Exception: ' + E.Message );
    201201    end;
    202202  end;
     
    416416
    417417Begin
    418   ProfileEvent( 'SaveSettings' );
     418  LogEvent(LogSettings, 'SaveSettings' );
    419419  GetIniFile( IniFile );
    420420  with IniFile do
     
    563563  end;
    564564  CloseIniFile( IniFile );
    565   ProfileEvent( ' Done' );
     565  LogEvent(LogSettings, ' Done' );
    566566
    567567End;
  • trunk/NewView/StartupUnit.pas

    r25 r43  
    5050  Dos,
    5151  SysUtils,
     52  DebugUnit,
    5253  PMWin,
    5354  ACLUtility,
     
    5556  ACLFileUtility,
    5657  AStringUtilityUnit,
    57   ACLProfile,
    5858  HelpManagerUnit;
    5959
     
    6767  EnvironmentVarValue: string;
    6868begin
    69   ProfileEvent( 'Translating environment vars' );
     69  LogEvent(LogStartup, 'Translating environment vars' );
    7070  for i := 0 to Items.Count - 1 do
    7171  begin
     
    7575    Item := StrUnDoubleQuote( Item ); // remove double quotes
    7676
    77     ProfileEvent( '  Item: ' + Item );
     77    LogEvent(LogStartup, '  Item: ' + Item );
    7878    EnvironmentVarValue := GetEnv( Uppercase( Item ) );
    7979    if DosError = 0 then
    8080    begin
    8181      // environment var exists - use it's value
    82       ProfileEvent( '    Translated: ' + EnvironmentVarValue );
     82      LogEvent(LogStartup, '    Translated: ' + EnvironmentVarValue );
    8383      while EnvironmentVarValue <> '' do
    8484      begin
     
    251251  Filenames := TStringList.Create;
    252252
    253   StringToList(cmdLineParameters.getFileNames, FileItems, '+' );
     253  StringToList(CmdLineParameters.getFileNames, FileItems, '+' );
    254254  TranslateIPFEnvironmentVars( FileItems, FileNames );
    255255
     
    320320var
    321321  tmpCmdLine: String;
    322   tmpSplittedCmdLine : TStringList;
    323322  tmpRc : Integer;
    324323
     
    333332  // parse parameters into Parameters object
    334333  tmpCmdLine := nativeOS2GetCmdLineParameter;
    335   tmpSplittedCmdLine := TStringList.Create;
    336   tmpRc := splitCmdLineParameter(tmpCmdLine, tmpSplittedCmdLine);
    337334
    338335  CmdLineParameters := TCmdLineParameters.Create;
    339   CmdLineParameters.parseCmdLine(tmpSplittedCmdLine);
    340 
    341   tmpSplittedCmdLine.Destroy;
     336  CmdLineParameters.parseCmdLine(tmpCmdLine);
    342337
    343338  ExistingWindow := FindExistingWindow;
     
    355350    WinSetFocus( HWND_DESKTOP, ExistingWindow );
    356351
    357     if CmdLineParameters.getTopics <> '' then
     352    // if CmdLineParameters.getTopics <> '' then
     353    if not CmdLineParameters.getSearchFlag AND not CmdLineParameters.getGlobalSearchFlag then
    358354    begin
    359355      PostNewViewTextMessage( ExistingWindow,
    360356                              NHM_SEARCH,
    361                               CmdLineParameters.getTopics);
    362     end;
    363 
    364     if CmdLineParameters.getGlobalSearchTextFlag then
     357                              CmdLineParameters.getSearchText);
     358    end;
     359
     360    if CmdLineParameters.getGlobalSearchFlag then
    365361    begin
    366362      PostNewViewTextMessage( ExistingWindow,
    367363                              NHM_GLOBAL_SEARCH,
    368                               CmdLineParameters.getGlobalSearchText );
     364                              CmdLineParameters.getSearchText );
    369365    end;
    370366
  • trunk/NewView/StringUtilsUnit.pas

    r35 r43  
    1212 Classes;
    1313
    14  TYPE
     14const
     15  StrCR = chr(13);
     16  StrLF = chr(10);
     17  StrCRLF = StrCR + StrLF;
     18
     19
     20  TYPE
    1521     TSerializableStringList = class
    1622     private
     
    2733  end;
    2834
     35  TYPE
     36    TSetOfChars = set of char;
     37
    2938  // prefices all occurences of one of the chars in aStringWithChars with anEscape char
    3039  // if the escapeChar itself is found, then it is doubled
    31   Function escapeAllCharsBy(Const aReceiver: String; const aStringWithChars: String; const anEscapeChar: char): String;
     40  Function StrEscapeAllCharsBy(Const aReceiver: String; const aSetOfChars: TSetOfChars; const anEscapeChar: char): String;
     41
     42  // Extract all fields in a String given a set of delimiter characters and
     43  // an optional escape character usable to escape field delimits.
     44  // Example:
     45  //     StrExtractStrings('1x2x3\x4', "x", '\') ->
     46  //     returns 4 strings: "1", "", "2" and "3x4"
     47  Procedure StrExtractStrings(Var aResult : TStringList; Const aReceiver: String; const aSetOfChars: TSetOfChars; const anEscapeChar: char);
     48
     49  // removes all occurences of char from aSetOfChars from the beginning
     50  // end the end of a String.
     51  Function StrTrimChars(const aReceiver: String; const aSetOfChars: TSetOfChars): String;
     52
     53  // removes all blanks from beginning and end
     54  Function StrTrim(const aReceiver: String): String;
     55
     56  // returns true if the String ends with the provides one
     57  // this is case SENSITIVE
     58  Function StrEndsWith(const aReceiver: String; const anEndString: String): Boolean;
     59
     60  // returns true if the String ends with the provides one
     61  // this is case INsensitive
     62  Function StrEndsWithIgnoringCase(const aString: String; const anEndString: String): Boolean;
     63
    3264
    3365Implementation
     
    71103    begin
    72104      if (i > 0) then result := result + '&';
    73       result := result + escapeAllCharsBy(stringList[i], '&', '\');
     105      result := result + StrEscapeAllCharsBy(stringList[i], ['&'], '\');
    74106    end;
    75107  end;
     
    77109
    78110  PROCEDURE TSerializableStringList.readValuesFromSerializedString(const aSerializedString : String);
     111  Begin
     112    if (length(aSerializedString) < 1) then exit;
     113
     114    stringList.destroy;
     115    stringList := TStringList.Create;
     116    StrExtractStrings(stringList, aSerializedString, ['&'], '\');
     117  end;
     118
     119
     120  // ----------------------------------------------------------
     121
     122
     123  Function StrEscapeAllCharsBy(Const aReceiver: String; const aSetOfChars: TSetOfChars; const anEscapeChar: char): String;
     124  Var
     125    i : Integer;
     126    tmpChar : Char;
     127  Begin
     128    Result := '';
     129
     130    for i := 1 To length(aReceiver) do
     131    begin
     132      tmpChar := aReceiver[i];
     133
     134      if (tmpChar = anEscapeChar) or (tmpChar IN aSetOfChars) then
     135        result := result + anEscapeChar + tmpChar
     136      else
     137        result := result + tmpChar;
     138    end;
     139  end;
     140
     141
     142  Procedure StrExtractStrings(Var aResult: TStringList; Const aReceiver: String; const aSetOfChars: TSetOfChars; const anEscapeChar: char);
    79143  Var
    80144    i : Integer;
    81145    tmpChar,tmpNextChar : Char;
    82146    tmpPart: String;
    83   begin
    84     if (length(aSerializedString) < 1) then exit;
    85 
    86     stringList.destroy;
    87     stringList := TStringList.Create;
     147  Begin
     148    if (length(aReceiver) < 1) then exit;
     149
    88150    tmpPart := '';
    89151
    90152    i := 1;
    91     while i <= length(aSerializedString) do
    92     begin
    93       tmpChar := aSerializedString[i];
    94       if i < length(aSerializedString) then
    95         tmpNextChar := aSerializedString[i+1]
     153    while i <= length(aReceiver) do
     154    begin
     155      tmpChar := aReceiver[i];
     156      if i < length(aReceiver) then
     157        tmpNextChar := aReceiver[i+1]
    96158      else
    97159        tmpNextChar := #0;
    98160
    99       if (tmpChar = '\') and (tmpNextChar = '\') then
     161      if (tmpChar = anEscapeChar) and (tmpNextChar = anEscapeChar) then
    100162      begin
    101         tmpPart := tmpPart + '\';
     163        tmpPart := tmpPart + anEscapeChar;
    102164        i := i + 2;
    103165      end
    104166      else
    105         if (tmpChar = '\') and (tmpNextChar = '&') then
     167        if (tmpChar = anEscapeChar) and (tmpNextChar IN aSetOfChars) then
    106168        begin
    107           tmpPart := tmpPart + '&';
     169          tmpPart := tmpPart + tmpNextChar;
    108170          i := i + 2;
    109171        end
    110172        else
    111           if (tmpChar = '&') then
     173          if (tmpChar IN aSetOfChars) then
    112174          begin
    113             stringList.add(tmpPart);
     175            aResult.add(tmpPart);
    114176            tmpPart := '';
    115177            i := i + 1;
     
    121183          end;
    122184    end;
    123     stringList.add(tmpPart);
    124   end;
    125 
    126   // ----------------------------------------------------------
    127 
    128   Function escapeAllCharsBy(Const aReceiver: String; const aStringWithChars: String; const anEscapeChar: char): String;
    129   Var
    130     i : Integer;
    131     tmpChar : Char;
    132   Begin
    133     Result := '';
    134 
    135     if (length(aStringWithChars) > 0) then
    136     begin
    137       for i := 1 To length(aReceiver) do
     185    aResult.add(tmpPart);
     186  end;
     187
     188
     189  Function StrTrimChars(const aReceiver: String; const aSetOfChars: TSetOfChars): String;
     190  Var
     191    i : Longint;
     192    j : Longint;
     193  Begin
     194    i := 1;
     195    while i < Length(aReceiver) do
     196    begin
     197      if aReceiver[i] in aSetOfChars then
     198        inc(i)
     199       else
     200         break;
     201    end;
     202
     203    j := Length(aReceiver);
     204    while j >= i do
     205    begin
     206      if aReceiver[j] in aSetOfChars then
     207        dec(j)
     208      else
     209        break;
     210    end;
     211
     212    result := Copy(aReceiver, i, j-i+1);
     213  end;
     214
     215
     216  Function StrTrim(const aReceiver: String): String;
     217  Begin
     218    result := StrTrimChars(aReceiver, [' ']);
     219  end;
     220
     221
     222  Function StrEndsWith(const aReceiver: String; const anEndString: String): Boolean;
     223  Var
     224    tmpStringPos : Longint;
     225    tmpMatchPos : Longint;
     226  Begin
     227    tmpStringPos := length(aReceiver);
     228    tmpMatchPos := length(anEndString);
     229
     230    if tmpMatchPos > tmpStringPos then
     231    begin
     232      result := false;
     233      exit;
     234    end;
     235
     236    while tmpMatchPos > 0 do
     237    begin
     238      if aReceiver[tmpStringPos] <> anEndString[tmpMatchPos] then
    138239      begin
    139         tmpChar := aReceiver[i];
    140 
    141         if ((tmpChar = anEscapeChar) or (pos(tmpChar, aStringWithChars) > 0)) then
    142           result := result + anEscapeChar + tmpChar
    143         else
    144           result := result + tmpChar;
     240        result := false;
     241        exit;
    145242      end;
    146     end;
     243      dec(tmpMatchPos);
     244      dec(tmpStringPos);
     245    end;
     246
     247    result := true;
     248  end;
     249
     250
     251  Function StrEndsWithIgnoringCase(const aReceiver: String; const anEndString: String): Boolean;
     252  Var
     253    tmpStringPos : Longint;
     254    tmpMatchPos : Longint;
     255  Begin
     256    tmpStringPos := length(aString);
     257    tmpMatchPos := length(anEndString);
     258
     259    if tmpMatchPos > tmpStringPos then
     260    begin
     261      result := false;
     262      exit;
     263    end;
     264
     265    while tmpMatchPos > 0 do
     266    begin
     267      if upcase(aString[tmpStringPos]) <> upcase(anEndString[tmpMatchPos]) then
     268      begin
     269        result := false;
     270        exit;
     271      end;
     272      dec(tmpMatchPos);
     273      dec(tmpStringPos);
     274    end;
     275
     276    result := true;
    147277  end;
    148278
Note: See TracChangeset for help on using the changeset viewer.