For a string that ends with the delimiter, split returns one string too little.
Original Reporter info from Mantis: SergeAnvarov @SergeAnvarov
-
Reporter name: Serge Anvarov
Original Reporter info from Mantis: SergeAnvarov @SergeAnvarov
- Reporter name: Serge Anvarov
Description:
Continue 0035663
Steps to reproduce:
{$APPTYPE CONSOLE}
{IFDEF FPC}{
MODE DELPHI}{$ENDIF}
uses SysUtils;
const
CA: array[0..7] of string = ('F0;F1;F2', ';F1;F2', ';;F2', 'F0;;F2', ';;', 'F0;F1;', 'F0;;', ';F1;');
var
S: string;
A: TArray<string>;
begin
for S in CA do
begin
A := S.Split([';']);
Writeln(S, ' = ':12-Length(S), Length(A));
end;
Readln;
end.
Additional information:
This project shows four "3" and four "2". But should always show "3" as it is done in Delphi.
I think the error is somewhere in the borders instead of "<=" is used strictly "<".
FPC 3.3.1 same error.
Mantis conversion info:
- Mantis ID: 35669
- Platform: Windows
- Version: 3.0.4
- Fixed in version: 3.3.1
- Fixed in revision: 42168 (#de30f785)
- Target version: 3.2.0