* don't stop at #0 characters for setstring with pchar either

git-svn-id: trunk@13828 -
This commit is contained in:
Jonas Maebe 2009-10-09 19:47:46 +00:00
parent 3f5ce0d228
commit be39c47d02
3 changed files with 14 additions and 16 deletions

View File

@ -1660,13 +1660,7 @@ var
begin
SetLength(S,Len);
If (Buf<>Nil) and (Len>0) then
begin
BufLen := IndexByte(Buf^, Len+1, 0);
If (BufLen>0) and (BufLen < Len) then
Len := BufLen;
widestringmanager.Ansi2UnicodeMoveProc(Buf,S,Len);
//PUnicodeChar(Pointer(S)+Len*sizeof(UnicodeChar))^:=#0;
end;
widestringmanager.Ansi2UnicodeMoveProc(Buf,S,Len);
end;

View File

@ -1025,18 +1025,10 @@ end;
Procedure SetString (Out S : WideString; Buf : PChar; Len : SizeInt);
var
BufLen: SizeInt;
begin
SetLength(S,Len);
If (Buf<>Nil) and (Len>0) then
begin
BufLen := IndexByte(Buf^, Len+1, 0);
If (BufLen>0) and (BufLen < Len) then
Len := BufLen;
widestringmanager.Ansi2WideMoveProc(Buf,S,Len);
//PWideChar(Pointer(S)+Len*sizeof(WideChar))^:=#0;
end;
widestringmanager.Ansi2WideMoveProc(Buf,S,Len);
end;

View File

@ -3,14 +3,26 @@ var
u: unicodestring;
pw: pwidechar;
pu: punicodechar;
p: pchar;
begin
pw:='abc'#0'def';
setstring(w,pw,7);
if w<>'abc'#0'def' then
halt(1);
w:='';
pu:='abc'#0'def';
setstring(u,pu,7);
if u<>'abc'#0'def' then
halt(2);
u:='';
p:='abc'#0'def';
setstring(w,p,7);
if w<>'abc'#0'def' then
halt(3);
setstring(u,p,7);
if u<>'abc'#0'def' then
halt(4);
end.