[lazarus] Bug in Trim not in Pos ("PATCH")

Cliff Baeseman vbman at pcpros.net
Fri Mar 31 02:13:57 EST 2000


Here is a patch to a bug I found in the trim function in the rtl.

It is inconsistant with delphi which removes the cr's and linefeeds the below 
copy works like delphi's. I just added the or's.

That one was causing me a bitch of a time porting my code if this would have
been consistant with delphi it would have compiled on the first shot. For now
in my parser I just copied it to my unit and called it StringTrim.


function Trim(const S: string): string;
var Ofs, Len: integer;
begin
  len := Length(S);
  while (Len>0) and (S[Len] = ' ') or (S[Len] = #10) or (S[Len] = #13) do
   dec(Len);
  Ofs := 1;
  while (Ofs<=Len) and (S[Ofs] = ' ') or (S[Ofs] = #10) or (S[Len] = #13) do
   Inc(Ofs);
  result := Copy(S, Ofs, 1 + Len - Ofs);
end ;


Cliff






More information about the Lazarus mailing list