Oh, 

I found the bug. 
There should be: 

Inc(byte(P^), 32);

instead of previously posted:


Inc(byte(P^));

Here is correct implementation:

----

Function Lowercase41(Const S : String) : String;
var
  i: Integer;
  P: PChar;
  Changed: boolean;
begin
  Changed:=False;
  P := PChar(S);
  for i := 1 to Length(S) do begin
    if P^ in ['A'..'Z'] then begin
      if not Changed then begin
        Changed := True;
        Result := S;
        UniqueString(Result);
        P := PChar(Result) + i - 1;
      end;
      Inc(byte(P^), 32);
    end;
    Inc(P);
  end;
  if not Changed then
    Result := S;
end;

Function Lowercase42(Const S : String) : String;
var
  i: Integer;
  P: PChar;
begin
  Result := S;
  UniqueString(Result);
  P := PChar(Result);
  i := Length(Result);
  while i > 0 do begin
    if P^ in ['A'..'Z'] then
      Inc(byte(P^), 32);
    Inc(P);
    Dec(i);
  end;
end;



_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to