[fpc-pascal] Improve TStringList.Text setter?

Michael Van Canneyt michael at freepascal.org
Thu May 5 23:27:05 CEST 2022



On Thu, 5 May 2022, Alexey Torgashin via fpc-pascal wrote:

> (I posted to the forum, but it's better to post here.)
> TStringList.Text setter does this
>
> <pre>
>    Procedure TStrings.DoSetTextStr(const Value: string; DoClear : Boolean);
> ...
>        if FLineBreak=sLineBreak then
>          begin
>          While GetNextLine (Value,S,P) do
>            Add(S)
>          end
>        else
>          While GetNextLineBreak (Value,S,P) do
>            Add(S);
>      finally
>        EndUpdate;
>      end;
>    end;
> </pre>
>
> here it calls GetNextLine which does SPECIAL handling of #10 and #13 and 
> #13#10 line breaks. If it does special handling of #10 and #13 and #13#10 
> line breaks, why don't we check
>
>  if (FLineBreak=#10) or (FLineBreak=#13) or (FLineBreak=#13#10)

This would change the behaviour.

Now the special treatment is only done when FLinebreak exactly matches
sLineBreak.

Michael.


More information about the fpc-pascal mailing list