diff --git a/rtl/objpas/classes/classesh.inc b/rtl/objpas/classes/classesh.inc index 42224ec286..c9de0dcdce 100644 --- a/rtl/objpas/classes/classesh.inc +++ b/rtl/objpas/classes/classesh.inc @@ -609,6 +609,7 @@ type FUpdateCount: Integer; FAdapter: IStringsAdapter; FLBS : TTextLineBreakStyle; + FSkipLastLineBreak : Boolean; FStrictDelimiter : Boolean; FLineBreak : String; function GetCommaText: string; @@ -630,6 +631,8 @@ type Function GetQuoteChar: Char; Function GetLineBreak : String; procedure SetLineBreak(const S : String); + Function GetSkipLastLineBreak : Boolean; + procedure SetSkipLastLineBreak(const AValue : Boolean); protected procedure DefineProperties(Filer: TFiler); override; procedure Error(const Msg: string; Data: Integer); @@ -704,6 +707,7 @@ type property Strings[Index: Integer]: string read Get write Put; default; property Text: string read GetTextStr write SetTextStr; property StringsAdapter: IStringsAdapter read FAdapter write SetStringsAdapter; + Property SkipLastLineBreak : Boolean Read GetSkipLastLineBreak Write SetSkipLastLineBreak; end; { TStringList class } diff --git a/rtl/objpas/classes/stringl.inc b/rtl/objpas/classes/stringl.inc index ad60d7585b..448878d38a 100644 --- a/rtl/objpas/classes/stringl.inc +++ b/rtl/objpas/classes/stringl.inc @@ -80,6 +80,20 @@ begin end; end; +Function TStrings.GetSkipLastLineBreak : Boolean; + +begin + CheckSpecialChars; + Result:=FSkipLastLineBreak; +end; + +procedure TStrings.SetSkipLastLineBreak(const AValue : Boolean); + +begin + CheckSpecialChars; + FSkipLastLineBreak:=AValue; +end; + Function TStrings.GetLBS : TTextLineBreakStyle; begin CheckSpecialChars; @@ -512,6 +526,8 @@ begin NLS:=Length(NL); For I:=0 to count-1 do L:=L+Length(Strings[I])+NLS; + if SkipLastLineBreak then + Dec(L,NLS); Setlength(Result,L); P:=Pointer(Result); For i:=0 To count-1 do @@ -521,11 +537,12 @@ begin if L<>0 then System.Move(Pointer(S)^,P^,L); P:=P+L; - For L:=1 to NLS do - begin - P^:=NL[L]; - inc(P); - end; + if (I