* when inserting a non-empty ansistring into an empty ansistring, the

destination must get the code page of the source (mantis #28850)

git-svn-id: trunk@32066 -
This commit is contained in:
Jonas Maebe 2015-10-16 19:15:40 +00:00
parent b2144d1da0
commit 1294dc1ede
3 changed files with 25 additions and 1 deletions

1
.gitattributes vendored
View File

@ -14764,6 +14764,7 @@ tests/webtbs/tw2876.pp svneol=native#text/plain
tests/webtbs/tw28766.pp svneol=native#text/pascal
tests/webtbs/tw2883.pp svneol=native#text/plain
tests/webtbs/tw2885.pp svneol=native#text/plain
tests/webtbs/tw28850.pp svneol=native#text/plain
tests/webtbs/tw2886.pp svneol=native#text/plain
tests/webtbs/tw2891.pp svneol=native#text/plain
tests/webtbs/tw2892.pp svneol=native#text/plain

View File

@ -1384,7 +1384,10 @@ begin
index := LS+1;
Dec(Index);
SetLength(Temp,Length(Source)+LS);
cp:=TranslatePlaceholderCP(StringCodePage(S));
if length(S)<>0 then
cp:=TranslatePlaceholderCP(StringCodePage(S))
else
cp:=TranslatePlaceholderCP(StringCodePage(Source));
SetCodePage(Temp,cp,false);
If Index>0 then
fpc_pchar_ansistr_intern_charmove(pchar(S),0,Temp,0,Index);

20
tests/webtbs/tw28850.pp Normal file
View File

@ -0,0 +1,20 @@
var
s1, s2: ansistring;
begin
s1 := 'abc';
s2:='';
{ ensure the codepage of s1 is different from defaultsystemcodepage }
if defaultsystemcodepage=866 then
setcodepage(rawbytestring(s1),1251,false)
else
setcodepage(rawbytestring(s1),866,false);
{ if the destination is empty, insert must create a new string
with the same code page as the source }
Insert(s1, s2, 1);
if StringRefCount(s1)<>1 then
halt(1);
if StringRefCount(s2)<>1 then
halt(2);
if stringcodepage(s2)<>stringcodepage(s1) then
halt(3);
end.