* Fixed fpc_WideCharArray_To_WideStr in case if widechar array contains empty string.

+ Test.

git-svn-id: trunk@8317 -
This commit is contained in:
yury 2007-08-28 09:53:29 +00:00
parent 65afe53eb0
commit 685810c18c
3 changed files with 16 additions and 3 deletions

1
.gitattributes vendored
View File

@ -6364,6 +6364,7 @@ tests/tbs/tb0537.pp svneol=native#text/plain
tests/tbs/tb0538.pp svneol=native#text/plain tests/tbs/tb0538.pp svneol=native#text/plain
tests/tbs/tb0539.pp svneol=native#text/plain tests/tbs/tb0539.pp svneol=native#text/plain
tests/tbs/tb0540.pp svneol=native#text/x-pascal tests/tbs/tb0540.pp svneol=native#text/x-pascal
tests/tbs/tb0541.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

@ -747,9 +747,7 @@ begin
else else
i := high(arr)+1; i := high(arr)+1;
SetLength(fpc_WideCharArray_To_WideStr,i); SetLength(fpc_WideCharArray_To_WideStr,i);
Move(pwidechar(@arr)^, PWideChar(Pointer(@fpc_WideCharArray_To_WideStr[1]))^,i*sizeof(WideChar)); Move(arr[0], Pointer(fpc_WideCharArray_To_WideStr)^,i*sizeof(WideChar));
{ Terminating Zero }
PWideChar(Pointer(@fpc_WideCharArray_To_WideStr[1])+i*sizeof(WideChar))^:=#0;
end; end;
{$ifndef FPC_STRTOCHARARRAYPROC} {$ifndef FPC_STRTOCHARARRAYPROC}

14
tests/tbs/tb0541.pp Normal file
View File

@ -0,0 +1,14 @@
const
TestStr: widestring = 'Test';
var
buf: array[0..10] of widechar;
s: widestring;
begin
Move(TestStr[1], buf[0], (Length(TestStr) + 1)*SizeOf(widechar));
s:=buf;
writeln(s);
buf[0]:=#0;
s:=buf;
end.