* 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/tb0500.pp svneol=native#text/plain
tests/tbs/tb0501.pp svneol=native#text/plain tests/tbs/tb0501.pp svneol=native#text/plain
tests/tbs/tb0502.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/ub0060.pp svneol=native#text/plain
tests/tbs/ub0069.pp svneol=native#text/plain tests/tbs/ub0069.pp svneol=native#text/plain
tests/tbs/ub0119.pp svneol=native#text/plain tests/tbs/ub0119.pp svneol=native#text/plain

View File

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