Răsfoiți Sursa

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

git-svn-id: branches/i8086@24047 -
nickysn 12 ani în urmă
părinte
comite
8b6b832677
2 a modificat fișierele cu 50 adăugiri și 0 ștergeri
  1. 4 0
      rtl/inc/compproc.inc
  2. 46 0
      rtl/inc/text.inc

+ 4 - 0
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}
 

+ 46 - 0
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}
+
 
 
 {*****************************************************************************