fix, AV in string ranges

This commit is contained in:
Basile Burg 2016-03-19 00:05:35 +01:00
parent 1bd6099f10
commit cea5cf757b
3 changed files with 13 additions and 3 deletions

View File

@ -24,7 +24,7 @@ inherited CEMessagesWidget: TCEMessagesWidget
Width = 759 Width = 759
Align = alClient Align = alClient
BorderSpacing.Around = 2 BorderSpacing.Around = 2
DefaultItemHeight = 18 DefaultItemHeight = 16
Font.Height = -12 Font.Height = -12
Font.Name = 'Courier New' Font.Name = 'Courier New'
Font.Quality = fqProof Font.Quality = fqProof

View File

@ -1002,6 +1002,8 @@ begin
rng.init(aMessg); rng.init(aMessg);
while true do while true do
begin begin
if rng.empty then
break;
idt := rng.popUntil(alp)^.takeWhile(alp).yield; idt := rng.popUntil(alp)^.takeWhile(alp).yield;
if idt = '' then if idt = '' then
exit; exit;
@ -1017,11 +1019,14 @@ var
lne: string; lne: string;
col: string = ''; col: string = '';
begin begin
Result := Point(-1,-1);
if aMessage.isEmpty then
exit;
rng.init(aMessage); rng.init(aMessage);
rng.popUntil(['('])^.popWhile(['(']); rng.popUntil('(')^.popWhile('(');
lne := rng.takeUntil([',', ':', ')']).yield; lne := rng.takeUntil([',', ':', ')']).yield;
if rng.front in [',', ':'] then if rng.front in [',', ':'] then
col := rng.popWhile([',', ':'])^.takeUntil([')']).yield; col := rng.popWhile([',', ':'])^.takeUntil(')').yield;
result.y := strToIntDef(lne, -1); result.y := strToIntDef(lne, -1);
result.x := strToIntDef(col, -1); result.x := strToIntDef(col, -1);
end; end;

View File

@ -97,6 +97,11 @@ end;
function TStringRange.init(const str: string): PStringRange; function TStringRange.init(const str: string): PStringRange;
begin begin
ptr := nil;
pos := 0;
len := 0;
if str = '' then
exit;
ptr := @str[1]; ptr := @str[1];
pos := 0; pos := 0;
len := length(str); len := length(str);