mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 07:29:29 +02:00
* synchronised code of fpc_ansistr_to_chararray() with
fpc_shortstr_to_chararray() * same for fpc_unicodestr_to_chararray() + fixes git-svn-id: branches/jvmbackend@18702 -
This commit is contained in:
parent
02f443ce68
commit
1ac7146182
@ -301,16 +301,16 @@ end;
|
|||||||
|
|
||||||
procedure fpc_ansistr_to_chararray(out res: array of ansichar; const src: ansistring); compilerproc;
|
procedure fpc_ansistr_to_chararray(out res: array of ansichar; const src: ansistring); compilerproc;
|
||||||
var
|
var
|
||||||
i, len: SizeInt;
|
len: longint;
|
||||||
begin
|
begin
|
||||||
len := length(src);
|
len:=length(src);
|
||||||
if len > length(res) then
|
if len>length(res) then
|
||||||
len := length(res);
|
len:=length(res);
|
||||||
{ make sure we don't try to access element 1 of the ansistring if it's nil }
|
{ make sure we don't try to access element 1 of the ansistring if it's nil }
|
||||||
if len > 0 then
|
if len>0 then
|
||||||
JLSystem.ArrayCopy(JLObject(AnsistringClass(src).fdata),0,JLObject(@res),0,len);
|
JLSystem.ArrayCopy(JLObject(AnsistringClass(src).fdata),0,JLObject(@res),0,len);
|
||||||
for i:=len to length(res) do
|
if len<=high(res) then
|
||||||
res[i]:=#0;
|
JUArrays.fill(TJByteArray(@res),len,high(res),0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -422,19 +422,21 @@ end;
|
|||||||
|
|
||||||
procedure fpc_unicodestr_to_chararray(out res: array of AnsiChar; const src: UnicodeString); compilerproc;
|
procedure fpc_unicodestr_to_chararray(out res: array of AnsiChar; const src: UnicodeString); compilerproc;
|
||||||
var
|
var
|
||||||
i, len: SizeInt;
|
len: longint;
|
||||||
temp: array of jbyte;
|
temp: array of jbyte;
|
||||||
begin
|
begin
|
||||||
len := length(src);
|
len:=length(src);
|
||||||
{ make sure we don't dereference src if it can be nil (JM) }
|
{ make sure we don't dereference src if it can be nil (JM) }
|
||||||
if len > 0 then
|
if len>0 then
|
||||||
begin
|
begin
|
||||||
temp:=JLString(src).getBytes;
|
temp:=JLString(src).getBytes;
|
||||||
if len > length(temp) then
|
len:=length(temp);
|
||||||
len := length(temp);
|
if len>length(res) then
|
||||||
for i := 0 to len-1 do
|
len:=length(res);
|
||||||
res[i] := chr(temp[i]);
|
JLSystem.ArrayCopy(JLObject(temp),0,JLObject(@res),0,len);
|
||||||
end;
|
end;
|
||||||
|
if len<=high(res) then
|
||||||
|
JUArrays.fill(TJByteArray(@res),len,high(res),0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user