From 8b6b832677ffb21a903296f84d4dd04d58863432 Mon Sep 17 00:00:00 2001 From: nickysn Date: Thu, 28 Mar 2013 23:56:47 +0000 Subject: [PATCH] + added helper functions for read/readln longint/longword on 16/8-bit cpus git-svn-id: branches/i8086@24047 - --- rtl/inc/compproc.inc | 4 ++++ rtl/inc/text.inc | 46 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/rtl/inc/compproc.inc b/rtl/inc/compproc.inc index 5c7a257842..50f1e3882d 100644 --- a/rtl/inc/compproc.inc +++ b/rtl/inc/compproc.inc @@ -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} diff --git a/rtl/inc/text.inc b/rtl/inc/text.inc index 40ae98538e..6be9691206 100644 --- a/rtl/inc/text.inc +++ b/rtl/inc/text.inc @@ -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} + {*****************************************************************************