TStringHelper function LastIndexOf considers wrong number of characters
Original Reporter info from Mantis: Felis-Sapiens
-
Reporter name:
Original Reporter info from Mantis: Felis-Sapiens
- Reporter name:
Description:
'abcd'.LastIndexOf('ab', 3, 3) returns 0 instead of -1
Steps to reproduce:
program last_index_text;
{$mode objfpc}{$h+}
uses SysUtils;
begin
// Search for last index of 'ab' in 'abcd'
// starting from 3rd (zero-based) character ('d')
// and considering only 3 characters ('bcd')
WriteLn('abcd'.LastIndexOf('ab', 3, 3));
// Result: 0
// Expected: -1
end.
Additional information:
Should be
M:=AStartIndex-ACount+2; // 1 based
in function TStringHelper.LastIndexOf(const AValue: string; AStartIndex: SizeInt; ACount: SizeInt): SizeInt;
Mantis conversion info:
- Mantis ID: 37814
- Version: 3.2.0
- Fixed in version: 3.2.1
- Fixed in revision: 46951 (#5198686c)
- Target version: 3.2.2