Changeset 7


Ignore:
Timestamp:
Sep 3, 2015, 1:32:33 PM (9 years ago)
Author:
chronos
Message:
  • Fixed: Proper evaluation of termination string.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/linetime.lpr

    r6 r7  
    3434    TermString: string;
    3535    TermStringIndex: Integer;
     36    procedure TermCheckString(Buffer: string);
    3637    function FindLineEnding(Buffer: string; var FoundLineEnding: string): Integer;
    3738    procedure WriteRaw(Text: string);
     
    118119end;
    119120
     121procedure TMyApplication.TermCheckString(Buffer: string);
     122var
     123  I: Integer;
     124begin
     125  // Search for termination string
     126  if TermString <> '' then
     127  for I := 1 to Length(Buffer) do begin
     128    if TermStringIndex > Length(TermString) then begin
     129      Terminate;
     130      Break;
     131    end;
     132    if Buffer[I] = TermString[TermStringIndex] then
     133      Inc(TermStringIndex)
     134      else TermStringIndex := 1;
     135  end;
     136end;
     137
    120138function TMyApplication.FindLineEnding(Buffer: string; var FoundLineEnding: string): Integer;
    121139const
     
    161179procedure TMyApplication.PrintOutput(Output: string);
    162180begin
     181  TermCheckString(Output);
    163182  if NewLine then begin
    164183    if not FirstLine then begin
     
    227246    end;
    228247
    229     // Search for termination string
    230     if TermString <> '' then
    231     for I := 1 to Length(Buffer) - 1 do begin
    232       if TermStringIndex > Length(TermString) then begin
    233         Terminate;
    234         Break;
    235       end;
    236       if Buffer[I] = TermString[TermStringIndex] then
    237         Inc(TermStringIndex)
    238         else TermStringIndex := 1;
    239     end;
    240248  until P = 0;
    241249  PrintOutput(Buffer);
Note: See TracChangeset for help on using the changeset viewer.