View Issue Details

IDProjectCategoryView StatusLast Update
0034359FPCRTLpublic2018-09-30 13:30
ReporterBart BroersmaAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformi386OSWindowsOS Version10
Product Version3.3.1Product Buildr39840 
Target Version3.2.0Fixed in Version3.3.1 
Summary0034359: String.Split inconsitent behaviour if Separators is [chars] vs [strings]
DescriptionIf you use Array of String as separators as opposed to Array of Char, the result of String.Split differs.
In the case of strings, the last element is missing.
Steps To Reproduceprogram split;
{$mode objfpc}
{$h+}

uses
  sysutils;

var
  S: string;
  A: TStringArray;
  i: Integer;

begin
  S := '1 2 3 4 5';
  A := S.Split([0000032],'"');
  writeln('S = ',S,', Separators = 0000032');
  for i := Low(A) to High(A) do writeln(format('%d: "%s"',[i,A[i]]));
  writeln;

  S := '1\n2\n3\n4\n5';
  A := S.Split(['\n'],'"');
  writeln('S = ',S,', Separators = \n');
  for i := Low(A) to High(A) do writeln(format('%d: "%s"',[i,A[i]]));
end.

Output:
S = 1 2 3 4 5, Separators = 0000032
0: "1"
1: "2"
2: "3"
3: "4"
4: "5"

S = 1\n2\n3\n4\n5, Separators = \n
0: "1"
1: "2"
2: "3"
3: "4"
TagsNo tags attached.
Fixed in Revision39843
FPCOldBugId
FPCTarget
Attached Files

Activities

Bart Broersma

2018-09-29 23:34

reporter   ~0111092

Sorry, did not consider that Mantis uses the # for linking.
Unfortunatley I cannot edit that.

Michael Van Canneyt

2018-09-30 11:18

administrator   ~0111103

Fixed, thanks for reporting!

Bart Broersma

2018-09-30 13:30

reporter   ~0111107

That was quick!

Issue History

Date Modified Username Field Change
2018-09-29 23:33 Bart Broersma New Issue
2018-09-29 23:34 Bart Broersma Note Added: 0111092
2018-09-30 11:11 Michael Van Canneyt Assigned To => Michael Van Canneyt
2018-09-30 11:11 Michael Van Canneyt Status new => assigned
2018-09-30 11:18 Michael Van Canneyt Fixed in Revision => 39843
2018-09-30 11:18 Michael Van Canneyt Note Added: 0111103
2018-09-30 11:18 Michael Van Canneyt Status assigned => resolved
2018-09-30 11:18 Michael Van Canneyt Fixed in Version => 3.3.1
2018-09-30 11:18 Michael Van Canneyt Resolution open => fixed
2018-09-30 11:18 Michael Van Canneyt Target Version => 3.2.0
2018-09-30 13:30 Bart Broersma Note Added: 0111107
2018-09-30 13:30 Bart Broersma Status resolved => closed