+ added helper functions for read/readln longint/longword on 16/8-bit cpus

git-svn-id: branches/i8086@24047 -
This commit is contained in:
nickysn 2013-03-28 23:56:47 +00:00
parent 9b79c52f32
commit 8b6b832677
2 changed files with 50 additions and 0 deletions

View File

@ -478,6 +478,10 @@ procedure fpc_Read_Text_Currency(var f : Text; out v : Currency); compilerproc;
Procedure fpc_Read_Text_QWord(var f : text; out q : qword); compilerproc;
Procedure fpc_Read_Text_Int64(var f : text; out i : int64); compilerproc;
{$endif CPU64}
{$if defined(CPU16) or defined(CPU8)}
Procedure fpc_Read_Text_LongWord(var f : text; out q : longword); compilerproc;
Procedure fpc_Read_Text_LongInt(var f : text; out i : longint); compilerproc;
{$endif CPU16 or CPU8}
function fpc_GetBuf(var f : Text) : pchar; compilerproc;
{$endif FPC_HAS_FEATURE_TEXTIO}

View File

@ -1737,6 +1737,52 @@ End;
{$endif CPU64}
{$if defined(CPU16) or defined(CPU8)}
procedure fpc_Read_Text_LongWord(var f : text; out q : longword); iocheck; compilerproc;
var
hs : String;
code : longint;
Begin
q:=0;
If not CheckRead(f) then
exit;
hs:='';
if IgnoreSpaces(f) then
begin
{ When spaces were found and we are now at EOF,
then we return 0 }
if (TextRec(f).BufPos>=TextRec(f).BufEnd) then
exit;
ReadNumeric(f,hs);
end;
val(hs,q,code);
If code<>0 Then
InOutRes:=106;
End;
procedure fpc_Read_Text_LongInt(var f : text; out i : longint); iocheck; compilerproc;
var
hs : String;
code : Longint;
Begin
i:=0;
If not CheckRead(f) then
exit;
hs:='';
if IgnoreSpaces(f) then
begin
{ When spaces were found and we are now at EOF,
then we return 0 }
if (TextRec(f).BufPos>=TextRec(f).BufEnd) then
exit;
ReadNumeric(f,hs);
end;
Val(hs,i,code);
If code<>0 Then
InOutRes:=106;
End;
{$endif CPU16 or CPU8}
{*****************************************************************************