* fixed fpc_AnsiStr_Concat_multi + test

git-svn-id: trunk@4790 -
This commit is contained in:
Jonas Maebe 2006-10-04 16:44:31 +00:00
parent 32a86f6daa
commit 86649024b3
3 changed files with 54 additions and 9 deletions

1
.gitattributes vendored
View File

@ -5832,6 +5832,7 @@ tests/tbs/tb0499.pp svneol=native#text/plain
tests/tbs/tb0500.pp svneol=native#text/plain
tests/tbs/tb0501.pp svneol=native#text/plain
tests/tbs/tb0502.pp svneol=native#text/plain
tests/tbs/tb0503.pp svneol=native#text/plain
tests/tbs/ub0060.pp svneol=native#text/plain
tests/tbs/ub0069.pp svneol=native#text/plain
tests/tbs/ub0119.pp svneol=native#text/plain

View File

@ -245,6 +245,7 @@ Var
p,pc : pointer;
Size,NewLen,
OldDestLen : SizeInt;
destcopy : ansistring;
begin
if high(sarr)=0 then
begin
@ -253,17 +254,19 @@ begin
end;
lowstart:=low(sarr);
if Pointer(DestS)=Pointer(sarr[lowstart]) then
inc(lowstart);
{ Check for another reuse, then we can't use
the append optimization }
for i:=lowstart to high(sarr) do
begin
inc(lowstart);
{ Check for another reuse, then we can't use
the append optimization }
for i:=lowstart to high(sarr) do
if Pointer(DestS)=Pointer(sarr[i]) then
begin
if Pointer(DestS)=Pointer(sarr[i]) then
begin
lowstart:=low(sarr);
break;
end;
{ if DestS is used somewhere in the middle of the expression,
we need to make sure the original string still exists after
we empty/modify DestS }
destcopy:=dests;
lowstart:=low(sarr);
break;
end;
end;
{ Start with empty DestS if we start with concatting

41
tests/tbs/tb0503.pp Normal file
View File

@ -0,0 +1,41 @@
procedure testansi;
var
s, q: ansistring;
begin
s := 'hell';
s := s+'o';
q := '"';
q := q+'''';
s := s + q + s + 'abc';
if (s <> 'hello"''helloabc') then
halt(1);
s := 'hell';
s := s+'o';
s := q+s+q;
if (s <> '"''hello"''') then
halt(2);
end;
procedure testshort;
var
s, q: shortstring;
begin
s := 'hell';
s := s+'o';
q := '"';
q := q+'''';
s := s + q + s + 'abc';
if (s <> 'hello"''helloabc') then
halt(3);
s := 'hell';
s := s+'o';
s := q+s+q;
if (s <> '"''hello"''') then
halt(4);
end;
begin
testansi;
testshort;
end.