diff --git a/rtl/inc/compproc.inc b/rtl/inc/compproc.inc index 3043c5651d..69938e38c0 100644 --- a/rtl/inc/compproc.inc +++ b/rtl/inc/compproc.inc @@ -210,8 +210,10 @@ Procedure fpc_Read_Text_Char(var f : Text; var c : char); compilerproc; Procedure fpc_Read_Text_SInt(var f : Text; var l :ValSInt); compilerproc; Procedure fpc_Read_Text_UInt(var f : Text; var u :ValUInt); compilerproc; Procedure fpc_Read_Text_Float(var f : Text; var v :ValReal); compilerproc; +{$ifndef CPU64} Procedure fpc_Read_Text_QWord(var f : text; var q : qword); compilerproc; Procedure fpc_Read_Text_Int64(var f : text; var i : int64); compilerproc; +{$endif CPU64} {$ifdef FPC_INCLUDE_SOFTWARE_MOD_DIV} function fpc_div_dword(n,z : dword) : dword; compilerproc; @@ -328,7 +330,10 @@ function fpc_qword_to_double(q: qword): double; compilerproc; { $Log$ - Revision 1.54 2004-04-29 19:50:13 peter + Revision 1.55 2004-05-01 20:52:50 peter + * ValSInt fixed for 64 bit + + Revision 1.54 2004/04/29 19:50:13 peter * x86-64 fixes Revision 1.53 2004/04/29 18:59:43 peter diff --git a/rtl/inc/generic.inc b/rtl/inc/generic.inc index 8343809d25..00acd2cab6 100644 --- a/rtl/inc/generic.inc +++ b/rtl/inc/generic.inc @@ -1150,6 +1150,66 @@ end; {$endif ndef FPC_SYSTEM_HAS_INT_STR_LONGWORD} +{$ifndef FPC_SYSTEM_HAS_INT_STR_INT64} + +procedure int_str(l : int64;var s : string); +var + value: int64; + negative: boolean; + + begin + negative := false; + s:=''; + { Workaround: } + if l=int64($8000000000000000) then + begin + s:='-9223372036854775808'; + exit; + end; + { handle case where l = 0 } + if l = 0 then + begin + s:='0'; + exit; + end; + If l < 0 then + begin + negative := true; + value:=abs(l); + end + else + value:=l; + { handle non-zero case } + while value>0 do + begin + s:=char((value mod 10)+ord('0'))+s; + value := value div 10; + end; + if negative then + s := '-' + s; + end; + +{$endif ndef FPC_SYSTEM_HAS_INT_STR_INT64} + +{$ifndef FPC_SYSTEM_HAS_INT_STR_QWORD} + +procedure int_str(l : qword;var s : string); +begin + s:=''; + if l = 0 then + begin + s := '0'; + exit; + end; + while l>0 do + begin + s:=char(ord('0')+(l mod 10))+s; + l:=l div 10; + end; +end; + +{$endif ndef FPC_SYSTEM_HAS_INT_STR_QWORD} + {$ifndef FPC_SYSTEM_HAS_SYSRESETFPU} procedure SysResetFpu; @@ -1161,7 +1221,10 @@ end; { $Log$ - Revision 1.74 2004-05-01 15:26:33 jonas + Revision 1.75 2004-05-01 20:52:50 peter + * ValSInt fixed for 64 bit + + Revision 1.74 2004/05/01 15:26:33 jonas * use some more string routines from libc if FPC_USE_LIBC is used Revision 1.73 2004/04/29 19:50:13 peter diff --git a/rtl/inc/sstrings.inc b/rtl/inc/sstrings.inc index 7c6b416256..5c598dc959 100644 --- a/rtl/inc/sstrings.inc +++ b/rtl/inc/sstrings.inc @@ -378,40 +378,17 @@ end; {$ifndef CPU64} - procedure int_qword_str(value : qword;var s : string); - var - hs : string; - begin - hs:=''; - repeat - hs:=chr(longint(value mod qword(10))+48)+hs; - value:=value div qword(10); - until value=0; - s:=hs; - end; - - procedure fpc_shortstr_qword(v : qword;len : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_QWORD']; {$ifdef hascompilerproc} compilerproc; {$endif} begin - int_qword_str(v,s); + int_str(v,s); if length(s)