* Promoted result type of FPC_PCHAR_LENGTH and FPC_PWIDECHAR_LENGTH to SizeInt.

+ Check for nil pointer in FPC_PWIDECHAR_LENGTH

git-svn-id: trunk@17733 -
This commit is contained in:
sergei 2011-06-13 04:59:17 +00:00
parent 0d71ef61fc
commit 4ebc34c5e7
10 changed files with 17 additions and 15 deletions

View File

@ -506,7 +506,7 @@ end;
{$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
{$define FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
function fpc_Pchar_length(p:Pchar):longint;assembler;nostackframe;[public,alias:'FPC_PCHAR_LENGTH'];compilerproc;
function fpc_Pchar_length(p:Pchar):sizeint;assembler;nostackframe;[public,alias:'FPC_PCHAR_LENGTH'];compilerproc;
asm
cmp r0,#0

View File

@ -461,7 +461,7 @@ end;
{$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
{$define FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
function fpc_Pchar_length(p:Pchar):longint;assembler;nostackframe;[public,alias:'FPC_PCHAR_LENGTH'];compilerproc;
function fpc_Pchar_length(p:Pchar):sizeint;assembler;nostackframe;[public,alias:'FPC_PCHAR_LENGTH'];compilerproc;
asm
cmp r0,#0

View File

@ -1144,7 +1144,7 @@ end;
{$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
{$define FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
function fpc_pchar_length(p:pchar):longint;assembler;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
function fpc_pchar_length(p:pchar):sizeint;assembler;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
var
saveedi : longint;

View File

@ -110,7 +110,7 @@ end;
function libc_pchar_length(p:pchar):size_t; cdecl; external 'c' name 'strlen';
function fpc_pchar_length(p:pchar):longint;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
function fpc_pchar_length(p:pchar):sizeint;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
begin
if assigned(p) then
fpc_pchar_length:=libc_pchar_length(p)

View File

@ -67,8 +67,8 @@ function fpc_pchar_to_shortstr(p:pchar):shortstring; compilerproc;
procedure fpc_pchar_to_shortstr(out res : shortstring;p:pchar); compilerproc;
{$endif FPC_STRTOSHORTSTRINGPROC}
function fpc_pchar_length(p:pchar):longint; compilerproc;
function fpc_pwidechar_length(p:pwidechar):longint; compilerproc;
function fpc_pchar_length(p:pchar):sizeint; compilerproc;
function fpc_pwidechar_length(p:pwidechar):sizeint; compilerproc;
{$ifndef FPC_STRTOSHORTSTRINGPROC}
function fpc_chararray_to_shortstr(const arr: array of char; zerobased: boolean = true):shortstring; compilerproc;

View File

@ -1243,8 +1243,8 @@ end;
{$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
function fpc_pchar_length(p:pchar):longint;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
var i : longint;
function fpc_pchar_length(p:pchar):sizeint;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
var i : sizeint;
begin
i:=0;
if assigned(p) then
@ -1257,11 +1257,13 @@ end;
{$ifndef FPC_SYSTEM_HAS_FPC_PWIDECHAR_LENGTH}
function fpc_pwidechar_length(p:pwidechar):longint;[public,alias:'FPC_PWIDECHAR_LENGTH']; compilerproc;
var i : longint;
function fpc_pwidechar_length(p:pwidechar):sizeint;[public,alias:'FPC_PWIDECHAR_LENGTH']; compilerproc;
var i : sizeint;
begin
i:=0;
while p[i]<>#0 do inc(i);
if assigned(p) then
while p[i]<>#0 do
inc(i);
exit(i);
end;

View File

@ -812,7 +812,7 @@ Function Sseg:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
****************************************************************************}
function strpas(p:pchar):shortstring;{$ifdef SYSTEMINLINE}inline;{$endif}
function strlen(p:pchar):longint;external name 'FPC_PCHAR_LENGTH';
function strlen(p:pchar):sizeint;external name 'FPC_PCHAR_LENGTH';
{ Shortstring functions }
Procedure Delete(var s:shortstring;index:SizeInt;count:SizeInt);

View File

@ -100,7 +100,7 @@ implementation
{ include system independent routines }
{$I system.inc}
function fpc_pwidechar_length(p: PWideChar): LongInt; external name 'FPC_PWIDECHAR_LENGTH';
function fpc_pwidechar_length(p: PWideChar): SizeInt; external name 'FPC_PWIDECHAR_LENGTH';
{ based on setup_arguments from Win32 RTL }
procedure setup_arguments;

View File

@ -673,7 +673,7 @@ end;
Initialization code
****************************************************************************}
function wstrlen(p: PWideChar): LongInt; external name 'FPC_PWIDECHAR_LENGTH';
function wstrlen(p: PWideChar): SizeInt; external name 'FPC_PWIDECHAR_LENGTH';
function GetEnvironmentVariable(const EnvVar: String): String;
var

View File

@ -1005,7 +1005,7 @@ procedure fpc_pchar_to_shortstr(out res : shortstring;p:pchar);assembler;[public
{$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
{$define FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
function fpc_pchar_length(p:pchar):longint;assembler;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc; nostackframe;
function fpc_pchar_length(p:pchar):sizeint;assembler;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc; nostackframe;
{$include strlen.inc}
{$endif FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}