From 12a3b11cdbb1e9521463f1f0e1626b9e4a6f2338 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 18 May 2001 22:59:59 +0000 Subject: [PATCH] * merged fixes branch fixes --- rtl/inc/generic.inc | 68 ++++++++++++++++++++++++++++----------------- rtl/inc/genset.inc | 21 +++++++++++--- 2 files changed, 60 insertions(+), 29 deletions(-) diff --git a/rtl/inc/generic.inc b/rtl/inc/generic.inc index dd4aa3756f..23fe803aaf 100644 --- a/rtl/inc/generic.inc +++ b/rtl/inc/generic.inc @@ -745,30 +745,40 @@ end; procedure int_str(l : longint;var s : string); var - sign : boolean; -begin - { Workaround: } - if l=$80000000 then - begin - s:='-2147483648'; - exit; - end; - if l<0 then - begin - sign:=true; - l:=-l; - end - else - sign:=false; - s:=''; - while l>0 do - begin - s:=char(ord('0')+(l mod 10))+s; - l:=l div 10; - end; - if sign then - s:='-'+s; -end; + value: longint; + negative: boolean; + + begin + negative := false; + s:=''; + { Workaround: } + if l=$80000000 then + begin + s:='-2147483648'; + 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_LONGINT} @@ -777,6 +787,11 @@ end; procedure int_str(l : cardinal;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; @@ -811,7 +826,10 @@ end; { $Log$ - Revision 1.11 2001-05-16 17:44:25 jonas + Revision 1.12 2001-05-18 22:59:59 peter + * merged fixes branch fixes + + Revision 1.11 2001/05/16 17:44:25 jonas + odd() for cardinal, int64 and qword (merged) Revision 1.10 2001/05/09 19:57:07 peter diff --git a/rtl/inc/genset.inc b/rtl/inc/genset.inc index 110d8371c5..b6375a64f6 100644 --- a/rtl/inc/genset.inc +++ b/rtl/inc/genset.inc @@ -95,7 +95,11 @@ {$ifndef FPC_SYSTEM_HAS_FPC_SET_IN_BYTE} - function do_in_byte(p : pointer;b : byte):boolean;[public,alias:'FPC_SET_IN_BYTE']; + +{ saveregisters is a bit of overkill, but this routine should save all registers } +{ and it should be overriden for each platform and be written in assembler } +{ by saving all required registers. } + function do_in_byte(p : pointer;b : byte):boolean;[public,alias:'FPC_SET_IN_BYTE'];saveregisters; { tests if the element b is in the set p the carryflag is set if it present } @@ -167,7 +171,10 @@ {$endif} {$ifndef FPC_SYSTEM_HAS_FPC_SET_COMP_SETS} - function do_comp_sets(set1,set2 : pointer):boolean;[public,alias:'FPC_SET_COMP_SETS']; +{ saveregisters is a bit of overkill, but this routine should save all registers } +{ and it should be overriden for each platform and be written in assembler } +{ by saving all required registers. } + function do_comp_sets(set1,set2 : pointer):boolean;[public,alias:'FPC_SET_COMP_SETS'];saveregisters; { compares set1 and set2 zeroflag is set if they are equal } @@ -185,7 +192,10 @@ {$ifndef FPC_SYSTEM_HAS_FPC_SET_CONTAINS_SET} - function do_contains_sets(set1,set2 : pointer):boolean;[public,alias:'FPC_SET_CONTAINS_SETS']; +{ saveregisters is a bit of overkill, but this routine should save all registers } +{ and it should be overriden for each platform and be written in assembler } +{ by saving all required registers. } + function do_contains_sets(set1,set2 : pointer):boolean;[public,alias:'FPC_SET_CONTAINS_SETS'];saveregisters; { on exit, zero flag is set if set1 <= set2 (set2 contains set1) } @@ -202,7 +212,10 @@ { $Log$ - Revision 1.2 2001-05-09 19:57:07 peter + Revision 1.3 2001-05-18 22:59:59 peter + * merged fixes branch fixes + + Revision 1.2 2001/05/09 19:57:07 peter *** empty log message *** }