mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 09:09:30 +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/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
|
||||
|
@ -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
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