* fix widestringreplace, shared routine missed some *sizeof(srchar) here and there.

patch from Cyrax, Mantis #32649

git-svn-id: trunk@37882 -
This commit is contained in:
marco 2017-12-30 15:51:53 +00:00
parent d9f733bada
commit acf6fde3cf

View File

@ -4,6 +4,11 @@ var
c,d: SRPChar ; c,d: SRPChar ;
begin begin
Result:='';
c:= NIL; d:=NIL;
OldPat:='';
Srch:='';
PatLength:=Length(OldPattern); PatLength:=Length(OldPattern);
if PatLength=0 then begin if PatLength=0 then begin
Result:=S; Result:=S;
@ -26,7 +31,7 @@ begin
repeat repeat
P:=Pos(OldPat,Srch,P); P:=Pos(OldPat,Srch,P);
if P>0 then begin if P>0 then begin
move(NewPattern[1],Result[P],PatLength); move(NewPattern[1],Result[P],PatLength*SizeOf(SRChar));
if not (rfReplaceAll in Flags) then exit; if not (rfReplaceAll in Flags) then exit;
inc(P,PatLength); inc(P,PatLength);
end; end;
@ -49,7 +54,7 @@ begin
exit; exit;
end; end;
NewPatLength:=Length(NewPattern); NewPatLength:=Length(NewPattern);
SetLength(Result,Length(S)+PatCount*(NewPatLength-PatLength)*SizeOf(SRChar)); SetLength(Result,Length(S)+PatCount*(NewPatLength-PatLength));
P:=1; PrevP:=0; P:=1; PrevP:=0;
c:=SRPChar(Result); d:=SRPChar(S); c:=SRPChar(Result); d:=SRPChar(S);
repeat repeat
@ -57,12 +62,12 @@ begin
if P>0 then begin if P>0 then begin
Cnt:=P-PrevP-1; Cnt:=P-PrevP-1;
if Cnt>0 then begin if Cnt>0 then begin
Move(d^,c^,Cnt); Move(d^,c^,Cnt*SizeOf(SRChar));
inc(c,Cnt); inc(c,Cnt);
inc(d,Cnt); inc(d,Cnt);
end; end;
if NewPatLength>0 then begin if NewPatLength>0 then begin
Move(NewPattern[1],c^,NewPatLength); Move(NewPattern[1],c^,NewPatLength*SizeOf(SRChar));
inc(c,NewPatLength); inc(c,NewPatLength);
end; end;
inc(P,PatLength); inc(P,PatLength);
@ -72,7 +77,7 @@ begin
end; end;
until p=0; until p=0;
Cnt:=Length(S)-PrevP; Cnt:=Length(S)-PrevP;
if Cnt>0 then Move(d^,c^,Cnt); if Cnt>0 then Move(d^,c^,Cnt*SizeOf(SRChar));
end; end;
end; end;
@ -113,4 +118,4 @@ begin
end; end;
end; end;
end; end;
*) *)