View Issue Details

IDProjectCategoryView StatusLast Update
0037814FPCRTLpublic2020-09-25 10:51
ReporterFelis-Sapiens Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.2.0 
Fixed in Version3.2.1 
Summary0037814: TStringHelper function LastIndexOf considers wrong number of characters
Description'abcd'.LastIndexOf('ab', 3, 3) returns 0 instead of -1
Steps To Reproduceprogram 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 InformationShould be
  M:=AStartIndex-ACount+2; // 1 based
in function TStringHelper.LastIndexOf(const AValue: string; AStartIndex: SizeInt; ACount: SizeInt): SizeInt;
TagsNo tags attached.
Fixed in Revision46951
FPCOldBugId
FPCTarget3.2.2
Attached Files

Activities

Michael Van Canneyt

2020-09-25 10:51

administrator   ~0125837

Checked, applied and tested. Thanks for the patch !

Issue History

Date Modified Username Field Change
2020-09-25 10:25 Felis-Sapiens New Issue
2020-09-25 10:38 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-09-25 10:38 Michael Van Canneyt Status new => assigned
2020-09-25 10:51 Michael Van Canneyt Status assigned => resolved
2020-09-25 10:51 Michael Van Canneyt Resolution open => fixed
2020-09-25 10:51 Michael Van Canneyt Fixed in Version => 3.2.1
2020-09-25 10:51 Michael Van Canneyt Fixed in Revision => 46951
2020-09-25 10:51 Michael Van Canneyt FPCTarget => 3.2.2
2020-09-25 10:51 Michael Van Canneyt Note Added: 0125837