mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 08:49:25 +02:00
* fixed fpc_AnsiStr_Concat_multi + test
git-svn-id: trunk@4790 -
This commit is contained in:
parent
32a86f6daa
commit
86649024b3
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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
|
||||||
|
@ -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
41
tests/tbs/tb0503.pp
Normal 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.
|
Loading…
Reference in New Issue
Block a user