* 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,7 +254,6 @@ begin
end; end;
lowstart:=low(sarr); lowstart:=low(sarr);
if Pointer(DestS)=Pointer(sarr[lowstart]) then if Pointer(DestS)=Pointer(sarr[lowstart]) then
begin
inc(lowstart); inc(lowstart);
{ Check for another reuse, then we can't use { Check for another reuse, then we can't use
the append optimization } the append optimization }
@ -261,11 +261,14 @@ begin
begin begin
if Pointer(DestS)=Pointer(sarr[i]) then if Pointer(DestS)=Pointer(sarr[i]) then
begin begin
{ 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); lowstart:=low(sarr);
break; break;
end; end;
end; end;
end;
{ Start with empty DestS if we start with concatting { Start with empty DestS if we start with concatting
the first array element } the first array element }
if lowstart=low(sarr) then if lowstart=low(sarr) then

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.